Codebase list libsdl2-mixer / 4b580e0
New upstream version 2.0.5~20211214.gffd0589+dfsg Simon McVittie 2 years ago
173 changed file(s) with 23367 addition(s) and 66009 deletion(s). Raw diff Collapse all Expand all
00 # Save the local path
11 SDL_MIXER_LOCAL_PATH := $(call my-dir)
22
3 # Enable this if you want to support loading WAV music
4 SUPPORT_WAV ?= true
35
46 # Enable this if you want to support loading FLAC music with libFLAC
57 SUPPORT_FLAC ?= true
6 FLAC_LIBRARY_PATH := external/flac-1.3.2
8 FLAC_LIBRARY_PATH := external/flac-1.3.3
79
810 # Enable this if you want to support loading OGG Vorbis music via Tremor
911 SUPPORT_OGG ?= true
1214
1315 # Enable this if you want to support loading MP3 music via MPG123
1416 SUPPORT_MP3_MPG123 ?= true
15 MPG123_LIBRARY_PATH := external/mpg123-1.25.6
17 MPG123_LIBRARY_PATH := external/mpg123-1.25.13
1618
1719 # Enable this if you want to support loading MOD music via modplug
1820 SUPPORT_MOD_MODPLUG ?= true
2022
2123 # Enable this if you want to support TiMidity
2224 SUPPORT_MID_TIMIDITY ?= true
23 TIMIDITY_LIBRARY_PATH := timidity
25 TIMIDITY_LIBRARY_PATH := src/codecs/timidity
2426
2527
2628 # Build the library
5759
5860 LOCAL_MODULE := SDL2_mixer
5961
60 LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \
62 LOCAL_C_INCLUDES := \
63 $(LOCAL_PATH)/include \
64 $(LOCAL_PATH)/src/ \
65 $(LOCAL_PATH)/src/codecs \
66
67
68 LOCAL_SRC_FILES := \
69 $(subst $(LOCAL_PATH)/,, \
70 $(wildcard $(LOCAL_PATH)/src/*.c) \
71 $(wildcard $(LOCAL_PATH)/src/codecs/*.c) \
72 )
6173
6274 LOCAL_CFLAGS :=
6375 LOCAL_LDLIBS :=
6476 LOCAL_STATIC_LIBRARIES :=
6577 LOCAL_SHARED_LIBRARIES := SDL2
78
79 ifeq ($(SUPPORT_WAV),true)
80 LOCAL_CFLAGS += -DMUSIC_WAV
81 endif
6682
6783 ifeq ($(SUPPORT_FLAC),true)
6884 LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(FLAC_LIBRARY_PATH)/include
97113 LOCAL_STATIC_LIBRARIES += timidity
98114 endif
99115
100 LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)
116 LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/include
101117
102118 include $(BUILD_SHARED_LIBRARY)
119
120 ###########################
121 #
122 # SDL2_mixer static library
123 #
124 ###########################
125
126 LOCAL_MODULE := SDL2_mixer_static
127
128 LOCAL_MODULE_FILENAME := libSDL2_mixer
129
130 LOCAL_LDLIBS :=
131 LOCAL_EXPORT_LDLIBS :=
132
133 include $(BUILD_STATIC_LIBRARY)
134
0 2.0.5:
1 Ozkan Sezer - Sun Feb 07 03:10:10 2021
2 * fixed distorted MIDI playback with FluidSynth if the sample rate
3 is out of library's limits
4 Ozkan Sezer - Fri Feb 05 14:33:50 2021
5 * Added Mix_ModMusicJumpToOrder for mod music formats
6 Ozkan Sezer - Sun Jan 31 10:03:10 2021
7 * Added libxmp support for mod music playback, partially based on
8 work by Vitaly Novichkov
9 Ozkan Sezer - Sun Jan 31 00:33:00 2021
10 * Fixed mikmod player reader issue with umx files
11 * Enabled module internal loops in modplug player
12 Ozkan Sezer - Thu Jan 28 17:02:25 2021
13 * Respect original mp3 file offset
14 Sam Lantinga - Wed Jan 20 10:17:10 2021
15 * Fixed a used-after-free issue in fluidsynth player
16 michaeljosephmaltese - Tue Nov 24 22:07:14 2020
17 * Support setting soundfont via SDL_SOUNDFONTS in OSX native midi
18 David Gow - Fri Oct 23 23:01:00 2020
19 * Fixed mp3 file detection.
20 Ozkan Sezer - Sat Jun 27 00:50:04 2020
21 * Fixed divide by zero crash in voc_get_block().
22 Matthias Gatto - Tue Dec 17 21:55:00 2019
23 * Add Mix_MusicDuration() to return music duration in seconds.
24 Vitaly Novichkov - Tue Dec 17 15:50:02 2019
25 * Fixed music_mpg123 seek bug when sample rate of the file and
26 the stream don't match
27 Ozkan Sezer - Tue Dec 17 14:56:04 2019
28 * Timidity improvements. New Mix_SetTimidityCfg() public api.
29 Ozkan Sezer - Sun Dec 08 10:20:40 2019
30 * Improved mp3 tag detection/skipping
31 Ozkan Sezer - Thu Dec 05 01:41:50 2019
32 * Updated external libraries with multiple bug/security fixes
33 Vitaly Novichkov - Wed Dec 04 18:50:02 2019
34 * Extended support for WAV files
35 Vitaly Novichkov - Tue Nov 26 15:55:50 2019
36 * Added looping support for Opus files
37 Vitaly Novichkov - Tue, 26 Nov 2019 15:02:51
38 * Allow rmid files be opened by native midi
39 Vitaly Novichkov - Tue Nov 26 14:37:25 2019
40 * Fixed possible crash in win32 native midi
41 Vitaly Novichkov - Mon Nov 18 17:10:20 2019
42 * Prevent clipping due to volume settings in modplug music
43 Michael Day - Mon Nov 18 07:43:52 2019
44 * Fixed FLAC initial stutter
45 Michael Day - Sat Nov 16 22:11:29 PST 2019
46 * Added looping support for FLAC files
47 Michael Day - Fri Nov 01 10:38:35 2019
48 * Improved OGG looping support
49 Sam Lantinga - Fri Oct 04 18:00:42 2019
50 * Fixed loading Opus audio as audio chunks
51 Sylvain Becker - Wed Aug 21 09:30:22 2019
52 * Fixed Mix_FadeOutChannel() never setting fade_volume_reset
53 Ioan Chera - Sat Mar 30 14:07:03 2019
54 * Fixed memory leak in macOS native midi code
55
056 2.0.4:
157 Ozkan Sezer - Wed, 10 Oct 2018 14:56:10
258 * Removed smpeg support for mp3 music, now that it's replaced by libmpg123
0 cmake_minimum_required(VERSION 3.1.0)
1 project(SDL2_mixer C)
2
3 # FIXME: CMAKE SUPPORT IN SDL2_mixer IS VERY INCOMPLETE YET !!!
4 #
5 # FIXME: make it able build against system codec libraries, too.
6 # FIXME: handle library versioning.
7 # FIXME: test accross different target platforms.
8 #
9 # FIXME: missing CMakeLists.txt for MPG123
10 set(SUPPORT_MP3_MPG123 OFF CACHE BOOL "" FORCE)
11
12 option(SUPPORT_WAV "Support loading WAVE music" ON)
13 option(SUPPORT_FLAC "Support loading FLAC music with libFLAC" OFF)
14 option(SUPPORT_OGG "Support loading OGG Vorbis music via Tremor" OFF)
15 option(SUPPORT_MP3_MPG123 "Support loading MP3 music via MPG123" OFF)
16 option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF)
17 option(SUPPORT_MID_TIMIDITY "Support loading MIDI music via TiMidity" OFF)
18
19 option(BUILD_SHARED_LIBS "Enable shared library" ON)
20
21 if (NOT ANDROID AND NOT (TARGET SDL2 OR TARGET SDL2-static))
22 find_package(SDL2 REQUIRED)
23
24 if(NOT TARGET SDL2::SDL2)
25 # SDL < 2.0.12
26 add_library(SDL2::SDL2 INTERFACE IMPORTED)
27 set_target_properties(SDL2::SDL2 PROPERTIES
28 INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR}
29 INTERFACE_LINK_LIBRARIES ${SDL2_LIBRARIES} ${SDL2_LIBRARY}
30 )
31 endif()
32 endif()
33
34 include_directories(include src src/codecs)
35
36 add_library(SDL2_mixer)
37 add_library(SDL2::mixer ALIAS SDL2_mixer)
38
39 target_sources(SDL2_mixer PRIVATE
40 src/effect_position.c src/effects_internal.c src/effect_stereoreverse.c
41 src/mixer.c src/music.c src/utils.c
42 src/codecs/load_aiff.c src/codecs/load_voc.c
43 src/codecs/music_cmd.c
44 src/codecs/music_wav.c src/codecs/music_flac.c
45 src/codecs/music_mad.c src/codecs/music_mpg123.c
46 src/codecs/music_ogg.c src/codecs/music_opus.c
47 src/codecs/music_mikmod.c src/codecs/music_modplug.c
48 src/codecs/music_xmp.c
49 src/codecs/music_fluidsynth.c src/codecs/music_timidity.c
50 src/codecs/music_nativemidi.c)
51
52 if (SUPPORT_WAV)
53 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_WAV)
54 endif()
55
56 if (SUPPORT_FLAC)
57 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_FLAC)
58 add_subdirectory(external/flac-1.3.3)
59 target_include_directories(SDL2_mixer PRIVATE external/flac-1.3.3/include)
60 target_link_libraries(SDL2_mixer PRIVATE FLAC)
61 endif()
62
63 if (SUPPORT_OGG)
64 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_OGG -DOGG_USE_TREMOR -DOGG_HEADER=<ivorbisfile.h>)
65 add_subdirectory(external/libogg-1.3.2)
66 add_subdirectory(external/libvorbisidec-1.2.1)
67 target_include_directories(SDL2_mixer PRIVATE external/libvorbisidec-1.2.1)
68 target_link_libraries(SDL2_mixer PRIVATE vorbisidec ogg)
69 endif()
70
71 if (SUPPORT_MP3_MPG123)
72 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MP3_MPG123)
73 add_subdirectory(external/mpg123-1.25.13)
74 target_link_libraries(SDL2_mixer PRIVATE mpg123)
75 endif()
76
77 if (SUPPORT_MOD_MODPLUG)
78 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MOD_MODPLUG -DMODPLUG_HEADER=<modplug.h>)
79 add_subdirectory(external/libmodplug-0.8.9.0)
80 target_include_directories(SDL2_mixer PRIVATE external/libmodplug-0.8.9.0/src)
81 target_link_libraries(SDL2_mixer PRIVATE modplug)
82 endif()
83
84 if (SUPPORT_MID_TIMIDITY)
85 target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MID_TIMIDITY)
86 add_subdirectory(src/codecs/timidity)
87 target_link_libraries(SDL2_mixer PRIVATE timidity)
88 endif()
89
90 if(WIN32 AND BUILD_SHARED_LIBS)
91 target_compile_definitions(SDL2_mixer PRIVATE -DDLL_EXPORT)
92 endif()
93
94 target_include_directories(SDL2_mixer PUBLIC include)
95 target_link_libraries(SDL2_mixer PRIVATE SDL2::SDL2)
+0
-20
COPYING.txt less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
0 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
1
2 This software is provided 'as-is', without any express or implied
3 warranty. In no event will the authors be held liable for any damages
4 arising from the use of this software.
5
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it
8 freely, subject to the following restrictions:
9
10 1. The origin of this software must not be misrepresented; you must not
11 claim that you wrote the original software. If you use this software
12 in a product, an acknowledgment in the product documentation would be
13 appreciated but is not required.
14 2. Altered source versions must be plainly marked as such, and must not be
15 misrepresented as being the original software.
16 3. This notice may not be removed or altered from any source distribution.
2727 INSTALL = @INSTALL@
2828 AR = @AR@
2929 RANLIB = @RANLIB@
30 WINDRES = @WINDRES@
30 RC = @RC@
3131 SDL_CFLAGS = @SDL_CFLAGS@
3232 SDL_LIBS = @SDL_LIBS@
3333
3737 PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@
3838 PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@
3939
40 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
40 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
41 GEN_DIST = SDL2_mixer.spec
4142
4243 LT_AGE = @LT_AGE@
4344 LT_CURRENT = @LT_CURRENT@
4445 LT_RELEASE = @LT_RELEASE@
4546 LT_REVISION = @LT_REVISION@
46 LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
47 LT_EXTRA = @LT_EXTRA@
48 LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LT_EXTRA)
4749
48 all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE)
50 all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE)
4951
50 $(srcdir)/configure: $(srcdir)/configure.in
51 @echo "Warning, configure.in is out of date"
52 #(cd $(srcdir) && sh autogen.sh && sh configure)
53 @sleep 3
52 $(srcdir)/configure: $(srcdir)/configure.ac
53 @echo "Warning, configure is out of date, please re-run autogen.sh"
5454
5555 Makefile: $(srcdir)/Makefile.in
5656 $(SHELL) config.status $@
5757
58 $(objects):
59 $(SHELL) $(auxdir)/mkinstalldirs $@
58 $(objects)/.created:
59 $(SHELL) $(auxdir)/mkinstalldirs $(objects)
60 touch $@
6061
6162 .PHONY: all install install-hdrs install-lib install-bin uninstall uninstall-hdrs uninstall-lib uninstall-bin clean distclean dist
6263
7273 install: all install-hdrs install-lib #install-bin
7374 install-hdrs:
7475 $(SHELL) $(auxdir)/mkinstalldirs $(includedir)/SDL2
75 for src in $(srcdir)/SDL_mixer.h; do \
76 for src in $(srcdir)/include/SDL_mixer.h; do \
7677 file=`echo $$src | sed -e 's|^.*/||'`; \
7778 $(INSTALL) -m 644 $$src $(includedir)/SDL2/$$file; \
7879 done
8889
8990 uninstall: uninstall-hdrs uninstall-lib uninstall-bin
9091 uninstall-hdrs:
91 for src in $(srcdir)/SDL_mixer.h; do \
92 for src in $(srcdir)/include/SDL_mixer.h; do \
9293 file=`echo $$src | sed -e 's|^.*/||'`; \
9394 rm -f $(includedir)/SDL2/$$file; \
9495 done
120121
121122 dist $(distfile):
122123 $(SHELL) $(auxdir)/mkinstalldirs $(distdir)
123 (cd $(srcdir); tar cf - $(DIST)) | (cd $(distdir); tar xf -)
124 (cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -)
125 tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -)
124126 rm -rf `find $(distdir) -name .svn`
125127 rm -f `find $(distdir) -name '.#*'`
126128 tar cvf - $(distdir) | gzip --best >$(distfile)
0 # Open Watcom makefile to build SDL2mix.dll for OS/2
1 # wmake -f Makefile.os2
2 #
3 # Remember to edit DEPS_INC and DEPS_LIB below to meet
4 # your own environment!.
5
6 LIBNAME = SDL2mix
7 VERSION = 2.0.4
8
9 TITLENAME = $(LIBNAME) $(VERSION)
10
11 # change DEPS_INC in order to point to the dependency headers.
12 DEPS_INC=-IC:\SDL2DEV\h\SDL2 -IC:\SDL2DEV\h
13 # change DEPS_LIB in order to point to the dependency libraries.
14 DEPS_LIB=C:\SDL2DEV\lib
15
16 # wav music support
17 USE_WAV=yes
18 # ogg/vorbis music support
19 USE_OGG=yes
20 # use integer-only Tremor (libvorbisidec) instead of libvorbis?
21 USE_TREMOR=no
22 # flac music support
23 USE_FLAC=yes
24 # opus music support
25 USE_OPUS=yes
26 # mp3 music support (using libmad)
27 USE_LIBMAD=no
28 # mp3 music support (using mpg123)
29 USE_MPG123=yes
30 # midi music support (using timidity)
31 USE_TIMIDITY=yes
32 # midi music support (using fluidsynth)
33 USE_FLUIDSYNTH=no
34 # tracker music support (using libmikmod)
35 USE_MIKMOD=no
36 # tracker music support (using libxmp)
37 USE_XMP=yes
38 # tracker music support (using libmodplug)
39 USE_MODPLUG=no
40
41 LIBFILE = $(LIBNAME).lib
42 DLLFILE = $(LIBNAME).dll
43 LNKFILE = $(LIBNAME).lnk
44 TIMILIB = timidity.lib
45
46 SRCS = utils.c effect_position.c effects_internal.c effect_stereoreverse.c mixer.c music.c
47 # codec sources:
48 SRCS+= load_aiff.c load_voc.c music_wav.c &
49 mp3utils.c music_mad.c music_mpg123.c &
50 music_ogg.c music_opus.c music_flac.c &
51 music_xmp.c music_mikmod.c music_modplug.c &
52 music_fluidsynth.c music_timidity.c
53 # timidity sources:
54 TIMISRCS = common.c instrum.c mix.c output.c playmidi.c readmidi.c resample.c tables.c timidity.c
55
56 OBJS = $(SRCS:.c=.obj)
57 TIMIOBJS = $(TIMISRCS:.c=.obj)
58
59 LIBS = SDL2.lib
60
61 CFLAGS_BASE = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei -j
62 # warnings:
63 CFLAGS_BASE+= -wx
64 # include paths:
65 CFLAGS_BASE+= -Iinclude -Isrc -I"src/codecs" -I"src/codecs/timidity" $(DEPS_INC)
66 CFLAGS_BASE+= -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
67 CFLAGS = $(CFLAGS_BASE)
68 # to build a dll:
69 CFLAGS+= -bd
70 # for DECLSPEC:
71 CFLAGS+= -DBUILD_SDL
72
73 !ifeq USE_TIMIDITY yes
74 CFLAGS+= -DMUSIC_MID_TIMIDITY
75 LIBS+= $(TIMILIB)
76 !endif
77 !ifeq USE_FLUIDSYNTH yes
78 CFLAGS+= -DMUSIC_MID_FLUIDSYNTH
79 LIBS+= fluidsyn.lib
80 !endif
81
82 !ifeq USE_WAV yes
83 CFLAGS+= -DMUSIC_WAV
84 !endif
85
86 !ifeq USE_TREMOR yes
87 VORBIS_LIBS=vorbisidec.lib
88 !else
89 VORBIS_LIBS=vorbisfile.lib vorbis.lib
90 !endif
91 !ifeq USE_OGG yes
92 CFLAGS+= -DMUSIC_OGG
93 !ifeq USE_TREMOR yes
94 CFLAGS+= -DOGG_USE_TREMOR
95 !endif
96 LIBS+= $(VORBIS_LIBS)
97 LIBS+= ogg.lib
98 !endif
99
100 !ifeq USE_FLAC yes
101 CFLAGS+= -DMUSIC_FLAC
102 LIBS+= FLAC.lib
103 !endif
104
105 !ifeq USE_OPUS yes
106 CFLAGS+= -DMUSIC_OPUS
107 LIBS+= opusfile.lib opus.lib
108 !ifneq USE_OGG yes
109 LIBS+= ogg.lib
110 !endif
111 !endif
112
113 !ifeq USE_LIBMAD yes
114 CFLAGS+= -DMUSIC_MP3_MAD
115 LIBS+= mad.lib
116 !endif
117 !ifeq USE_MPG123 yes
118 CFLAGS+= -DMUSIC_MP3_MPG123
119 LIBS+= mpg123.lib
120 !endif
121
122 !ifeq USE_XMP yes
123 CFLAGS+= -DMUSIC_MOD_XMP
124 LIBS+= libxmp.lib
125 !endif
126 !ifeq USE_MIKMOD yes
127 CFLAGS+= -DMUSIC_MOD_MIKMOD
128 LIBS+= mikmod.lib
129 !endif
130 !ifeq USE_MODPLUG yes
131 CFLAGS+= -DMUSIC_MOD_MODPLUG
132 LIBS+= modplug.lib
133 !endif
134
135 all: $(DLLFILE) playwave.exe playmus.exe
136
137 $(LIBFILE): $(DLLFILE)
138 @echo * Create library: $@...
139 wlib -b -n -q -c -pa -s -t -zld -ii -io $@ $(DLLFILE)
140
141 $(DLLFILE): $(OBJS) $(TIMILIB) $(LNKFILE)
142 @echo * Link: $@
143 wlink @$(LNKFILE)
144
145 $(LNKFILE):
146 @%create $@
147 @%append $@ SYSTEM os2v2_dll INITINSTANCE TERMINSTANCE
148 @%append $@ NAME $(LIBNAME)
149 @for %i in ($(OBJS)) do @%append $@ FILE %i
150 @%append $@ OPTION QUIET
151 @%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@Simple DirectMedia Layer Mixer'
152 @%append $@ LIBPATH $(DEPS_LIB)
153 @for %i in ($(LIBS)) do @%append $@ LIB %i
154 @%append $@ OPTION MAP=$*
155 @%append $@ OPTION ELIMINATE
156 @%append $@ OPTION MANYAUTODATA
157 @%append $@ OPTION OSNAME='OS/2 and eComStation'
158 @%append $@ OPTION SHOWDEAD
159
160 .c: ./src;./src/codecs;
161
162 .c.obj:
163 wcc386 $(CFLAGS) -fo=$^@ $<
164
165 playmus.obj: playmus.c
166 wcc386 $(CFLAGS_BASE) -fo=$^@ $<
167
168 playwave.obj: playwave.c
169 wcc386 $(CFLAGS_BASE) -fo=$^@ $<
170
171 playmus.exe: $(LIBFILE) playmus.obj
172 wlink SYS os2v2 OP q LIBPATH $(DEPS_LIB) LIBR {$(LIBFILE) SDL2.lib} F {playmus.obj} N playmus.exe
173
174 playwave.exe: $(LIBFILE) playwave.obj
175 wlink SYS os2v2 OP q LIBPATH $(DEPS_LIB) LIBR {$(LIBFILE) SDL2.lib} F {playwave.obj} N playwave.exe
176
177 .c: ./src/codecs/timidity;
178 timidity.lib: $(TIMIOBJS)
179 wlib -b -n -q -c -pa -s -t -zld -ii -io $@ $(TIMIOBJS)
180
181 clean: .SYMBOLIC
182 @echo * Clean: $(TITLENAME)
183 @if exist *.obj rm *.obj
184 @if exist *.err rm *.err
185 @if exist $(TIMILIB) rm $(TIMILIB)
186 @if exist $(LNKFILE) rm $(LNKFILE)
187 distclean: .SYMBOLIC clean
188 @if exist $(DLLFILE) rm $(DLLFILE)
189 @if exist $(LIBFILE) rm $(LIBFILE)
190 @if exist *.map rm *.map
191 @if exist *.exe rm *.exe
4949 and SDL_mixer directories to your "Header Search Paths" setting, then add the
5050 libSDL2.a and libSDL2_mixer.a to your "Link Binary with Libraries" setting.
5151
52 This library is under the zlib license, see the file "COPYING.txt" for details.
52 This library is under the zlib license, see the file "LICENSE.txt" for details.
5353
0 %define name SDL2_mixer
1 %define version 2.0.4
2 %define release 1
3
4 Summary: Simple DirectMedia Layer - Sample Mixer Library
5 Name: %{name}
6 Version: %{version}
7 Release: %{release}
8 Source0: %{name}-%{version}.tar.gz
9 License: LGPL
10 Group: System Environment/Libraries
11 BuildRoot: /var/tmp/%{name}-buildroot
12 Prefix: %{_prefix}
13
14 %description
15 Due to popular demand, here is a simple multi-channel audio mixer.
16 It supports 4 channels of 16 bit stereo audio, plus a single channel
17 of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis,
18 Tremor, libmpg123 and libmad MP3 libraries.
19
20 %package devel
21 Summary: Libraries, includes and more to develop SDL applications.
22 Group: Development/Libraries
23 Requires: %{name}
24
25 %description devel
26 Due to popular demand, here is a simple multi-channel audio mixer.
27 It supports 4 channels of 16 bit stereo audio, plus a single channel
28 of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis,
29 Tremor, libmpg123 and libmad MP3 libraries.
30
31 %prep
32 %setup
33
34 %build
35 CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix}
36 make
37
38 %install
39 rm -rf $RPM_BUILD_ROOT
40 make install prefix=$RPM_BUILD_ROOT/%{prefix}
41
42 %clean
43 rm -rf $RPM_BUILD_ROOT
44
45 %files
46 %defattr(-,root,root)
47 %doc README.txt CHANGES.txt LICENSE.txt
48 %{prefix}/lib/lib*.so.*
49
50 %files devel
51 %defattr(-,root,root)
52 %{prefix}/lib/lib*.a
53 %{prefix}/lib/lib*.la
54 %{prefix}/lib/lib*.so
55 %{prefix}/include/*/
56 %{prefix}/lib/pkgconfig/*.pc
57
58 %changelog
59 * Wed Jan 19 2000 Sam Lantinga
60 - converted to get package information from configure
61 * Sun Jan 16 2000 Hakan Tandogan <hakan@iconsult.com>
62 - initial spec file
63
2929 Tremor, libmpg123 and libmad MP3 libraries.
3030
3131 %prep
32 %setup
32 %setup
3333
3434 %build
3535 CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix}
4444
4545 %files
4646 %defattr(-,root,root)
47 %doc README.txt CHANGES.txt COPYING.txt
47 %doc README.txt CHANGES.txt LICENSE.txt
4848 %{prefix}/lib/lib*.so.*
4949
5050 %files devel
5656 %{prefix}/lib/pkgconfig/*.pc
5757
5858 %changelog
59 * Wed Jan 19 2000 Sam Lantinga
59 * Wed Jan 19 2000 Sam Lantinga
6060 - converted to get package information from configure
6161 * Sun Jan 16 2000 Hakan Tandogan <hakan@iconsult.com>
6262 - initial spec file
+0
-651
SDL_mixer.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef SDL_MIXER_H_
22 #define SDL_MIXER_H_
23
24 #include "SDL_stdinc.h"
25 #include "SDL_rwops.h"
26 #include "SDL_audio.h"
27 #include "SDL_endian.h"
28 #include "SDL_version.h"
29 #include "begin_code.h"
30
31 /* Set up for C function definitions, even when using C++ */
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
37 */
38 #define SDL_MIXER_MAJOR_VERSION 2
39 #define SDL_MIXER_MINOR_VERSION 0
40 #define SDL_MIXER_PATCHLEVEL 4
41
42 /* This macro can be used to fill a version structure with the compile-time
43 * version of the SDL_mixer library.
44 */
45 #define SDL_MIXER_VERSION(X) \
46 { \
47 (X)->major = SDL_MIXER_MAJOR_VERSION; \
48 (X)->minor = SDL_MIXER_MINOR_VERSION; \
49 (X)->patch = SDL_MIXER_PATCHLEVEL; \
50 }
51
52 /* Backwards compatibility */
53 #define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION
54 #define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION
55 #define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL
56 #define MIX_VERSION(X) SDL_MIXER_VERSION(X)
57
58 /**
59 * This is the version number macro for the current SDL_mixer version.
60 */
61 #define SDL_MIXER_COMPILEDVERSION \
62 SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
63
64 /**
65 * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
66 */
67 #define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
68 (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
69
70 /* This function gets the version of the dynamically linked SDL_mixer library.
71 it should NOT be used to fill a version structure, instead you should
72 use the SDL_MIXER_VERSION() macro.
73 */
74 extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
75
76 typedef enum
77 {
78 MIX_INIT_FLAC = 0x00000001,
79 MIX_INIT_MOD = 0x00000002,
80 MIX_INIT_MP3 = 0x00000008,
81 MIX_INIT_OGG = 0x00000010,
82 MIX_INIT_MID = 0x00000020,
83 MIX_INIT_OPUS = 0x00000040
84 } MIX_InitFlags;
85
86 /* Loads dynamic libraries and prepares them for use. Flags should be
87 one or more flags from MIX_InitFlags OR'd together.
88 It returns the flags successfully initialized, or 0 on failure.
89 */
90 extern DECLSPEC int SDLCALL Mix_Init(int flags);
91
92 /* Unloads libraries loaded with Mix_Init */
93 extern DECLSPEC void SDLCALL Mix_Quit(void);
94
95
96 /* The default mixer has 8 simultaneous mixing channels */
97 #ifndef MIX_CHANNELS
98 #define MIX_CHANNELS 8
99 #endif
100
101 /* Good default values for a PC soundcard */
102 #define MIX_DEFAULT_FREQUENCY 22050
103 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
104 #define MIX_DEFAULT_FORMAT AUDIO_S16LSB
105 #else
106 #define MIX_DEFAULT_FORMAT AUDIO_S16MSB
107 #endif
108 #define MIX_DEFAULT_CHANNELS 2
109 #define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */
110
111 /* The internal format for an audio chunk */
112 typedef struct Mix_Chunk {
113 int allocated;
114 Uint8 *abuf;
115 Uint32 alen;
116 Uint8 volume; /* Per-sample volume, 0-128 */
117 } Mix_Chunk;
118
119 /* The different fading types supported */
120 typedef enum {
121 MIX_NO_FADING,
122 MIX_FADING_OUT,
123 MIX_FADING_IN
124 } Mix_Fading;
125
126 /* These are types of music files (not libraries used to load them) */
127 typedef enum {
128 MUS_NONE,
129 MUS_CMD,
130 MUS_WAV,
131 MUS_MOD,
132 MUS_MID,
133 MUS_OGG,
134 MUS_MP3,
135 MUS_MP3_MAD_UNUSED,
136 MUS_FLAC,
137 MUS_MODPLUG_UNUSED,
138 MUS_OPUS
139 } Mix_MusicType;
140
141 /* The internal format for a music chunk interpreted via mikmod */
142 typedef struct _Mix_Music Mix_Music;
143
144 /* Open the mixer with a certain audio format */
145 extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
146
147 /* Open the mixer with specific device and certain audio format */
148 extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
149
150 /* Dynamically change the number of channels managed by the mixer.
151 If decreasing the number of channels, the upper channels are
152 stopped.
153 This function returns the new number of allocated channels.
154 */
155 extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
156
157 /* Find out what the actual audio device parameters are.
158 This function returns 1 if the audio has been opened, 0 otherwise.
159 */
160 extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
161
162 /* Load a wave file or a music (.mod .s3m .it .xm) file */
163 extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
164 #define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
165 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
166
167 /* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
168 Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
169 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
170
171 /* Load a music file from an SDL_RWop object assuming a specific format */
172 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
173
174 /* Load a wave file of the mixer format from a memory buffer */
175 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
176
177 /* Load raw audio data of the mixer format from a memory buffer */
178 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
179
180 /* Free an audio chunk previously loaded */
181 extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
182 extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
183
184 /* Get a list of chunk/music decoders that this build of SDL_mixer provides.
185 This list can change between builds AND runs of the program, if external
186 libraries that add functionality become available.
187 You must successfully call Mix_OpenAudio() before calling these functions.
188 This API is only available in SDL_mixer 1.2.9 and later.
189
190 // usage...
191 int i;
192 const int total = Mix_GetNumChunkDecoders();
193 for (i = 0; i < total; i++)
194 printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
195
196 Appearing in this list doesn't promise your specific audio file will
197 decode...but it's handy to know if you have, say, a functioning Timidity
198 install.
199
200 These return values are static, read-only data; do not modify or free it.
201 The pointers remain valid until you call Mix_CloseAudio().
202 */
203 extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
204 extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
205 extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
206 extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
207 extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
208 extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
209
210 /* Find out the music format of a mixer music, or the currently playing
211 music, if 'music' is NULL.
212 */
213 extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
214
215 /* Set a function that is called after all mixing is performed.
216 This can be used to provide real-time visual display of the audio stream
217 or add a custom mixer filter for the stream data.
218 */
219 extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
220
221 /* Add your own music player or additional mixer function.
222 If 'mix_func' is NULL, the default music player is re-enabled.
223 */
224 extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
225
226 /* Add your own callback for when the music has finished playing or when it is
227 * stopped from a call to Mix_HaltMusic.
228 */
229 extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void));
230
231 /* Get a pointer to the user data for the current music hook */
232 extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
233
234 /*
235 * Add your own callback when a channel has finished playing. NULL
236 * to disable callback. The callback may be called from the mixer's audio
237 * callback or it could be called as a result of Mix_HaltChannel(), etc.
238 * do not call SDL_LockAudio() from this callback; you will either be
239 * inside the audio callback, or SDL_mixer will explicitly lock the audio
240 * before calling your callback.
241 */
242 extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel));
243
244
245 /* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
246
247 #define MIX_CHANNEL_POST -2
248
249 /* This is the format of a special effect callback:
250 *
251 * myeffect(int chan, void *stream, int len, void *udata);
252 *
253 * (chan) is the channel number that your effect is affecting. (stream) is
254 * the buffer of data to work upon. (len) is the size of (stream), and
255 * (udata) is a user-defined bit of data, which you pass as the last arg of
256 * Mix_RegisterEffect(), and is passed back unmolested to your callback.
257 * Your effect changes the contents of (stream) based on whatever parameters
258 * are significant, or just leaves it be, if you prefer. You can do whatever
259 * you like to the buffer, though, and it will continue in its changed state
260 * down the mixing pipeline, through any other effect functions, then finally
261 * to be mixed with the rest of the channels and music for the final output
262 * stream.
263 *
264 * DO NOT EVER call SDL_LockAudio() from your callback function!
265 */
266 typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
267
268 /*
269 * This is a callback that signifies that a channel has finished all its
270 * loops and has completed playback. This gets called if the buffer
271 * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
272 * a channel via Mix_AllocateChannels(), or unregister a callback while
273 * it's still playing.
274 *
275 * DO NOT EVER call SDL_LockAudio() from your callback function!
276 */
277 typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
278
279
280 /* Register a special effect function. At mixing time, the channel data is
281 * copied into a buffer and passed through each registered effect function.
282 * After it passes through all the functions, it is mixed into the final
283 * output stream. The copy to buffer is performed once, then each effect
284 * function performs on the output of the previous effect. Understand that
285 * this extra copy to a buffer is not performed if there are no effects
286 * registered for a given chunk, which saves CPU cycles, and any given
287 * effect will be extra cycles, too, so it is crucial that your code run
288 * fast. Also note that the data that your function is given is in the
289 * format of the sound device, and not the format you gave to Mix_OpenAudio(),
290 * although they may in reality be the same. This is an unfortunate but
291 * necessary speed concern. Use Mix_QuerySpec() to determine if you can
292 * handle the data before you register your effect, and take appropriate
293 * actions.
294 * You may also specify a callback (Mix_EffectDone_t) that is called when
295 * the channel finishes playing. This gives you a more fine-grained control
296 * than Mix_ChannelFinished(), in case you need to free effect-specific
297 * resources, etc. If you don't need this, you can specify NULL.
298 * You may set the callbacks before or after calling Mix_PlayChannel().
299 * Things like Mix_SetPanning() are just internal special effect functions,
300 * so if you are using that, you've already incurred the overhead of a copy
301 * to a separate buffer, and that these effects will be in the queue with
302 * any functions you've registered. The list of registered effects for a
303 * channel is reset when a chunk finishes playing, so you need to explicitly
304 * set them with each call to Mix_PlayChannel*().
305 * You may also register a special effect function that is to be run after
306 * final mixing occurs. The rules for these callbacks are identical to those
307 * in Mix_RegisterEffect, but they are run after all the channels and the
308 * music have been mixed into a single stream, whereas channel-specific
309 * effects run on a given channel before any other mixing occurs. These
310 * global effect callbacks are call "posteffects". Posteffects only have
311 * their Mix_EffectDone_t function called when they are unregistered (since
312 * the main output stream is never "done" in the same sense as a channel).
313 * You must unregister them manually when you've had enough. Your callback
314 * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
315 * processing is considered a posteffect.
316 *
317 * After all these effects have finished processing, the callback registered
318 * through Mix_SetPostMix() runs, and then the stream goes to the audio
319 * device.
320 *
321 * DO NOT EVER call SDL_LockAudio() from your callback function!
322 *
323 * returns zero if error (no such channel), nonzero if added.
324 * Error messages can be retrieved from Mix_GetError().
325 */
326 extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
327
328
329 /* You may not need to call this explicitly, unless you need to stop an
330 * effect from processing in the middle of a chunk's playback.
331 * Posteffects are never implicitly unregistered as they are for channels,
332 * but they may be explicitly unregistered through this function by
333 * specifying MIX_CHANNEL_POST for a channel.
334 * returns zero if error (no such channel or effect), nonzero if removed.
335 * Error messages can be retrieved from Mix_GetError().
336 */
337 extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
338
339
340 /* You may not need to call this explicitly, unless you need to stop all
341 * effects from processing in the middle of a chunk's playback. Note that
342 * this will also shut off some internal effect processing, since
343 * Mix_SetPanning() and others may use this API under the hood. This is
344 * called internally when a channel completes playback.
345 * Posteffects are never implicitly unregistered as they are for channels,
346 * but they may be explicitly unregistered through this function by
347 * specifying MIX_CHANNEL_POST for a channel.
348 * returns zero if error (no such channel), nonzero if all effects removed.
349 * Error messages can be retrieved from Mix_GetError().
350 */
351 extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
352
353
354 #define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"
355
356 /*
357 * These are the internally-defined mixing effects. They use the same API that
358 * effects defined in the application use, but are provided here as a
359 * convenience. Some effects can reduce their quality or use more memory in
360 * the name of speed; to enable this, make sure the environment variable
361 * MIX_EFFECTSMAXSPEED (see above) is defined before you call
362 * Mix_OpenAudio().
363 */
364
365
366 /* Set the panning of a channel. The left and right channels are specified
367 * as integers between 0 and 255, quietest to loudest, respectively.
368 *
369 * Technically, this is just individual volume control for a sample with
370 * two (stereo) channels, so it can be used for more than just panning.
371 * If you want real panning, call it like this:
372 *
373 * Mix_SetPanning(channel, left, 255 - left);
374 *
375 * ...which isn't so hard.
376 *
377 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
378 * the panning will be done to the final mixed stream before passing it on
379 * to the audio device.
380 *
381 * This uses the Mix_RegisterEffect() API internally, and returns without
382 * registering the effect function if the audio device is not configured
383 * for stereo output. Setting both (left) and (right) to 255 causes this
384 * effect to be unregistered, since that is the data's normal state.
385 *
386 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
387 * nonzero if panning effect enabled. Note that an audio device in mono
388 * mode is a no-op, but this call will return successful in that case.
389 * Error messages can be retrieved from Mix_GetError().
390 */
391 extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
392
393
394 /* Set the position of a channel. (angle) is an integer from 0 to 360, that
395 * specifies the location of the sound in relation to the listener. (angle)
396 * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
397 * Angle 0 is due north, and rotates clockwise as the value increases.
398 * For efficiency, the precision of this effect may be limited (angles 1
399 * through 7 might all produce the same effect, 8 through 15 are equal, etc).
400 * (distance) is an integer between 0 and 255 that specifies the space
401 * between the sound and the listener. The larger the number, the further
402 * away the sound is. Using 255 does not guarantee that the channel will be
403 * culled from the mixing process or be completely silent. For efficiency,
404 * the precision of this effect may be limited (distance 0 through 5 might
405 * all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
406 * and (distance) to 0 unregisters this effect, since the data would be
407 * unchanged.
408 *
409 * If you need more precise positional audio, consider using OpenAL for
410 * spatialized effects instead of SDL_mixer. This is only meant to be a
411 * basic effect for simple "3D" games.
412 *
413 * If the audio device is configured for mono output, then you won't get
414 * any effectiveness from the angle; however, distance attenuation on the
415 * channel will still occur. While this effect will function with stereo
416 * voices, it makes more sense to use voices with only one channel of sound,
417 * so when they are mixed through this effect, the positioning will sound
418 * correct. You can convert them to mono through SDL before giving them to
419 * the mixer in the first place if you like.
420 *
421 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
422 * the positioning will be done to the final mixed stream before passing it
423 * on to the audio device.
424 *
425 * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
426 *
427 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
428 * nonzero if position effect is enabled.
429 * Error messages can be retrieved from Mix_GetError().
430 */
431 extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
432
433
434 /* Set the "distance" of a channel. (distance) is an integer from 0 to 255
435 * that specifies the location of the sound in relation to the listener.
436 * Distance 0 is overlapping the listener, and 255 is as far away as possible
437 * A distance of 255 does not guarantee silence; in such a case, you might
438 * want to try changing the chunk's volume, or just cull the sample from the
439 * mixing process with Mix_HaltChannel().
440 * For efficiency, the precision of this effect may be limited (distances 1
441 * through 7 might all produce the same effect, 8 through 15 are equal, etc).
442 * (distance) is an integer between 0 and 255 that specifies the space
443 * between the sound and the listener. The larger the number, the further
444 * away the sound is.
445 * Setting (distance) to 0 unregisters this effect, since the data would be
446 * unchanged.
447 * If you need more precise positional audio, consider using OpenAL for
448 * spatialized effects instead of SDL_mixer. This is only meant to be a
449 * basic effect for simple "3D" games.
450 *
451 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
452 * the distance attenuation will be done to the final mixed stream before
453 * passing it on to the audio device.
454 *
455 * This uses the Mix_RegisterEffect() API internally.
456 *
457 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
458 * nonzero if position effect is enabled.
459 * Error messages can be retrieved from Mix_GetError().
460 */
461 extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
462
463
464 /*
465 * !!! FIXME : Haven't implemented, since the effect goes past the
466 * end of the sound buffer. Will have to think about this.
467 * --ryan.
468 */
469 #if 0
470 /* Causes an echo effect to be mixed into a sound. (echo) is the amount
471 * of echo to mix. 0 is no echo, 255 is infinite (and probably not
472 * what you want).
473 *
474 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
475 * the reverbing will be done to the final mixed stream before passing it on
476 * to the audio device.
477 *
478 * This uses the Mix_RegisterEffect() API internally. If you specify an echo
479 * of zero, the effect is unregistered, as the data is already in that state.
480 *
481 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
482 * nonzero if reversing effect is enabled.
483 * Error messages can be retrieved from Mix_GetError().
484 */
485 extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
486 #endif
487
488 /* Causes a channel to reverse its stereo. This is handy if the user has his
489 * speakers hooked up backwards, or you would like to have a minor bit of
490 * psychedelia in your sound code. :) Calling this function with (flip)
491 * set to non-zero reverses the chunks's usual channels. If (flip) is zero,
492 * the effect is unregistered.
493 *
494 * This uses the Mix_RegisterEffect() API internally, and thus is probably
495 * more CPU intensive than having the user just plug in his speakers
496 * correctly. Mix_SetReverseStereo() returns without registering the effect
497 * function if the audio device is not configured for stereo output.
498 *
499 * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
500 * on the final mixed stream before sending it on to the audio device (a
501 * posteffect).
502 *
503 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
504 * nonzero if reversing effect is enabled. Note that an audio device in mono
505 * mode is a no-op, but this call will return successful in that case.
506 * Error messages can be retrieved from Mix_GetError().
507 */
508 extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
509
510 /* end of effects API. --ryan. */
511
512
513 /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
514 them dynamically to the next sample if requested with a -1 value below.
515 Returns the number of reserved channels.
516 */
517 extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
518
519 /* Channel grouping functions */
520
521 /* Attach a tag to a channel. A tag can be assigned to several mixer
522 channels, to form groups of channels.
523 If 'tag' is -1, the tag is removed (actually -1 is the tag used to
524 represent the group of all the channels).
525 Returns true if everything was OK.
526 */
527 extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
528 /* Assign several consecutive channels to a group */
529 extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
530 /* Finds the first available channel in a group of channels,
531 returning -1 if none are available.
532 */
533 extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
534 /* Returns the number of channels in a group. This is also a subtle
535 way to get the total number of channels when 'tag' is -1
536 */
537 extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
538 /* Finds the "oldest" sample playing in a group of channels */
539 extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
540 /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
541 extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
542
543 /* Play an audio chunk on a specific channel.
544 If the specified channel is -1, play on the first free channel.
545 If 'loops' is greater than zero, loop the sound that many times.
546 If 'loops' is -1, loop inifinitely (~65000 times).
547 Returns which channel was used to play the sound.
548 */
549 #define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
550 /* The same as above, but the sound is played at most 'ticks' milliseconds */
551 extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
552 extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
553
554 /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
555 extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
556 extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
557 #define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
558 extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
559
560 /* Set the volume in the range of 0-128 of a specific channel or chunk.
561 If the specified channel is -1, set volume for all channels.
562 Returns the original volume.
563 If the specified volume is -1, just return the current volume.
564 */
565 extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
566 extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
567 extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
568
569 /* Halt playing of a particular channel */
570 extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
571 extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
572 extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
573
574 /* Change the expiration delay for a particular channel.
575 The sample will stop playing after the 'ticks' milliseconds have elapsed,
576 or remove the expiration if 'ticks' is -1
577 */
578 extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
579
580 /* Halt a channel, fading it out progressively till it's silent
581 The ms parameter indicates the number of milliseconds the fading
582 will take.
583 */
584 extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
585 extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
586 extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
587
588 /* Query the fading status of a channel */
589 extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
590 extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
591
592 /* Pause/Resume a particular channel */
593 extern DECLSPEC void SDLCALL Mix_Pause(int channel);
594 extern DECLSPEC void SDLCALL Mix_Resume(int channel);
595 extern DECLSPEC int SDLCALL Mix_Paused(int channel);
596
597 /* Pause/Resume the music stream */
598 extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
599 extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
600 extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
601 extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
602
603 /* Set the current position in the music stream.
604 This returns 0 if successful, or -1 if it failed or isn't implemented.
605 This function is only implemented for MOD music formats (set pattern
606 order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music
607 (set position in seconds), at the moment.
608 */
609 extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
610
611 /* Check the status of a specific channel.
612 If the specified channel is -1, check all channels.
613 */
614 extern DECLSPEC int SDLCALL Mix_Playing(int channel);
615 extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
616
617 /* Stop music and set external music playback command */
618 extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
619
620 /* Synchro value is set by MikMod from modules while playing */
621 extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
622 extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
623
624 /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
625 extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
626 extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
627 extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data);
628
629 /* Get the Mix_Chunk currently associated with a mixer channel
630 Returns NULL if it's an invalid channel, or there's no chunk associated.
631 */
632 extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
633
634 /* Close the mixer, halting all playing audio */
635 extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
636
637 /* We'll use SDL for reporting errors */
638 #define Mix_SetError SDL_SetError
639 #define Mix_GetError SDL_GetError
640 #define Mix_ClearError SDL_ClearError
641
642 /* Ends C function definitions when using C++ */
643 #ifdef __cplusplus
644 }
645 #endif
646 #include "close_code.h"
647
648 #endif /* SDL_MIXER_H_ */
649
650 /* vi: set ts=4 sw=4 expandtab: */
+0
-7373
acinclude/libtool.m4 less more
0 ##############################################################################
1 # Based on libtool-2.2.6a
2 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
3 #
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
5 # 2006, 2007, 2008 Free Software Foundation, Inc.
6 # Written by Gordon Matzigkeit, 1996
7 #
8 # This file is free software; the Free Software Foundation gives
9 # unlimited permission to copy and/or distribute it, with or without
10 # modifications, as long as this notice is preserved.
11
12 m4_define([_LT_COPYING], [dnl
13 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
14 # 2006, 2007, 2008 Free Software Foundation, Inc.
15 # Written by Gordon Matzigkeit, 1996
16 #
17 # This file is part of GNU Libtool.
18 #
19 # GNU Libtool is free software; you can redistribute it and/or
20 # modify it under the terms of the GNU General Public License as
21 # published by the Free Software Foundation; either version 2 of
22 # the License, or (at your option) any later version.
23 #
24 # As a special exception to the GNU General Public License,
25 # if you distribute this file as part of a program or library that
26 # is built using GNU Libtool, you may include this file under the
27 # same distribution terms that you use for the rest of that program.
28 #
29 # GNU Libtool is distributed in the hope that it will be useful,
30 # but WITHOUT ANY WARRANTY; without even the implied warranty of
31 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 # GNU General Public License for more details.
33 #
34 # You should have received a copy of the GNU General Public License
35 # along with GNU Libtool; see the file COPYING. If not, a copy
36 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
37 # obtained by writing to the Free Software Foundation, Inc.,
38 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39 ])
40
41 # serial 56 LT_INIT
42
43
44 # LT_PREREQ(VERSION)
45 # ------------------
46 # Complain and exit if this libtool version is less that VERSION.
47 m4_defun([LT_PREREQ],
48 [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
49 [m4_default([$3],
50 [m4_fatal([Libtool version $1 or higher is required],
51 63)])],
52 [$2])])
53
54
55 # _LT_CHECK_BUILDDIR
56 # ------------------
57 # Complain if the absolute build directory name contains unusual characters
58 m4_defun([_LT_CHECK_BUILDDIR],
59 [case `pwd` in
60 *\ * | *\ *)
61 AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
62 esac
63 ])
64
65
66 # LT_INIT([OPTIONS])
67 # ------------------
68 AC_DEFUN([LT_INIT],
69 [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
70 AC_BEFORE([$0], [LT_LANG])dnl
71 AC_BEFORE([$0], [LT_OUTPUT])dnl
72 AC_BEFORE([$0], [LTDL_INIT])dnl
73 m4_require([_LT_CHECK_BUILDDIR])dnl
74
75 dnl Autoconf doesn't catch unexpanded LT_ macros by default:
76 m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
77 m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
78 dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
79 dnl unless we require an AC_DEFUNed macro:
80 AC_REQUIRE([LTOPTIONS_VERSION])dnl
81 AC_REQUIRE([LTSUGAR_VERSION])dnl
82 AC_REQUIRE([LTVERSION_VERSION])dnl
83 AC_REQUIRE([LTOBSOLETE_VERSION])dnl
84 m4_require([_LT_PROG_LTMAIN])dnl
85
86 dnl Parse OPTIONS
87 _LT_SET_OPTIONS([$0], [$1])
88
89 # This can be used to rebuild libtool when needed
90 LIBTOOL_DEPS="$ltmain"
91
92 # Always use our own libtool.
93 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
94 AC_SUBST(LIBTOOL)dnl
95
96 _LT_SETUP
97
98 # Only expand once:
99 m4_define([LT_INIT])
100 ])# LT_INIT
101
102 # Old names:
103 AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
104 AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
105 dnl aclocal-1.4 backwards compatibility:
106 dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
107 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
108
109
110 # _LT_CC_BASENAME(CC)
111 # -------------------
112 # Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
113 m4_defun([_LT_CC_BASENAME],
114 [for cc_temp in $1""; do
115 case $cc_temp in
116 compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
117 distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
118 \-*) ;;
119 *) break;;
120 esac
121 done
122 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
123 ])
124
125
126 # _LT_FILEUTILS_DEFAULTS
127 # ----------------------
128 # It is okay to use these file commands and assume they have been set
129 # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
130 m4_defun([_LT_FILEUTILS_DEFAULTS],
131 [: ${CP="cp -f"}
132 : ${MV="mv -f"}
133 : ${RM="rm -f"}
134 ])# _LT_FILEUTILS_DEFAULTS
135
136
137 # _LT_SETUP
138 # ---------
139 m4_defun([_LT_SETUP],
140 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
141 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
142 _LT_DECL([], [host_alias], [0], [The host system])dnl
143 _LT_DECL([], [host], [0])dnl
144 _LT_DECL([], [host_os], [0])dnl
145 dnl
146 _LT_DECL([], [build_alias], [0], [The build system])dnl
147 _LT_DECL([], [build], [0])dnl
148 _LT_DECL([], [build_os], [0])dnl
149 dnl
150 AC_REQUIRE([AC_PROG_CC])dnl
151 AC_REQUIRE([LT_PATH_LD])dnl
152 AC_REQUIRE([LT_PATH_NM])dnl
153 dnl
154 AC_REQUIRE([AC_PROG_LN_S])dnl
155 test -z "$LN_S" && LN_S="ln -s"
156 _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
157 dnl
158 AC_REQUIRE([LT_CMD_MAX_LEN])dnl
159 _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
160 _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
161 dnl
162 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
163 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
164 m4_require([_LT_CMD_RELOAD])dnl
165 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
166 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
167 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
168
169 _LT_CONFIG_LIBTOOL_INIT([
170 # See if we are running on zsh, and set the options which allow our
171 # commands through without removal of \ escapes INIT.
172 if test -n "\${ZSH_VERSION+set}" ; then
173 setopt NO_GLOB_SUBST
174 fi
175 ])
176 if test -n "${ZSH_VERSION+set}" ; then
177 setopt NO_GLOB_SUBST
178 fi
179
180 _LT_CHECK_OBJDIR
181
182 m4_require([_LT_TAG_COMPILER])dnl
183 _LT_PROG_ECHO_BACKSLASH
184
185 case $host_os in
186 aix3*)
187 # AIX sometimes has problems with the GCC collect2 program. For some
188 # reason, if we set the COLLECT_NAMES environment variable, the problems
189 # vanish in a puff of smoke.
190 if test "X${COLLECT_NAMES+set}" != Xset; then
191 COLLECT_NAMES=
192 export COLLECT_NAMES
193 fi
194 ;;
195 esac
196
197 # Sed substitution that helps us do robust quoting. It backslashifies
198 # metacharacters that are still active within double-quoted strings.
199 sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
200
201 # Same as above, but do not quote variable references.
202 double_quote_subst='s/\([["`\\]]\)/\\\1/g'
203
204 # Sed substitution to delay expansion of an escaped shell variable in a
205 # double_quote_subst'ed string.
206 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
207
208 # Sed substitution to delay expansion of an escaped single quote.
209 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
210
211 # Sed substitution to avoid accidental globbing in evaled expressions
212 no_glob_subst='s/\*/\\\*/g'
213
214 # Global variables:
215 ofile=libtool
216 can_build_shared=yes
217
218 # All known linkers require a `.a' archive for static linking (except MSVC,
219 # which needs '.lib').
220 libext=a
221
222 with_gnu_ld="$lt_cv_prog_gnu_ld"
223
224 old_CC="$CC"
225 old_CFLAGS="$CFLAGS"
226
227 # Set sane defaults for various variables
228 test -z "$CC" && CC=cc
229 test -z "$LTCC" && LTCC=$CC
230 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
231 test -z "$LD" && LD=ld
232 test -z "$ac_objext" && ac_objext=o
233
234 _LT_CC_BASENAME([$compiler])
235
236 # Only perform the check for file, if the check method requires it
237 test -z "$MAGIC_CMD" && MAGIC_CMD=file
238 case $deplibs_check_method in
239 file_magic*)
240 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
241 _LT_PATH_MAGIC
242 fi
243 ;;
244 esac
245
246 # Use C for the default configuration in the libtool script
247 LT_SUPPORTED_TAG([CC])
248 _LT_LANG_C_CONFIG
249 _LT_LANG_DEFAULT_CONFIG
250 _LT_CONFIG_COMMANDS
251 ])# _LT_SETUP
252
253
254 # _LT_PROG_LTMAIN
255 # ---------------
256 # Note that this code is called both from `configure', and `config.status'
257 # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
258 # `config.status' has no value for ac_aux_dir unless we are using Automake,
259 # so we pass a copy along to make sure it has a sensible value anyway.
260 m4_defun([_LT_PROG_LTMAIN],
261 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
262 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
263 ltmain="$ac_aux_dir/ltmain.sh"
264 ])# _LT_PROG_LTMAIN
265
266
267 ## ------------------------------------- ##
268 ## Accumulate code for creating libtool. ##
269 ## ------------------------------------- ##
270
271 # So that we can recreate a full libtool script including additional
272 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
273 # in macros and then make a single call at the end using the `libtool'
274 # label.
275
276
277 # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
278 # ----------------------------------------
279 # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
280 m4_define([_LT_CONFIG_LIBTOOL_INIT],
281 [m4_ifval([$1],
282 [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
283 [$1
284 ])])])
285
286 # Initialize.
287 m4_define([_LT_OUTPUT_LIBTOOL_INIT])
288
289
290 # _LT_CONFIG_LIBTOOL([COMMANDS])
291 # ------------------------------
292 # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
293 m4_define([_LT_CONFIG_LIBTOOL],
294 [m4_ifval([$1],
295 [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
296 [$1
297 ])])])
298
299 # Initialize.
300 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
301
302
303 # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
304 # -----------------------------------------------------
305 m4_defun([_LT_CONFIG_SAVE_COMMANDS],
306 [_LT_CONFIG_LIBTOOL([$1])
307 _LT_CONFIG_LIBTOOL_INIT([$2])
308 ])
309
310
311 # _LT_FORMAT_COMMENT([COMMENT])
312 # -----------------------------
313 # Add leading comment marks to the start of each line, and a trailing
314 # full-stop to the whole comment if one is not present already.
315 m4_define([_LT_FORMAT_COMMENT],
316 [m4_ifval([$1], [
317 m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
318 [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
319 )])
320
321
322
323 ## ------------------------ ##
324 ## FIXME: Eliminate VARNAME ##
325 ## ------------------------ ##
326
327
328 # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
329 # -------------------------------------------------------------------
330 # CONFIGNAME is the name given to the value in the libtool script.
331 # VARNAME is the (base) name used in the configure script.
332 # VALUE may be 0, 1 or 2 for a computed quote escaped value based on
333 # VARNAME. Any other value will be used directly.
334 m4_define([_LT_DECL],
335 [lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
336 [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
337 [m4_ifval([$1], [$1], [$2])])
338 lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
339 m4_ifval([$4],
340 [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
341 lt_dict_add_subkey([lt_decl_dict], [$2],
342 [tagged?], [m4_ifval([$5], [yes], [no])])])
343 ])
344
345
346 # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
347 # --------------------------------------------------------
348 m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
349
350
351 # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
352 # ------------------------------------------------
353 m4_define([lt_decl_tag_varnames],
354 [_lt_decl_filter([tagged?], [yes], $@)])
355
356
357 # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
358 # ---------------------------------------------------------
359 m4_define([_lt_decl_filter],
360 [m4_case([$#],
361 [0], [m4_fatal([$0: too few arguments: $#])],
362 [1], [m4_fatal([$0: too few arguments: $#: $1])],
363 [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
364 [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
365 [lt_dict_filter([lt_decl_dict], $@)])[]dnl
366 ])
367
368
369 # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
370 # --------------------------------------------------
371 m4_define([lt_decl_quote_varnames],
372 [_lt_decl_filter([value], [1], $@)])
373
374
375 # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
376 # ---------------------------------------------------
377 m4_define([lt_decl_dquote_varnames],
378 [_lt_decl_filter([value], [2], $@)])
379
380
381 # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
382 # ---------------------------------------------------
383 m4_define([lt_decl_varnames_tagged],
384 [m4_assert([$# <= 2])dnl
385 _$0(m4_quote(m4_default([$1], [[, ]])),
386 m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
387 m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
388 m4_define([_lt_decl_varnames_tagged],
389 [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
390
391
392 # lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
393 # ------------------------------------------------
394 m4_define([lt_decl_all_varnames],
395 [_$0(m4_quote(m4_default([$1], [[, ]])),
396 m4_if([$2], [],
397 m4_quote(lt_decl_varnames),
398 m4_quote(m4_shift($@))))[]dnl
399 ])
400 m4_define([_lt_decl_all_varnames],
401 [lt_join($@, lt_decl_varnames_tagged([$1],
402 lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
403 ])
404
405
406 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
407 # ------------------------------------
408 # Quote a variable value, and forward it to `config.status' so that its
409 # declaration there will have the same value as in `configure'. VARNAME
410 # must have a single quote delimited value for this to work.
411 m4_define([_LT_CONFIG_STATUS_DECLARE],
412 [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
413
414
415 # _LT_CONFIG_STATUS_DECLARATIONS
416 # ------------------------------
417 # We delimit libtool config variables with single quotes, so when
418 # we write them to config.status, we have to be sure to quote all
419 # embedded single quotes properly. In configure, this macro expands
420 # each variable declared with _LT_DECL (and _LT_TAGDECL) into:
421 #
422 # <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
423 m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
424 [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
425 [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
426
427
428 # _LT_LIBTOOL_TAGS
429 # ----------------
430 # Output comment and list of tags supported by the script
431 m4_defun([_LT_LIBTOOL_TAGS],
432 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
433 available_tags="_LT_TAGS"dnl
434 ])
435
436
437 # _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
438 # -----------------------------------
439 # Extract the dictionary values for VARNAME (optionally with TAG) and
440 # expand to a commented shell variable setting:
441 #
442 # # Some comment about what VAR is for.
443 # visible_name=$lt_internal_name
444 m4_define([_LT_LIBTOOL_DECLARE],
445 [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
446 [description])))[]dnl
447 m4_pushdef([_libtool_name],
448 m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
449 m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
450 [0], [_libtool_name=[$]$1],
451 [1], [_libtool_name=$lt_[]$1],
452 [2], [_libtool_name=$lt_[]$1],
453 [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
454 m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
455 ])
456
457
458 # _LT_LIBTOOL_CONFIG_VARS
459 # -----------------------
460 # Produce commented declarations of non-tagged libtool config variables
461 # suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
462 # script. Tagged libtool config variables (even for the LIBTOOL CONFIG
463 # section) are produced by _LT_LIBTOOL_TAG_VARS.
464 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
465 [m4_foreach([_lt_var],
466 m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
467 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
468
469
470 # _LT_LIBTOOL_TAG_VARS(TAG)
471 # -------------------------
472 m4_define([_LT_LIBTOOL_TAG_VARS],
473 [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
474 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
475
476
477 # _LT_TAGVAR(VARNAME, [TAGNAME])
478 # ------------------------------
479 m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
480
481
482 # _LT_CONFIG_COMMANDS
483 # -------------------
484 # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
485 # variables for single and double quote escaping we saved from calls
486 # to _LT_DECL, we can put quote escaped variables declarations
487 # into `config.status', and then the shell code to quote escape them in
488 # for loops in `config.status'. Finally, any additional code accumulated
489 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
490 m4_defun([_LT_CONFIG_COMMANDS],
491 [AC_PROVIDE_IFELSE([LT_OUTPUT],
492 dnl If the libtool generation code has been placed in $CONFIG_LT,
493 dnl instead of duplicating it all over again into config.status,
494 dnl then we will have config.status run $CONFIG_LT later, so it
495 dnl needs to know what name is stored there:
496 [AC_CONFIG_COMMANDS([libtool],
497 [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
498 dnl If the libtool generation code is destined for config.status,
499 dnl expand the accumulated commands and init code now:
500 [AC_CONFIG_COMMANDS([libtool],
501 [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
502 ])#_LT_CONFIG_COMMANDS
503
504
505 # Initialize.
506 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
507 [
508
509 # The HP-UX ksh and POSIX shell print the target directory to stdout
510 # if CDPATH is set.
511 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
512
513 sed_quote_subst='$sed_quote_subst'
514 double_quote_subst='$double_quote_subst'
515 delay_variable_subst='$delay_variable_subst'
516 _LT_CONFIG_STATUS_DECLARATIONS
517 LTCC='$LTCC'
518 LTCFLAGS='$LTCFLAGS'
519 compiler='$compiler_DEFAULT'
520
521 # Quote evaled strings.
522 for var in lt_decl_all_varnames([[ \
523 ]], lt_decl_quote_varnames); do
524 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
525 *[[\\\\\\\`\\"\\\$]]*)
526 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
527 ;;
528 *)
529 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
530 ;;
531 esac
532 done
533
534 # Double-quote double-evaled strings.
535 for var in lt_decl_all_varnames([[ \
536 ]], lt_decl_dquote_varnames); do
537 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
538 *[[\\\\\\\`\\"\\\$]]*)
539 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
540 ;;
541 *)
542 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
543 ;;
544 esac
545 done
546
547 # Fix-up fallback echo if it was mangled by the above quoting rules.
548 case \$lt_ECHO in
549 *'\\\[$]0 --fallback-echo"')dnl "
550 lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
551 ;;
552 esac
553
554 _LT_OUTPUT_LIBTOOL_INIT
555 ])
556
557
558 # LT_OUTPUT
559 # ---------
560 # This macro allows early generation of the libtool script (before
561 # AC_OUTPUT is called), incase it is used in configure for compilation
562 # tests.
563 AC_DEFUN([LT_OUTPUT],
564 [: ${CONFIG_LT=./config.lt}
565 AC_MSG_NOTICE([creating $CONFIG_LT])
566 cat >"$CONFIG_LT" <<_LTEOF
567 #! $SHELL
568 # Generated by $as_me.
569 # Run this file to recreate a libtool stub with the current configuration.
570
571 lt_cl_silent=false
572 SHELL=\${CONFIG_SHELL-$SHELL}
573 _LTEOF
574
575 cat >>"$CONFIG_LT" <<\_LTEOF
576 AS_SHELL_SANITIZE
577 _AS_PREPARE
578
579 exec AS_MESSAGE_FD>&1
580 exec AS_MESSAGE_LOG_FD>>config.log
581 {
582 echo
583 AS_BOX([Running $as_me.])
584 } >&AS_MESSAGE_LOG_FD
585
586 lt_cl_help="\
587 \`$as_me' creates a local libtool stub from the current configuration,
588 for use in further configure time tests before the real libtool is
589 generated.
590
591 Usage: $[0] [[OPTIONS]]
592
593 -h, --help print this help, then exit
594 -V, --version print version number, then exit
595 -q, --quiet do not print progress messages
596 -d, --debug don't remove temporary files
597
598 Report bugs to <bug-libtool@gnu.org>."
599
600 lt_cl_version="\
601 m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
602 m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
603 configured by $[0], generated by m4_PACKAGE_STRING.
604
605 Copyright (C) 2008 Free Software Foundation, Inc.
606 This config.lt script is free software; the Free Software Foundation
607 gives unlimited permision to copy, distribute and modify it."
608
609 while test $[#] != 0
610 do
611 case $[1] in
612 --version | --v* | -V )
613 echo "$lt_cl_version"; exit 0 ;;
614 --help | --h* | -h )
615 echo "$lt_cl_help"; exit 0 ;;
616 --debug | --d* | -d )
617 debug=: ;;
618 --quiet | --q* | --silent | --s* | -q )
619 lt_cl_silent=: ;;
620
621 -*) AC_MSG_ERROR([unrecognized option: $[1]
622 Try \`$[0] --help' for more information.]) ;;
623
624 *) AC_MSG_ERROR([unrecognized argument: $[1]
625 Try \`$[0] --help' for more information.]) ;;
626 esac
627 shift
628 done
629
630 if $lt_cl_silent; then
631 exec AS_MESSAGE_FD>/dev/null
632 fi
633 _LTEOF
634
635 cat >>"$CONFIG_LT" <<_LTEOF
636 _LT_OUTPUT_LIBTOOL_COMMANDS_INIT
637 _LTEOF
638
639 cat >>"$CONFIG_LT" <<\_LTEOF
640 AC_MSG_NOTICE([creating $ofile])
641 _LT_OUTPUT_LIBTOOL_COMMANDS
642 AS_EXIT(0)
643 _LTEOF
644 chmod +x "$CONFIG_LT"
645
646 # configure is writing to config.log, but config.lt does its own redirection,
647 # appending to config.log, which fails on DOS, as config.log is still kept
648 # open by configure. Here we exec the FD to /dev/null, effectively closing
649 # config.log, so it can be properly (re)opened and appended to by config.lt.
650 if test "$no_create" != yes; then
651 lt_cl_success=:
652 test "$silent" = yes &&
653 lt_config_lt_args="$lt_config_lt_args --quiet"
654 exec AS_MESSAGE_LOG_FD>/dev/null
655 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
656 exec AS_MESSAGE_LOG_FD>>config.log
657 $lt_cl_success || AS_EXIT(1)
658 fi
659 ])# LT_OUTPUT
660
661
662 # _LT_CONFIG(TAG)
663 # ---------------
664 # If TAG is the built-in tag, create an initial libtool script with a
665 # default configuration from the untagged config vars. Otherwise add code
666 # to config.status for appending the configuration named by TAG from the
667 # matching tagged config vars.
668 m4_defun([_LT_CONFIG],
669 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
670 _LT_CONFIG_SAVE_COMMANDS([
671 m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
672 m4_if(_LT_TAG, [C], [
673 # See if we are running on zsh, and set the options which allow our
674 # commands through without removal of \ escapes.
675 if test -n "${ZSH_VERSION+set}" ; then
676 setopt NO_GLOB_SUBST
677 fi
678
679 cfgfile="${ofile}T"
680 trap "$RM \"$cfgfile\"; exit 1" 1 2 15
681 $RM "$cfgfile"
682
683 cat <<_LT_EOF >> "$cfgfile"
684 #! $SHELL
685
686 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
687 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
688 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
689 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
690 #
691 _LT_COPYING
692 _LT_LIBTOOL_TAGS
693
694 # ### BEGIN LIBTOOL CONFIG
695 _LT_LIBTOOL_CONFIG_VARS
696 _LT_LIBTOOL_TAG_VARS
697 # ### END LIBTOOL CONFIG
698
699 _LT_EOF
700
701 case $host_os in
702 aix3*)
703 cat <<\_LT_EOF >> "$cfgfile"
704 # AIX sometimes has problems with the GCC collect2 program. For some
705 # reason, if we set the COLLECT_NAMES environment variable, the problems
706 # vanish in a puff of smoke.
707 if test "X${COLLECT_NAMES+set}" != Xset; then
708 COLLECT_NAMES=
709 export COLLECT_NAMES
710 fi
711 _LT_EOF
712 ;;
713 esac
714
715 _LT_PROG_LTMAIN
716
717 # We use sed instead of cat because bash on DJGPP gets confused if
718 # if finds mixed CR/LF and LF-only lines. Since sed operates in
719 # text mode, it properly converts lines to CR/LF. This bash problem
720 # is reportedly fixed, but why not run on old versions too?
721 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
722 || (rm -f "$cfgfile"; exit 1)
723
724 _LT_PROG_XSI_SHELLFNS
725
726 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
727 || (rm -f "$cfgfile"; exit 1)
728
729 mv -f "$cfgfile" "$ofile" ||
730 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
731 chmod +x "$ofile"
732 ],
733 [cat <<_LT_EOF >> "$ofile"
734
735 dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
736 dnl in a comment (ie after a #).
737 # ### BEGIN LIBTOOL TAG CONFIG: $1
738 _LT_LIBTOOL_TAG_VARS(_LT_TAG)
739 # ### END LIBTOOL TAG CONFIG: $1
740 _LT_EOF
741 ])dnl /m4_if
742 ],
743 [m4_if([$1], [], [
744 PACKAGE='$PACKAGE'
745 VERSION='$VERSION'
746 TIMESTAMP='$TIMESTAMP'
747 RM='$RM'
748 ofile='$ofile'], [])
749 ])dnl /_LT_CONFIG_SAVE_COMMANDS
750 ])# _LT_CONFIG
751
752
753 # LT_SUPPORTED_TAG(TAG)
754 # ---------------------
755 # Trace this macro to discover what tags are supported by the libtool
756 # --tag option, using:
757 # autoconf --trace 'LT_SUPPORTED_TAG:$1'
758 AC_DEFUN([LT_SUPPORTED_TAG], [])
759
760
761 # C support is built-in for now
762 m4_define([_LT_LANG_C_enabled], [])
763 m4_define([_LT_TAGS], [])
764
765
766 # LT_LANG(LANG)
767 # -------------
768 # Enable libtool support for the given language if not already enabled.
769 AC_DEFUN([LT_LANG],
770 [AC_BEFORE([$0], [LT_OUTPUT])dnl
771 m4_case([$1],
772 [C], [_LT_LANG(C)],
773 [C++], [_LT_LANG(CXX)],
774 [Java], [_LT_LANG(GCJ)],
775 [Fortran 77], [_LT_LANG(F77)],
776 [Fortran], [_LT_LANG(FC)],
777 [Windows Resource], [_LT_LANG(RC)],
778 [m4_ifdef([_LT_LANG_]$1[_CONFIG],
779 [_LT_LANG($1)],
780 [m4_fatal([$0: unsupported language: "$1"])])])dnl
781 ])# LT_LANG
782
783
784 # _LT_LANG(LANGNAME)
785 # ------------------
786 m4_defun([_LT_LANG],
787 [m4_ifdef([_LT_LANG_]$1[_enabled], [],
788 [LT_SUPPORTED_TAG([$1])dnl
789 m4_append([_LT_TAGS], [$1 ])dnl
790 m4_define([_LT_LANG_]$1[_enabled], [])dnl
791 _LT_LANG_$1_CONFIG($1)])dnl
792 ])# _LT_LANG
793
794
795 # _LT_LANG_DEFAULT_CONFIG
796 # -----------------------
797 m4_defun([_LT_LANG_DEFAULT_CONFIG],
798 [AC_PROVIDE_IFELSE([AC_PROG_CXX],
799 [LT_LANG(CXX)],
800 [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
801
802 AC_PROVIDE_IFELSE([AC_PROG_F77],
803 [LT_LANG(F77)],
804 [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
805
806 AC_PROVIDE_IFELSE([AC_PROG_FC],
807 [LT_LANG(FC)],
808 [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
809
810 dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
811 dnl pulling things in needlessly.
812 AC_PROVIDE_IFELSE([AC_PROG_GCJ],
813 [LT_LANG(GCJ)],
814 [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
815 [LT_LANG(GCJ)],
816 [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
817 [LT_LANG(GCJ)],
818 [m4_ifdef([AC_PROG_GCJ],
819 [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
820 m4_ifdef([A][M_PROG_GCJ],
821 [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
822 m4_ifdef([LT_PROG_GCJ],
823 [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
824
825 AC_PROVIDE_IFELSE([LT_PROG_RC],
826 [LT_LANG(RC)],
827 [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
828 ])# _LT_LANG_DEFAULT_CONFIG
829
830 # Obsolete macros:
831 AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
832 AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
833 AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
834 AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
835 dnl aclocal-1.4 backwards compatibility:
836 dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
837 dnl AC_DEFUN([AC_LIBTOOL_F77], [])
838 dnl AC_DEFUN([AC_LIBTOOL_FC], [])
839 dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
840
841
842 # _LT_TAG_COMPILER
843 # ----------------
844 m4_defun([_LT_TAG_COMPILER],
845 [AC_REQUIRE([AC_PROG_CC])dnl
846
847 _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
848 _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
849 _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
850 _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
851
852 # If no C compiler was specified, use CC.
853 LTCC=${LTCC-"$CC"}
854
855 # If no C compiler flags were specified, use CFLAGS.
856 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
857
858 # Allow CC to be a program name with arguments.
859 compiler=$CC
860 ])# _LT_TAG_COMPILER
861
862
863 # _LT_COMPILER_BOILERPLATE
864 # ------------------------
865 # Check for compiler boilerplate output or warnings with
866 # the simple compiler test code.
867 m4_defun([_LT_COMPILER_BOILERPLATE],
868 [m4_require([_LT_DECL_SED])dnl
869 ac_outfile=conftest.$ac_objext
870 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
871 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
872 _lt_compiler_boilerplate=`cat conftest.err`
873 $RM conftest*
874 ])# _LT_COMPILER_BOILERPLATE
875
876
877 # _LT_LINKER_BOILERPLATE
878 # ----------------------
879 # Check for linker boilerplate output or warnings with
880 # the simple link test code.
881 m4_defun([_LT_LINKER_BOILERPLATE],
882 [m4_require([_LT_DECL_SED])dnl
883 ac_outfile=conftest.$ac_objext
884 echo "$lt_simple_link_test_code" >conftest.$ac_ext
885 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
886 _lt_linker_boilerplate=`cat conftest.err`
887 $RM -r conftest*
888 ])# _LT_LINKER_BOILERPLATE
889
890 # _LT_REQUIRED_DARWIN_CHECKS
891 # -------------------------
892 m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
893 case $host_os in
894 rhapsody* | darwin*)
895 AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
896 AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
897 AC_CHECK_TOOL([LIPO], [lipo], [:])
898 AC_CHECK_TOOL([OTOOL], [otool], [:])
899 AC_CHECK_TOOL([OTOOL64], [otool64], [:])
900 _LT_DECL([], [DSYMUTIL], [1],
901 [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
902 _LT_DECL([], [NMEDIT], [1],
903 [Tool to change global to local symbols on Mac OS X])
904 _LT_DECL([], [LIPO], [1],
905 [Tool to manipulate fat objects and archives on Mac OS X])
906 _LT_DECL([], [OTOOL], [1],
907 [ldd/readelf like tool for Mach-O binaries on Mac OS X])
908 _LT_DECL([], [OTOOL64], [1],
909 [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
910
911 AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
912 [lt_cv_apple_cc_single_mod=no
913 if test -z "${LT_MULTI_MODULE}"; then
914 # By default we will add the -single_module flag. You can override
915 # by either setting the environment variable LT_MULTI_MODULE
916 # non-empty at configure time, or by adding -multi_module to the
917 # link flags.
918 rm -rf libconftest.dylib*
919 echo "int foo(void){return 1;}" > conftest.c
920 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
921 -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
922 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
923 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
924 _lt_result=$?
925 if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
926 lt_cv_apple_cc_single_mod=yes
927 else
928 cat conftest.err >&AS_MESSAGE_LOG_FD
929 fi
930 rm -rf libconftest.dylib*
931 rm -f conftest.*
932 fi])
933 AC_CACHE_CHECK([for -exported_symbols_list linker flag],
934 [lt_cv_ld_exported_symbols_list],
935 [lt_cv_ld_exported_symbols_list=no
936 save_LDFLAGS=$LDFLAGS
937 echo "_main" > conftest.sym
938 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
939 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
940 [lt_cv_ld_exported_symbols_list=yes],
941 [lt_cv_ld_exported_symbols_list=no])
942 LDFLAGS="$save_LDFLAGS"
943 ])
944 case $host_os in
945 rhapsody* | darwin1.[[012]])
946 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
947 darwin1.*)
948 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
949 darwin*) # darwin 5.x on
950 # if running on 10.5 or later, the deployment target defaults
951 # to the OS version, if on x86, and 10.4, the deployment
952 # target defaults to 10.4. Don't you love it?
953 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
954 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
955 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
956 10.[[012]]*)
957 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
958 10.*)
959 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
960 esac
961 ;;
962 esac
963 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
964 _lt_dar_single_mod='$single_module'
965 fi
966 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
967 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
968 else
969 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
970 fi
971 if test "$DSYMUTIL" != ":"; then
972 _lt_dsymutil='~$DSYMUTIL $lib || :'
973 else
974 _lt_dsymutil=
975 fi
976 ;;
977 esac
978 ])
979
980
981 # _LT_DARWIN_LINKER_FEATURES
982 # --------------------------
983 # Checks for linker and compiler features on darwin
984 m4_defun([_LT_DARWIN_LINKER_FEATURES],
985 [
986 m4_require([_LT_REQUIRED_DARWIN_CHECKS])
987 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
988 _LT_TAGVAR(hardcode_direct, $1)=no
989 _LT_TAGVAR(hardcode_automatic, $1)=yes
990 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
991 _LT_TAGVAR(whole_archive_flag_spec, $1)=''
992 _LT_TAGVAR(link_all_deplibs, $1)=yes
993 _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
994 case $cc_basename in
995 ifort*) _lt_dar_can_shared=yes ;;
996 *) _lt_dar_can_shared=$GCC ;;
997 esac
998 if test "$_lt_dar_can_shared" = "yes"; then
999 output_verbose_link_cmd=echo
1000 _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}"
1001 _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
1002 _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}"
1003 _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}"
1004 m4_if([$1], [CXX],
1005 [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
1006 _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}"
1007 _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}"
1008 fi
1009 ],[])
1010 else
1011 _LT_TAGVAR(ld_shlibs, $1)=no
1012 fi
1013 ])
1014
1015 # _LT_SYS_MODULE_PATH_AIX
1016 # -----------------------
1017 # Links a minimal program and checks the executable
1018 # for the system default hardcoded library path. In most cases,
1019 # this is /usr/lib:/lib, but when the MPI compilers are used
1020 # the location of the communication and MPI libs are included too.
1021 # If we don't find anything, use the default library path according
1022 # to the aix ld manual.
1023 m4_defun([_LT_SYS_MODULE_PATH_AIX],
1024 [m4_require([_LT_DECL_SED])dnl
1025 AC_LINK_IFELSE(AC_LANG_PROGRAM,[
1026 lt_aix_libpath_sed='
1027 /Import File Strings/,/^$/ {
1028 /^0/ {
1029 s/^0 *\(.*\)$/\1/
1030 p
1031 }
1032 }'
1033 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1034 # Check for a 64-bit object if we didn't find anything.
1035 if test -z "$aix_libpath"; then
1036 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1037 fi],[])
1038 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
1039 ])# _LT_SYS_MODULE_PATH_AIX
1040
1041
1042 # _LT_SHELL_INIT(ARG)
1043 # -------------------
1044 m4_define([_LT_SHELL_INIT],
1045 [ifdef([AC_DIVERSION_NOTICE],
1046 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
1047 [AC_DIVERT_PUSH(NOTICE)])
1048 $1
1049 AC_DIVERT_POP
1050 ])# _LT_SHELL_INIT
1051
1052
1053 # _LT_PROG_ECHO_BACKSLASH
1054 # -----------------------
1055 # Add some code to the start of the generated configure script which
1056 # will find an echo command which doesn't interpret backslashes.
1057 m4_defun([_LT_PROG_ECHO_BACKSLASH],
1058 [_LT_SHELL_INIT([
1059 # Check that we are running under the correct shell.
1060 SHELL=${CONFIG_SHELL-/bin/sh}
1061
1062 case X$lt_ECHO in
1063 X*--fallback-echo)
1064 # Remove one level of quotation (which was required for Make).
1065 ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
1066 ;;
1067 esac
1068
1069 ECHO=${lt_ECHO-echo}
1070 if test "X[$]1" = X--no-reexec; then
1071 # Discard the --no-reexec flag, and continue.
1072 shift
1073 elif test "X[$]1" = X--fallback-echo; then
1074 # Avoid inline document here, it may be left over
1075 :
1076 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
1077 # Yippee, $ECHO works!
1078 :
1079 else
1080 # Restart under the correct shell.
1081 exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
1082 fi
1083
1084 if test "X[$]1" = X--fallback-echo; then
1085 # used as fallback echo
1086 shift
1087 cat <<_LT_EOF
1088 [$]*
1089 _LT_EOF
1090 exit 0
1091 fi
1092
1093 # The HP-UX ksh and POSIX shell print the target directory to stdout
1094 # if CDPATH is set.
1095 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1096
1097 if test -z "$lt_ECHO"; then
1098 if test "X${echo_test_string+set}" != Xset; then
1099 # find a string as large as possible, as long as the shell can cope with it
1100 for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
1101 # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
1102 if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
1103 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
1104 then
1105 break
1106 fi
1107 done
1108 fi
1109
1110 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1111 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1112 test "X$echo_testing_string" = "X$echo_test_string"; then
1113 :
1114 else
1115 # The Solaris, AIX, and Digital Unix default echo programs unquote
1116 # backslashes. This makes it impossible to quote backslashes using
1117 # echo "$something" | sed 's/\\/\\\\/g'
1118 #
1119 # So, first we look for a working echo in the user's PATH.
1120
1121 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
1122 for dir in $PATH /usr/ucb; do
1123 IFS="$lt_save_ifs"
1124 if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
1125 test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
1126 echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
1127 test "X$echo_testing_string" = "X$echo_test_string"; then
1128 ECHO="$dir/echo"
1129 break
1130 fi
1131 done
1132 IFS="$lt_save_ifs"
1133
1134 if test "X$ECHO" = Xecho; then
1135 # We didn't find a better echo, so look for alternatives.
1136 if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
1137 echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
1138 test "X$echo_testing_string" = "X$echo_test_string"; then
1139 # This shell has a builtin print -r that does the trick.
1140 ECHO='print -r'
1141 elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
1142 test "X$CONFIG_SHELL" != X/bin/ksh; then
1143 # If we have ksh, try running configure again with it.
1144 ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1145 export ORIGINAL_CONFIG_SHELL
1146 CONFIG_SHELL=/bin/ksh
1147 export CONFIG_SHELL
1148 exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
1149 else
1150 # Try using printf.
1151 ECHO='printf %s\n'
1152 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1153 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1154 test "X$echo_testing_string" = "X$echo_test_string"; then
1155 # Cool, printf works
1156 :
1157 elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1158 test "X$echo_testing_string" = 'X\t' &&
1159 echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1160 test "X$echo_testing_string" = "X$echo_test_string"; then
1161 CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
1162 export CONFIG_SHELL
1163 SHELL="$CONFIG_SHELL"
1164 export SHELL
1165 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1166 elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1167 test "X$echo_testing_string" = 'X\t' &&
1168 echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1169 test "X$echo_testing_string" = "X$echo_test_string"; then
1170 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1171 else
1172 # maybe with a smaller string...
1173 prev=:
1174
1175 for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
1176 if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
1177 then
1178 break
1179 fi
1180 prev="$cmd"
1181 done
1182
1183 if test "$prev" != 'sed 50q "[$]0"'; then
1184 echo_test_string=`eval $prev`
1185 export echo_test_string
1186 exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
1187 else
1188 # Oops. We lost completely, so just stick with echo.
1189 ECHO=echo
1190 fi
1191 fi
1192 fi
1193 fi
1194 fi
1195 fi
1196
1197 # Copy echo and quote the copy suitably for passing to libtool from
1198 # the Makefile, instead of quoting the original, which is used later.
1199 lt_ECHO=$ECHO
1200 if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
1201 lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
1202 fi
1203
1204 AC_SUBST(lt_ECHO)
1205 ])
1206 _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
1207 _LT_DECL([], [ECHO], [1],
1208 [An echo program that does not interpret backslashes])
1209 ])# _LT_PROG_ECHO_BACKSLASH
1210
1211
1212 # _LT_ENABLE_LOCK
1213 # ---------------
1214 m4_defun([_LT_ENABLE_LOCK],
1215 [AC_ARG_ENABLE([libtool-lock],
1216 [AS_HELP_STRING([--disable-libtool-lock],
1217 [avoid locking (might break parallel builds)])])
1218 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
1219
1220 # Some flags need to be propagated to the compiler or linker for good
1221 # libtool support.
1222 case $host in
1223 ia64-*-hpux*)
1224 # Find out which ABI we are using.
1225 echo 'int i;' > conftest.$ac_ext
1226 if AC_TRY_EVAL(ac_compile); then
1227 case `/usr/bin/file conftest.$ac_objext` in
1228 *ELF-32*)
1229 HPUX_IA64_MODE="32"
1230 ;;
1231 *ELF-64*)
1232 HPUX_IA64_MODE="64"
1233 ;;
1234 esac
1235 fi
1236 rm -rf conftest*
1237 ;;
1238 *-*-irix6*)
1239 # Find out which ABI we are using.
1240 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1241 if AC_TRY_EVAL(ac_compile); then
1242 if test "$lt_cv_prog_gnu_ld" = yes; then
1243 case `/usr/bin/file conftest.$ac_objext` in
1244 *32-bit*)
1245 LD="${LD-ld} -melf32bsmip"
1246 ;;
1247 *N32*)
1248 LD="${LD-ld} -melf32bmipn32"
1249 ;;
1250 *64-bit*)
1251 LD="${LD-ld} -melf64bmip"
1252 ;;
1253 esac
1254 else
1255 case `/usr/bin/file conftest.$ac_objext` in
1256 *32-bit*)
1257 LD="${LD-ld} -32"
1258 ;;
1259 *N32*)
1260 LD="${LD-ld} -n32"
1261 ;;
1262 *64-bit*)
1263 LD="${LD-ld} -64"
1264 ;;
1265 esac
1266 fi
1267 fi
1268 rm -rf conftest*
1269 ;;
1270
1271 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
1272 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
1273 # Find out which ABI we are using.
1274 echo 'int i;' > conftest.$ac_ext
1275 if AC_TRY_EVAL(ac_compile); then
1276 case `/usr/bin/file conftest.o` in
1277 *32-bit*)
1278 case $host in
1279 x86_64-*kfreebsd*-gnu)
1280 LD="${LD-ld} -m elf_i386_fbsd"
1281 ;;
1282 x86_64-*linux*)
1283 LD="${LD-ld} -m elf_i386"
1284 ;;
1285 ppc64-*linux*|powerpc64-*linux*)
1286 LD="${LD-ld} -m elf32ppclinux"
1287 ;;
1288 s390x-*linux*)
1289 LD="${LD-ld} -m elf_s390"
1290 ;;
1291 sparc64-*linux*)
1292 LD="${LD-ld} -m elf32_sparc"
1293 ;;
1294 esac
1295 ;;
1296 *64-bit*)
1297 case $host in
1298 x86_64-*kfreebsd*-gnu)
1299 LD="${LD-ld} -m elf_x86_64_fbsd"
1300 ;;
1301 x86_64-*linux*)
1302 LD="${LD-ld} -m elf_x86_64"
1303 ;;
1304 powerpc64le-*linux*)
1305 LD="${LD-ld} -m elf64lppc"
1306 ;;
1307 powerpc64-*linux*)
1308 LD="${LD-ld} -m elf64ppc"
1309 ;;
1310 s390*-*linux*|s390*-*tpf*)
1311 LD="${LD-ld} -m elf64_s390"
1312 ;;
1313 sparc*-*linux*)
1314 LD="${LD-ld} -m elf64_sparc"
1315 ;;
1316 esac
1317 ;;
1318 esac
1319 fi
1320 rm -rf conftest*
1321 ;;
1322
1323 *-*-sco3.2v5*)
1324 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1325 SAVE_CFLAGS="$CFLAGS"
1326 CFLAGS="$CFLAGS -belf"
1327 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1328 [AC_LANG_PUSH(C)
1329 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
1330 AC_LANG_POP])
1331 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1332 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1333 CFLAGS="$SAVE_CFLAGS"
1334 fi
1335 ;;
1336 sparc*-*solaris*)
1337 # Find out which ABI we are using.
1338 echo 'int i;' > conftest.$ac_ext
1339 if AC_TRY_EVAL(ac_compile); then
1340 case `/usr/bin/file conftest.o` in
1341 *64-bit*)
1342 case $lt_cv_prog_gnu_ld in
1343 yes*) LD="${LD-ld} -m elf64_sparc" ;;
1344 *)
1345 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
1346 LD="${LD-ld} -64"
1347 fi
1348 ;;
1349 esac
1350 ;;
1351 esac
1352 fi
1353 rm -rf conftest*
1354 ;;
1355 esac
1356
1357 need_locks="$enable_libtool_lock"
1358 ])# _LT_ENABLE_LOCK
1359
1360
1361 # _LT_CMD_OLD_ARCHIVE
1362 # -------------------
1363 m4_defun([_LT_CMD_OLD_ARCHIVE],
1364 [AC_CHECK_TOOL(AR, ar, false)
1365 test -z "$AR" && AR=ar
1366 test -z "$AR_FLAGS" && AR_FLAGS=cru
1367 _LT_DECL([], [AR], [1], [The archiver])
1368 _LT_DECL([], [AR_FLAGS], [1])
1369
1370 AC_CHECK_TOOL(STRIP, strip, :)
1371 test -z "$STRIP" && STRIP=:
1372 _LT_DECL([], [STRIP], [1], [A symbol stripping program])
1373
1374 AC_CHECK_TOOL(RANLIB, ranlib, :)
1375 test -z "$RANLIB" && RANLIB=:
1376 _LT_DECL([], [RANLIB], [1],
1377 [Commands used to install an old-style archive])
1378
1379 # Determine commands to create old-style static archives.
1380 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
1381 old_postinstall_cmds='chmod 644 $oldlib'
1382 old_postuninstall_cmds=
1383
1384 if test -n "$RANLIB"; then
1385 case $host_os in
1386 openbsd*)
1387 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
1388 ;;
1389 *)
1390 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
1391 ;;
1392 esac
1393 old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
1394 fi
1395 _LT_DECL([], [old_postinstall_cmds], [2])
1396 _LT_DECL([], [old_postuninstall_cmds], [2])
1397 _LT_TAGDECL([], [old_archive_cmds], [2],
1398 [Commands used to build an old-style archive])
1399 ])# _LT_CMD_OLD_ARCHIVE
1400
1401
1402 # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1403 # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
1404 # ----------------------------------------------------------------
1405 # Check whether the given compiler option works
1406 AC_DEFUN([_LT_COMPILER_OPTION],
1407 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1408 m4_require([_LT_DECL_SED])dnl
1409 AC_CACHE_CHECK([$1], [$2],
1410 [$2=no
1411 m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
1412 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1413 lt_compiler_flag="$3"
1414 # Insert the option either (1) after the last *FLAGS variable, or
1415 # (2) before a word containing "conftest.", or (3) at the end.
1416 # Note that $ac_compile itself does not contain backslashes and begins
1417 # with a dollar sign (not a hyphen), so the echo should work correctly.
1418 # The option is referenced via a variable to avoid confusing sed.
1419 lt_compile=`echo "$ac_compile" | $SED \
1420 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1421 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1422 -e 's:$: $lt_compiler_flag:'`
1423 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1424 (eval "$lt_compile" 2>conftest.err)
1425 ac_status=$?
1426 cat conftest.err >&AS_MESSAGE_LOG_FD
1427 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1428 if (exit $ac_status) && test -s "$ac_outfile"; then
1429 # The compiler can only warn and ignore the option if not recognized
1430 # So say no if there are warnings other than the usual output.
1431 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
1432 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1433 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
1434 $2=yes
1435 fi
1436 fi
1437 $RM conftest*
1438 ])
1439
1440 if test x"[$]$2" = xyes; then
1441 m4_if([$5], , :, [$5])
1442 else
1443 m4_if([$6], , :, [$6])
1444 fi
1445 ])# _LT_COMPILER_OPTION
1446
1447 # Old name:
1448 AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
1449 dnl aclocal-1.4 backwards compatibility:
1450 dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
1451
1452
1453 # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1454 # [ACTION-SUCCESS], [ACTION-FAILURE])
1455 # ----------------------------------------------------
1456 # Check whether the given linker option works
1457 AC_DEFUN([_LT_LINKER_OPTION],
1458 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1459 m4_require([_LT_DECL_SED])dnl
1460 AC_CACHE_CHECK([$1], [$2],
1461 [$2=no
1462 save_LDFLAGS="$LDFLAGS"
1463 LDFLAGS="$LDFLAGS $3"
1464 echo "$lt_simple_link_test_code" > conftest.$ac_ext
1465 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
1466 # The linker can only warn and ignore the option if not recognized
1467 # So say no if there are warnings
1468 if test -s conftest.err; then
1469 # Append any errors to the config.log.
1470 cat conftest.err 1>&AS_MESSAGE_LOG_FD
1471 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
1472 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1473 if diff conftest.exp conftest.er2 >/dev/null; then
1474 $2=yes
1475 fi
1476 else
1477 $2=yes
1478 fi
1479 fi
1480 $RM -r conftest*
1481 LDFLAGS="$save_LDFLAGS"
1482 ])
1483
1484 if test x"[$]$2" = xyes; then
1485 m4_if([$4], , :, [$4])
1486 else
1487 m4_if([$5], , :, [$5])
1488 fi
1489 ])# _LT_LINKER_OPTION
1490
1491 # Old name:
1492 AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
1493 dnl aclocal-1.4 backwards compatibility:
1494 dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
1495
1496
1497 # LT_CMD_MAX_LEN
1498 #---------------
1499 AC_DEFUN([LT_CMD_MAX_LEN],
1500 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1501 # find the maximum length of command line arguments
1502 AC_MSG_CHECKING([the maximum length of command line arguments])
1503 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
1504 i=0
1505 teststring="ABCD"
1506
1507 case $build_os in
1508 msdosdjgpp*)
1509 # On DJGPP, this test can blow up pretty badly due to problems in libc
1510 # (any single argument exceeding 2000 bytes causes a buffer overrun
1511 # during glob expansion). Even if it were fixed, the result of this
1512 # check would be larger than it should be.
1513 lt_cv_sys_max_cmd_len=12288; # 12K is about right
1514 ;;
1515
1516 gnu*)
1517 # Under GNU Hurd, this test is not required because there is
1518 # no limit to the length of command line arguments.
1519 # Libtool will interpret -1 as no limit whatsoever
1520 lt_cv_sys_max_cmd_len=-1;
1521 ;;
1522
1523 cygwin* | mingw* | cegcc*)
1524 # On Win9x/ME, this test blows up -- it succeeds, but takes
1525 # about 5 minutes as the teststring grows exponentially.
1526 # Worse, since 9x/ME are not pre-emptively multitasking,
1527 # you end up with a "frozen" computer, even though with patience
1528 # the test eventually succeeds (with a max line length of 256k).
1529 # Instead, let's just punt: use the minimum linelength reported by
1530 # all of the supported platforms: 8192 (on NT/2K/XP).
1531 lt_cv_sys_max_cmd_len=8192;
1532 ;;
1533
1534 beos*)
1535 # On BeOS, this test takes a really really long time.
1536 # So we just punt and use a minimum line length of 8192.
1537 lt_cv_sys_max_cmd_len=8192;
1538 ;;
1539
1540 amigaos*)
1541 # On AmigaOS with pdksh, this test takes hours, literally.
1542 # So we just punt and use a minimum line length of 8192.
1543 lt_cv_sys_max_cmd_len=8192;
1544 ;;
1545
1546 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
1547 # This has been around since 386BSD, at least. Likely further.
1548 if test -x /sbin/sysctl; then
1549 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
1550 elif test -x /usr/sbin/sysctl; then
1551 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
1552 else
1553 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
1554 fi
1555 # And add a safety zone
1556 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1557 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1558 ;;
1559
1560 interix*)
1561 # We know the value 262144 and hardcode it with a safety zone (like BSD)
1562 lt_cv_sys_max_cmd_len=196608
1563 ;;
1564
1565 osf*)
1566 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
1567 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
1568 # nice to cause kernel panics so lets avoid the loop below.
1569 # First set a reasonable default.
1570 lt_cv_sys_max_cmd_len=16384
1571 #
1572 if test -x /sbin/sysconfig; then
1573 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
1574 *1*) lt_cv_sys_max_cmd_len=-1 ;;
1575 esac
1576 fi
1577 ;;
1578 sco3.2v5*)
1579 lt_cv_sys_max_cmd_len=102400
1580 ;;
1581 sysv5* | sco5v6* | sysv4.2uw2*)
1582 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
1583 if test -n "$kargmax"; then
1584 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
1585 else
1586 lt_cv_sys_max_cmd_len=32768
1587 fi
1588 ;;
1589 *)
1590 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
1591 if test -n "$lt_cv_sys_max_cmd_len"; then
1592 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1593 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1594 else
1595 # Make teststring a little bigger before we do anything with it.
1596 # a 1K string should be a reasonable start.
1597 for i in 1 2 3 4 5 6 7 8 ; do
1598 teststring=$teststring$teststring
1599 done
1600 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
1601 # If test is not a shell built-in, we'll probably end up computing a
1602 # maximum length that is only half of the actual maximum length, but
1603 # we can't tell.
1604 while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
1605 = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
1606 test $i != 17 # 1/2 MB should be enough
1607 do
1608 i=`expr $i + 1`
1609 teststring=$teststring$teststring
1610 done
1611 # Only check the string length outside the loop.
1612 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
1613 teststring=
1614 # Add a significant safety factor because C++ compilers can tack on
1615 # massive amounts of additional arguments before passing them to the
1616 # linker. It appears as though 1/2 is a usable value.
1617 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
1618 fi
1619 ;;
1620 esac
1621 ])
1622 if test -n $lt_cv_sys_max_cmd_len ; then
1623 AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
1624 else
1625 AC_MSG_RESULT(none)
1626 fi
1627 max_cmd_len=$lt_cv_sys_max_cmd_len
1628 _LT_DECL([], [max_cmd_len], [0],
1629 [What is the maximum length of a command?])
1630 ])# LT_CMD_MAX_LEN
1631
1632 # Old name:
1633 AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
1634 dnl aclocal-1.4 backwards compatibility:
1635 dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
1636
1637
1638 # _LT_HEADER_DLFCN
1639 # ----------------
1640 m4_defun([_LT_HEADER_DLFCN],
1641 [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
1642 ])# _LT_HEADER_DLFCN
1643
1644
1645 # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
1646 # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
1647 # ----------------------------------------------------------------
1648 m4_defun([_LT_TRY_DLOPEN_SELF],
1649 [m4_require([_LT_HEADER_DLFCN])dnl
1650 if test "$cross_compiling" = yes; then :
1651 [$4]
1652 else
1653 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1654 lt_status=$lt_dlunknown
1655 cat > conftest.$ac_ext <<_LT_EOF
1656 [#line __oline__ "configure"
1657 #include "confdefs.h"
1658
1659 #if HAVE_DLFCN_H
1660 #include <dlfcn.h>
1661 #endif
1662
1663 #include <stdio.h>
1664
1665 #ifdef RTLD_GLOBAL
1666 # define LT_DLGLOBAL RTLD_GLOBAL
1667 #else
1668 # ifdef DL_GLOBAL
1669 # define LT_DLGLOBAL DL_GLOBAL
1670 # else
1671 # define LT_DLGLOBAL 0
1672 # endif
1673 #endif
1674
1675 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
1676 find out it does not work in some platform. */
1677 #ifndef LT_DLLAZY_OR_NOW
1678 # ifdef RTLD_LAZY
1679 # define LT_DLLAZY_OR_NOW RTLD_LAZY
1680 # else
1681 # ifdef DL_LAZY
1682 # define LT_DLLAZY_OR_NOW DL_LAZY
1683 # else
1684 # ifdef RTLD_NOW
1685 # define LT_DLLAZY_OR_NOW RTLD_NOW
1686 # else
1687 # ifdef DL_NOW
1688 # define LT_DLLAZY_OR_NOW DL_NOW
1689 # else
1690 # define LT_DLLAZY_OR_NOW 0
1691 # endif
1692 # endif
1693 # endif
1694 # endif
1695 #endif
1696
1697 void fnord() { int i=42;}
1698 int main ()
1699 {
1700 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
1701 int status = $lt_dlunknown;
1702
1703 if (self)
1704 {
1705 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
1706 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
1707 /* dlclose (self); */
1708 }
1709 else
1710 puts (dlerror ());
1711
1712 return status;
1713 }]
1714 _LT_EOF
1715 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
1716 (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
1717 lt_status=$?
1718 case x$lt_status in
1719 x$lt_dlno_uscore) $1 ;;
1720 x$lt_dlneed_uscore) $2 ;;
1721 x$lt_dlunknown|x*) $3 ;;
1722 esac
1723 else :
1724 # compilation failed
1725 $3
1726 fi
1727 fi
1728 rm -fr conftest*
1729 ])# _LT_TRY_DLOPEN_SELF
1730
1731
1732 # LT_SYS_DLOPEN_SELF
1733 # ------------------
1734 AC_DEFUN([LT_SYS_DLOPEN_SELF],
1735 [m4_require([_LT_HEADER_DLFCN])dnl
1736 if test "x$enable_dlopen" != xyes; then
1737 enable_dlopen=unknown
1738 enable_dlopen_self=unknown
1739 enable_dlopen_self_static=unknown
1740 else
1741 lt_cv_dlopen=no
1742 lt_cv_dlopen_libs=
1743
1744 case $host_os in
1745 beos*)
1746 lt_cv_dlopen="load_add_on"
1747 lt_cv_dlopen_libs=
1748 lt_cv_dlopen_self=yes
1749 ;;
1750
1751 mingw* | pw32* | cegcc*)
1752 lt_cv_dlopen="LoadLibrary"
1753 lt_cv_dlopen_libs=
1754 ;;
1755
1756 cygwin*)
1757 lt_cv_dlopen="dlopen"
1758 lt_cv_dlopen_libs=
1759 ;;
1760
1761 darwin*)
1762 # if libdl is installed we need to link against it
1763 AC_CHECK_LIB([dl], [dlopen],
1764 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
1765 lt_cv_dlopen="dyld"
1766 lt_cv_dlopen_libs=
1767 lt_cv_dlopen_self=yes
1768 ])
1769 ;;
1770
1771 *)
1772 AC_CHECK_FUNC([shl_load],
1773 [lt_cv_dlopen="shl_load"],
1774 [AC_CHECK_LIB([dld], [shl_load],
1775 [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
1776 [AC_CHECK_FUNC([dlopen],
1777 [lt_cv_dlopen="dlopen"],
1778 [AC_CHECK_LIB([dl], [dlopen],
1779 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
1780 [AC_CHECK_LIB([svld], [dlopen],
1781 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
1782 [AC_CHECK_LIB([dld], [dld_link],
1783 [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
1784 ])
1785 ])
1786 ])
1787 ])
1788 ])
1789 ;;
1790 esac
1791
1792 if test "x$lt_cv_dlopen" != xno; then
1793 enable_dlopen=yes
1794 else
1795 enable_dlopen=no
1796 fi
1797
1798 case $lt_cv_dlopen in
1799 dlopen)
1800 save_CPPFLAGS="$CPPFLAGS"
1801 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
1802
1803 save_LDFLAGS="$LDFLAGS"
1804 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
1805
1806 save_LIBS="$LIBS"
1807 LIBS="$lt_cv_dlopen_libs $LIBS"
1808
1809 AC_CACHE_CHECK([whether a program can dlopen itself],
1810 lt_cv_dlopen_self, [dnl
1811 _LT_TRY_DLOPEN_SELF(
1812 lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
1813 lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
1814 ])
1815
1816 if test "x$lt_cv_dlopen_self" = xyes; then
1817 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
1818 AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
1819 lt_cv_dlopen_self_static, [dnl
1820 _LT_TRY_DLOPEN_SELF(
1821 lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
1822 lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
1823 ])
1824 fi
1825
1826 CPPFLAGS="$save_CPPFLAGS"
1827 LDFLAGS="$save_LDFLAGS"
1828 LIBS="$save_LIBS"
1829 ;;
1830 esac
1831
1832 case $lt_cv_dlopen_self in
1833 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
1834 *) enable_dlopen_self=unknown ;;
1835 esac
1836
1837 case $lt_cv_dlopen_self_static in
1838 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
1839 *) enable_dlopen_self_static=unknown ;;
1840 esac
1841 fi
1842 _LT_DECL([dlopen_support], [enable_dlopen], [0],
1843 [Whether dlopen is supported])
1844 _LT_DECL([dlopen_self], [enable_dlopen_self], [0],
1845 [Whether dlopen of programs is supported])
1846 _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
1847 [Whether dlopen of statically linked programs is supported])
1848 ])# LT_SYS_DLOPEN_SELF
1849
1850 # Old name:
1851 AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
1852 dnl aclocal-1.4 backwards compatibility:
1853 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
1854
1855
1856 # _LT_COMPILER_C_O([TAGNAME])
1857 # ---------------------------
1858 # Check to see if options -c and -o are simultaneously supported by compiler.
1859 # This macro does not hard code the compiler like AC_PROG_CC_C_O.
1860 m4_defun([_LT_COMPILER_C_O],
1861 [m4_require([_LT_DECL_SED])dnl
1862 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1863 m4_require([_LT_TAG_COMPILER])dnl
1864 AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
1865 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
1866 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
1867 $RM -r conftest 2>/dev/null
1868 mkdir conftest
1869 cd conftest
1870 mkdir out
1871 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1872
1873 lt_compiler_flag="-o out/conftest2.$ac_objext"
1874 # Insert the option either (1) after the last *FLAGS variable, or
1875 # (2) before a word containing "conftest.", or (3) at the end.
1876 # Note that $ac_compile itself does not contain backslashes and begins
1877 # with a dollar sign (not a hyphen), so the echo should work correctly.
1878 lt_compile=`echo "$ac_compile" | $SED \
1879 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1880 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1881 -e 's:$: $lt_compiler_flag:'`
1882 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1883 (eval "$lt_compile" 2>out/conftest.err)
1884 ac_status=$?
1885 cat out/conftest.err >&AS_MESSAGE_LOG_FD
1886 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1887 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1888 then
1889 # The compiler can only warn and ignore the option if not recognized
1890 # So say no if there are warnings
1891 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
1892 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
1893 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
1894 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
1895 fi
1896 fi
1897 chmod u+w . 2>&AS_MESSAGE_LOG_FD
1898 $RM conftest*
1899 # SGI C++ compiler will create directory out/ii_files/ for
1900 # template instantiation
1901 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
1902 $RM out/* && rmdir out
1903 cd ..
1904 $RM -r conftest
1905 $RM conftest*
1906 ])
1907 _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
1908 [Does compiler simultaneously support -c and -o options?])
1909 ])# _LT_COMPILER_C_O
1910
1911
1912 # _LT_COMPILER_FILE_LOCKS([TAGNAME])
1913 # ----------------------------------
1914 # Check to see if we can do hard links to lock some files if needed
1915 m4_defun([_LT_COMPILER_FILE_LOCKS],
1916 [m4_require([_LT_ENABLE_LOCK])dnl
1917 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1918 _LT_COMPILER_C_O([$1])
1919
1920 hard_links="nottested"
1921 if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
1922 # do not overwrite the value of need_locks provided by the user
1923 AC_MSG_CHECKING([if we can lock with hard links])
1924 hard_links=yes
1925 $RM conftest*
1926 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1927 touch conftest.a
1928 ln conftest.a conftest.b 2>&5 || hard_links=no
1929 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1930 AC_MSG_RESULT([$hard_links])
1931 if test "$hard_links" = no; then
1932 AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
1933 need_locks=warn
1934 fi
1935 else
1936 need_locks=no
1937 fi
1938 _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
1939 ])# _LT_COMPILER_FILE_LOCKS
1940
1941
1942 # _LT_CHECK_OBJDIR
1943 # ----------------
1944 m4_defun([_LT_CHECK_OBJDIR],
1945 [AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
1946 [rm -f .libs 2>/dev/null
1947 mkdir .libs 2>/dev/null
1948 if test -d .libs; then
1949 lt_cv_objdir=.libs
1950 else
1951 # MS-DOS does not allow filenames that begin with a dot.
1952 lt_cv_objdir=_libs
1953 fi
1954 rmdir .libs 2>/dev/null])
1955 objdir=$lt_cv_objdir
1956 _LT_DECL([], [objdir], [0],
1957 [The name of the directory that contains temporary libtool files])dnl
1958 m4_pattern_allow([LT_OBJDIR])dnl
1959 AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
1960 [Define to the sub-directory in which libtool stores uninstalled libraries.])
1961 ])# _LT_CHECK_OBJDIR
1962
1963
1964 # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
1965 # --------------------------------------
1966 # Check hardcoding attributes.
1967 m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
1968 [AC_MSG_CHECKING([how to hardcode library paths into programs])
1969 _LT_TAGVAR(hardcode_action, $1)=
1970 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
1971 test -n "$_LT_TAGVAR(runpath_var, $1)" ||
1972 test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
1973
1974 # We can hardcode non-existent directories.
1975 if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
1976 # If the only mechanism to avoid hardcoding is shlibpath_var, we
1977 # have to relink, otherwise we might link with an installed library
1978 # when we should be linking with a yet-to-be-installed one
1979 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
1980 test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
1981 # Linking always hardcodes the temporary library directory.
1982 _LT_TAGVAR(hardcode_action, $1)=relink
1983 else
1984 # We can link without hardcoding, and we can hardcode nonexisting dirs.
1985 _LT_TAGVAR(hardcode_action, $1)=immediate
1986 fi
1987 else
1988 # We cannot hardcode anything, or else we can only hardcode existing
1989 # directories.
1990 _LT_TAGVAR(hardcode_action, $1)=unsupported
1991 fi
1992 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
1993
1994 if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
1995 test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
1996 # Fast installation is not supported
1997 enable_fast_install=no
1998 elif test "$shlibpath_overrides_runpath" = yes ||
1999 test "$enable_shared" = no; then
2000 # Fast installation is not necessary
2001 enable_fast_install=needless
2002 fi
2003 _LT_TAGDECL([], [hardcode_action], [0],
2004 [How to hardcode a shared library path into an executable])
2005 ])# _LT_LINKER_HARDCODE_LIBPATH
2006
2007
2008 # _LT_CMD_STRIPLIB
2009 # ----------------
2010 m4_defun([_LT_CMD_STRIPLIB],
2011 [m4_require([_LT_DECL_EGREP])
2012 striplib=
2013 old_striplib=
2014 AC_MSG_CHECKING([whether stripping libraries is possible])
2015 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
2016 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
2017 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
2018 AC_MSG_RESULT([yes])
2019 else
2020 # FIXME - insert some real tests, host_os isn't really good enough
2021 case $host_os in
2022 darwin*)
2023 if test -n "$STRIP" ; then
2024 striplib="$STRIP -x"
2025 old_striplib="$STRIP -S"
2026 AC_MSG_RESULT([yes])
2027 else
2028 AC_MSG_RESULT([no])
2029 fi
2030 ;;
2031 *)
2032 AC_MSG_RESULT([no])
2033 ;;
2034 esac
2035 fi
2036 _LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
2037 _LT_DECL([], [striplib], [1])
2038 ])# _LT_CMD_STRIPLIB
2039
2040
2041 # _LT_SYS_DYNAMIC_LINKER([TAG])
2042 # -----------------------------
2043 # PORTME Fill in your ld.so characteristics
2044 m4_defun([_LT_SYS_DYNAMIC_LINKER],
2045 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
2046 m4_require([_LT_DECL_EGREP])dnl
2047 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
2048 m4_require([_LT_DECL_OBJDUMP])dnl
2049 m4_require([_LT_DECL_SED])dnl
2050 AC_MSG_CHECKING([dynamic linker characteristics])
2051 m4_if([$1],
2052 [], [
2053 if test "$GCC" = yes; then
2054 case $host_os in
2055 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
2056 *) lt_awk_arg="/^libraries:/" ;;
2057 esac
2058 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2059 if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
2060 # if the path contains ";" then we assume it to be the separator
2061 # otherwise default to the standard path separator (i.e. ":") - it is
2062 # assumed that no part of a normal pathname contains ";" but that should
2063 # okay in the real world where ";" in dirpaths is itself problematic.
2064 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
2065 else
2066 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2067 fi
2068 # Ok, now we have the path, separated by spaces, we can step through it
2069 # and add multilib dir if necessary.
2070 lt_tmp_lt_search_path_spec=
2071 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
2072 for lt_sys_path in $lt_search_path_spec; do
2073 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
2074 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
2075 else
2076 test -d "$lt_sys_path" && \
2077 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
2078 fi
2079 done
2080 lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
2081 BEGIN {RS=" "; FS="/|\n";} {
2082 lt_foo="";
2083 lt_count=0;
2084 for (lt_i = NF; lt_i > 0; lt_i--) {
2085 if ($lt_i != "" && $lt_i != ".") {
2086 if ($lt_i == "..") {
2087 lt_count++;
2088 } else {
2089 if (lt_count == 0) {
2090 lt_foo="/" $lt_i lt_foo;
2091 } else {
2092 lt_count--;
2093 }
2094 }
2095 }
2096 }
2097 if (lt_foo != "") { lt_freq[[lt_foo]]++; }
2098 if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
2099 }'`
2100 sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
2101 else
2102 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
2103 fi])
2104 library_names_spec=
2105 libname_spec='lib$name'
2106 soname_spec=
2107 shrext_cmds=".so"
2108 postinstall_cmds=
2109 postuninstall_cmds=
2110 finish_cmds=
2111 finish_eval=
2112 shlibpath_var=
2113 shlibpath_overrides_runpath=unknown
2114 version_type=none
2115 dynamic_linker="$host_os ld.so"
2116 sys_lib_dlsearch_path_spec="/lib /usr/lib"
2117 need_lib_prefix=unknown
2118 hardcode_into_libs=no
2119
2120 # when you set need_version to no, make sure it does not cause -set_version
2121 # flags to be left without arguments
2122 need_version=unknown
2123
2124 case $host_os in
2125 aix3*)
2126 version_type=linux
2127 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
2128 shlibpath_var=LIBPATH
2129
2130 # AIX 3 has no versioning support, so we append a major version to the name.
2131 soname_spec='${libname}${release}${shared_ext}$major'
2132 ;;
2133
2134 aix[[4-9]]*)
2135 version_type=linux
2136 need_lib_prefix=no
2137 need_version=no
2138 hardcode_into_libs=yes
2139 if test "$host_cpu" = ia64; then
2140 # AIX 5 supports IA64
2141 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
2142 shlibpath_var=LD_LIBRARY_PATH
2143 else
2144 # With GCC up to 2.95.x, collect2 would create an import file
2145 # for dependence libraries. The import file would start with
2146 # the line `#! .'. This would cause the generated library to
2147 # depend on `.', always an invalid library. This was fixed in
2148 # development snapshots of GCC prior to 3.0.
2149 case $host_os in
2150 aix4 | aix4.[[01]] | aix4.[[01]].*)
2151 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
2152 echo ' yes '
2153 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
2154 :
2155 else
2156 can_build_shared=no
2157 fi
2158 ;;
2159 esac
2160 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
2161 # soname into executable. Probably we can add versioning support to
2162 # collect2, so additional links can be useful in future.
2163 if test "$aix_use_runtimelinking" = yes; then
2164 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
2165 # instead of lib<name>.a to let people know that these are not
2166 # typical AIX shared libraries.
2167 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2168 else
2169 # We preserve .a as extension for shared libraries through AIX4.2
2170 # and later when we are not doing run time linking.
2171 library_names_spec='${libname}${release}.a $libname.a'
2172 soname_spec='${libname}${release}${shared_ext}$major'
2173 fi
2174 shlibpath_var=LIBPATH
2175 fi
2176 ;;
2177
2178 amigaos*)
2179 case $host_cpu in
2180 powerpc)
2181 # Since July 2007 AmigaOS4 officially supports .so libraries.
2182 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
2183 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2184 ;;
2185 m68k)
2186 library_names_spec='$libname.ixlibrary $libname.a'
2187 # Create ${libname}_ixlibrary.a entries in /sys/libs.
2188 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'
2189 ;;
2190 esac
2191 ;;
2192
2193 beos*)
2194 library_names_spec='${libname}${shared_ext}'
2195 dynamic_linker="$host_os ld.so"
2196 shlibpath_var=LIBRARY_PATH
2197 ;;
2198
2199 bsdi[[45]]*)
2200 version_type=linux
2201 need_version=no
2202 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2203 soname_spec='${libname}${release}${shared_ext}$major'
2204 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
2205 shlibpath_var=LD_LIBRARY_PATH
2206 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
2207 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
2208 # the default ld.so.conf also contains /usr/contrib/lib and
2209 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
2210 # libtool to hard-code these into programs
2211 ;;
2212
2213 cygwin* | mingw* | pw32* | cegcc*)
2214 version_type=windows
2215 shrext_cmds=".dll"
2216 need_version=no
2217 need_lib_prefix=no
2218
2219 case $GCC,$host_os in
2220 yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
2221 library_names_spec='$libname.dll.a'
2222 # DLL is installed to $(libdir)/../bin by postinstall_cmds
2223 postinstall_cmds='base_file=`basename \${file}`~
2224 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
2225 dldir=$destdir/`dirname \$dlpath`~
2226 test -d \$dldir || mkdir -p \$dldir~
2227 $install_prog $dir/$dlname \$dldir/$dlname~
2228 chmod a+x \$dldir/$dlname~
2229 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
2230 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
2231 fi'
2232 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
2233 dlpath=$dir/\$dldll~
2234 $RM \$dlpath'
2235 shlibpath_overrides_runpath=yes
2236
2237 case $host_os in
2238 cygwin*)
2239 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
2240 #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2241 soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
2242 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
2243 ;;
2244 mingw* | cegcc*)
2245 # MinGW DLLs use traditional 'lib' prefix
2246 #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2247 soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
2248 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2249 if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
2250 # It is most probably a Windows format PATH printed by
2251 # mingw gcc, but we are running on Cygwin. Gcc prints its search
2252 # path with ; separators, and with drive letters. We can handle the
2253 # drive letters (cygwin fileutils understands them), so leave them,
2254 # especially as we might pass files found there to a mingw objdump,
2255 # which wouldn't understand a cygwinified path. Ahh.
2256 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
2257 else
2258 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2259 fi
2260 ;;
2261 pw32*)
2262 # pw32 DLLs use 'pw' prefix rather than 'lib'
2263 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2264 ;;
2265 esac
2266 ;;
2267
2268 *)
2269 library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
2270 ;;
2271 esac
2272 dynamic_linker='Win32 ld.exe'
2273 # FIXME: first we should search . and the directory the executable is in
2274 shlibpath_var=PATH
2275 ;;
2276
2277 darwin* | rhapsody*)
2278 dynamic_linker="$host_os dyld"
2279 version_type=darwin
2280 need_lib_prefix=no
2281 need_version=no
2282 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
2283 soname_spec='${libname}${release}${major}$shared_ext'
2284 shlibpath_overrides_runpath=yes
2285 shlibpath_var=DYLD_LIBRARY_PATH
2286 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
2287 m4_if([$1], [],[
2288 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
2289 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
2290 ;;
2291
2292 dgux*)
2293 version_type=linux
2294 need_lib_prefix=no
2295 need_version=no
2296 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
2297 soname_spec='${libname}${release}${shared_ext}$major'
2298 shlibpath_var=LD_LIBRARY_PATH
2299 ;;
2300
2301 freebsd1*)
2302 dynamic_linker=no
2303 ;;
2304
2305 freebsd* | dragonfly*)
2306 # DragonFly does not have aout. When/if they implement a new
2307 # versioning mechanism, adjust this.
2308 if test -x /usr/bin/objformat; then
2309 objformat=`/usr/bin/objformat`
2310 else
2311 case $host_os in
2312 freebsd[[123]]*) objformat=aout ;;
2313 *) objformat=elf ;;
2314 esac
2315 fi
2316 version_type=freebsd-$objformat
2317 case $version_type in
2318 freebsd-elf*)
2319 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2320 need_version=no
2321 need_lib_prefix=no
2322 ;;
2323 freebsd-*)
2324 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
2325 need_version=yes
2326 ;;
2327 esac
2328 shlibpath_var=LD_LIBRARY_PATH
2329 case $host_os in
2330 freebsd2*)
2331 shlibpath_overrides_runpath=yes
2332 ;;
2333 freebsd3.[[01]]* | freebsdelf3.[[01]]*)
2334 shlibpath_overrides_runpath=yes
2335 hardcode_into_libs=yes
2336 ;;
2337 freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
2338 freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
2339 shlibpath_overrides_runpath=no
2340 hardcode_into_libs=yes
2341 ;;
2342 *) # from 4.6 on, and DragonFly
2343 shlibpath_overrides_runpath=yes
2344 hardcode_into_libs=yes
2345 ;;
2346 esac
2347 ;;
2348
2349 gnu*)
2350 version_type=linux
2351 need_lib_prefix=no
2352 need_version=no
2353 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
2354 soname_spec='${libname}${release}${shared_ext}$major'
2355 shlibpath_var=LD_LIBRARY_PATH
2356 hardcode_into_libs=yes
2357 ;;
2358
2359 hpux9* | hpux10* | hpux11*)
2360 # Give a soname corresponding to the major version so that dld.sl refuses to
2361 # link against other versions.
2362 version_type=sunos
2363 need_lib_prefix=no
2364 need_version=no
2365 case $host_cpu in
2366 ia64*)
2367 shrext_cmds='.so'
2368 hardcode_into_libs=yes
2369 dynamic_linker="$host_os dld.so"
2370 shlibpath_var=LD_LIBRARY_PATH
2371 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2372 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2373 soname_spec='${libname}${release}${shared_ext}$major'
2374 if test "X$HPUX_IA64_MODE" = X32; then
2375 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
2376 else
2377 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
2378 fi
2379 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2380 ;;
2381 hppa*64*)
2382 shrext_cmds='.sl'
2383 hardcode_into_libs=yes
2384 dynamic_linker="$host_os dld.sl"
2385 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
2386 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2387 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2388 soname_spec='${libname}${release}${shared_ext}$major'
2389 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
2390 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2391 ;;
2392 *)
2393 shrext_cmds='.sl'
2394 dynamic_linker="$host_os dld.sl"
2395 shlibpath_var=SHLIB_PATH
2396 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
2397 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2398 soname_spec='${libname}${release}${shared_ext}$major'
2399 ;;
2400 esac
2401 # HP-UX runs *really* slowly unless shared libraries are mode 555.
2402 postinstall_cmds='chmod 555 $lib'
2403 ;;
2404
2405 interix[[3-9]]*)
2406 version_type=linux
2407 need_lib_prefix=no
2408 need_version=no
2409 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2410 soname_spec='${libname}${release}${shared_ext}$major'
2411 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
2412 shlibpath_var=LD_LIBRARY_PATH
2413 shlibpath_overrides_runpath=no
2414 hardcode_into_libs=yes
2415 ;;
2416
2417 irix5* | irix6* | nonstopux*)
2418 case $host_os in
2419 nonstopux*) version_type=nonstopux ;;
2420 *)
2421 if test "$lt_cv_prog_gnu_ld" = yes; then
2422 version_type=linux
2423 else
2424 version_type=irix
2425 fi ;;
2426 esac
2427 need_lib_prefix=no
2428 need_version=no
2429 soname_spec='${libname}${release}${shared_ext}$major'
2430 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
2431 case $host_os in
2432 irix5* | nonstopux*)
2433 libsuff= shlibsuff=
2434 ;;
2435 *)
2436 case $LD in # libtool.m4 will add one of these switches to LD
2437 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
2438 libsuff= shlibsuff= libmagic=32-bit;;
2439 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
2440 libsuff=32 shlibsuff=N32 libmagic=N32;;
2441 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
2442 libsuff=64 shlibsuff=64 libmagic=64-bit;;
2443 *) libsuff= shlibsuff= libmagic=never-match;;
2444 esac
2445 ;;
2446 esac
2447 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
2448 shlibpath_overrides_runpath=no
2449 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
2450 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
2451 hardcode_into_libs=yes
2452 ;;
2453
2454 # No shared lib support for Linux oldld, aout, or coff.
2455 linux*oldld* | linux*aout* | linux*coff*)
2456 dynamic_linker=no
2457 ;;
2458
2459 # This must be Linux ELF.
2460 linux* | k*bsd*-gnu)
2461 version_type=linux
2462 need_lib_prefix=no
2463 need_version=no
2464 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2465 soname_spec='${libname}${release}${shared_ext}$major'
2466 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
2467 shlibpath_var=LD_LIBRARY_PATH
2468 shlibpath_overrides_runpath=no
2469 # Some binutils ld are patched to set DT_RUNPATH
2470 save_LDFLAGS=$LDFLAGS
2471 save_libdir=$libdir
2472 eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
2473 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
2474 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2475 [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
2476 [shlibpath_overrides_runpath=yes])])
2477 LDFLAGS=$save_LDFLAGS
2478 libdir=$save_libdir
2479
2480 # This implies no fast_install, which is unacceptable.
2481 # Some rework will be needed to allow for fast_install
2482 # before this can be enabled.
2483 hardcode_into_libs=yes
2484
2485 # Append ld.so.conf contents to the search path
2486 if test -f /etc/ld.so.conf; then
2487 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' ' '`
2488 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
2489 fi
2490
2491 # We used to test for /lib/ld.so.1 and disable shared libraries on
2492 # powerpc, because MkLinux only supported shared libraries with the
2493 # GNU dynamic linker. Since this was broken with cross compilers,
2494 # most powerpc-linux boxes support dynamic linking these days and
2495 # people can always --disable-shared, the test was removed, and we
2496 # assume the GNU/Linux dynamic linker is in use.
2497 dynamic_linker='GNU/Linux ld.so'
2498 ;;
2499
2500 netbsd*)
2501 version_type=sunos
2502 need_lib_prefix=no
2503 need_version=no
2504 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
2505 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2506 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2507 dynamic_linker='NetBSD (a.out) ld.so'
2508 else
2509 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2510 soname_spec='${libname}${release}${shared_ext}$major'
2511 dynamic_linker='NetBSD ld.elf_so'
2512 fi
2513 shlibpath_var=LD_LIBRARY_PATH
2514 shlibpath_overrides_runpath=yes
2515 hardcode_into_libs=yes
2516 ;;
2517
2518 newsos6)
2519 version_type=linux
2520 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2521 shlibpath_var=LD_LIBRARY_PATH
2522 shlibpath_overrides_runpath=yes
2523 ;;
2524
2525 *nto* | *qnx*)
2526 version_type=qnx
2527 need_lib_prefix=no
2528 need_version=no
2529 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2530 soname_spec='${libname}${release}${shared_ext}$major'
2531 shlibpath_var=LD_LIBRARY_PATH
2532 shlibpath_overrides_runpath=no
2533 hardcode_into_libs=yes
2534 dynamic_linker='ldqnx.so'
2535 ;;
2536
2537 openbsd*)
2538 version_type=sunos
2539 sys_lib_dlsearch_path_spec="/usr/lib"
2540 need_lib_prefix=no
2541 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
2542 case $host_os in
2543 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
2544 *) need_version=no ;;
2545 esac
2546 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2547 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2548 shlibpath_var=LD_LIBRARY_PATH
2549 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
2550 case $host_os in
2551 openbsd2.[[89]] | openbsd2.[[89]].*)
2552 shlibpath_overrides_runpath=no
2553 ;;
2554 *)
2555 shlibpath_overrides_runpath=yes
2556 ;;
2557 esac
2558 else
2559 shlibpath_overrides_runpath=yes
2560 fi
2561 ;;
2562
2563 os2*)
2564 libname_spec='$name'
2565 shrext_cmds=".dll"
2566 need_lib_prefix=no
2567 library_names_spec='$libname${shared_ext} $libname.a'
2568 dynamic_linker='OS/2 ld.exe'
2569 shlibpath_var=LIBPATH
2570 ;;
2571
2572 osf3* | osf4* | osf5*)
2573 version_type=osf
2574 need_lib_prefix=no
2575 need_version=no
2576 soname_spec='${libname}${release}${shared_ext}$major'
2577 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2578 shlibpath_var=LD_LIBRARY_PATH
2579 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
2580 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
2581 ;;
2582
2583 rdos*)
2584 dynamic_linker=no
2585 ;;
2586
2587 solaris*)
2588 version_type=linux
2589 need_lib_prefix=no
2590 need_version=no
2591 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2592 soname_spec='${libname}${release}${shared_ext}$major'
2593 shlibpath_var=LD_LIBRARY_PATH
2594 shlibpath_overrides_runpath=yes
2595 hardcode_into_libs=yes
2596 # ldd complains unless libraries are executable
2597 postinstall_cmds='chmod +x $lib'
2598 ;;
2599
2600 sunos4*)
2601 version_type=sunos
2602 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2603 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
2604 shlibpath_var=LD_LIBRARY_PATH
2605 shlibpath_overrides_runpath=yes
2606 if test "$with_gnu_ld" = yes; then
2607 need_lib_prefix=no
2608 fi
2609 need_version=yes
2610 ;;
2611
2612 sysv4 | sysv4.3*)
2613 version_type=linux
2614 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2615 soname_spec='${libname}${release}${shared_ext}$major'
2616 shlibpath_var=LD_LIBRARY_PATH
2617 case $host_vendor in
2618 sni)
2619 shlibpath_overrides_runpath=no
2620 need_lib_prefix=no
2621 runpath_var=LD_RUN_PATH
2622 ;;
2623 siemens)
2624 need_lib_prefix=no
2625 ;;
2626 motorola)
2627 need_lib_prefix=no
2628 need_version=no
2629 shlibpath_overrides_runpath=no
2630 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
2631 ;;
2632 esac
2633 ;;
2634
2635 sysv4*MP*)
2636 if test -d /usr/nec ;then
2637 version_type=linux
2638 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
2639 soname_spec='$libname${shared_ext}.$major'
2640 shlibpath_var=LD_LIBRARY_PATH
2641 fi
2642 ;;
2643
2644 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
2645 version_type=freebsd-elf
2646 need_lib_prefix=no
2647 need_version=no
2648 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2649 soname_spec='${libname}${release}${shared_ext}$major'
2650 shlibpath_var=LD_LIBRARY_PATH
2651 shlibpath_overrides_runpath=yes
2652 hardcode_into_libs=yes
2653 if test "$with_gnu_ld" = yes; then
2654 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
2655 else
2656 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
2657 case $host_os in
2658 sco3.2v5*)
2659 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
2660 ;;
2661 esac
2662 fi
2663 sys_lib_dlsearch_path_spec='/usr/lib'
2664 ;;
2665
2666 tpf*)
2667 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
2668 version_type=linux
2669 need_lib_prefix=no
2670 need_version=no
2671 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2672 shlibpath_var=LD_LIBRARY_PATH
2673 shlibpath_overrides_runpath=no
2674 hardcode_into_libs=yes
2675 ;;
2676
2677 uts4*)
2678 version_type=linux
2679 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2680 soname_spec='${libname}${release}${shared_ext}$major'
2681 shlibpath_var=LD_LIBRARY_PATH
2682 ;;
2683
2684 *)
2685 dynamic_linker=no
2686 ;;
2687 esac
2688 AC_MSG_RESULT([$dynamic_linker])
2689 test "$dynamic_linker" = no && can_build_shared=no
2690
2691 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
2692 if test "$GCC" = yes; then
2693 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
2694 fi
2695
2696 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
2697 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
2698 fi
2699 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
2700 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
2701 fi
2702
2703 _LT_DECL([], [variables_saved_for_relink], [1],
2704 [Variables whose values should be saved in libtool wrapper scripts and
2705 restored at link time])
2706 _LT_DECL([], [need_lib_prefix], [0],
2707 [Do we need the "lib" prefix for modules?])
2708 _LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
2709 _LT_DECL([], [version_type], [0], [Library versioning type])
2710 _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
2711 _LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
2712 _LT_DECL([], [shlibpath_overrides_runpath], [0],
2713 [Is shlibpath searched before the hard-coded library search path?])
2714 _LT_DECL([], [libname_spec], [1], [Format of library name prefix])
2715 _LT_DECL([], [library_names_spec], [1],
2716 [[List of archive names. First name is the real one, the rest are links.
2717 The last name is the one that the linker finds with -lNAME]])
2718 _LT_DECL([], [soname_spec], [1],
2719 [[The coded name of the library, if different from the real name]])
2720 _LT_DECL([], [postinstall_cmds], [2],
2721 [Command to use after installation of a shared archive])
2722 _LT_DECL([], [postuninstall_cmds], [2],
2723 [Command to use after uninstallation of a shared archive])
2724 _LT_DECL([], [finish_cmds], [2],
2725 [Commands used to finish a libtool library installation in a directory])
2726 _LT_DECL([], [finish_eval], [1],
2727 [[As "finish_cmds", except a single script fragment to be evaled but
2728 not shown]])
2729 _LT_DECL([], [hardcode_into_libs], [0],
2730 [Whether we should hardcode library paths into libraries])
2731 _LT_DECL([], [sys_lib_search_path_spec], [2],
2732 [Compile-time system search path for libraries])
2733 _LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
2734 [Run-time system search path for libraries])
2735 ])# _LT_SYS_DYNAMIC_LINKER
2736
2737
2738 # _LT_PATH_TOOL_PREFIX(TOOL)
2739 # --------------------------
2740 # find a file program which can recognize shared library
2741 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
2742 [m4_require([_LT_DECL_EGREP])dnl
2743 AC_MSG_CHECKING([for $1])
2744 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
2745 [case $MAGIC_CMD in
2746 [[\\/*] | ?:[\\/]*])
2747 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
2748 ;;
2749 *)
2750 lt_save_MAGIC_CMD="$MAGIC_CMD"
2751 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2752 dnl $ac_dummy forces splitting on constant user-supplied paths.
2753 dnl POSIX.2 word splitting is done only on the output of word expansions,
2754 dnl not every word. This closes a longstanding sh security hole.
2755 ac_dummy="m4_if([$2], , $PATH, [$2])"
2756 for ac_dir in $ac_dummy; do
2757 IFS="$lt_save_ifs"
2758 test -z "$ac_dir" && ac_dir=.
2759 if test -f $ac_dir/$1; then
2760 lt_cv_path_MAGIC_CMD="$ac_dir/$1"
2761 if test -n "$file_magic_test_file"; then
2762 case $deplibs_check_method in
2763 "file_magic "*)
2764 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
2765 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2766 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
2767 $EGREP "$file_magic_regex" > /dev/null; then
2768 :
2769 else
2770 cat <<_LT_EOF 1>&2
2771
2772 *** Warning: the command libtool uses to detect shared libraries,
2773 *** $file_magic_cmd, produces output that libtool cannot recognize.
2774 *** The result is that libtool may fail to recognize shared libraries
2775 *** as such. This will affect the creation of libtool libraries that
2776 *** depend on shared libraries, but programs linked with such libtool
2777 *** libraries will work regardless of this problem. Nevertheless, you
2778 *** may want to report the problem to your system manager and/or to
2779 *** bug-libtool@gnu.org
2780
2781 _LT_EOF
2782 fi ;;
2783 esac
2784 fi
2785 break
2786 fi
2787 done
2788 IFS="$lt_save_ifs"
2789 MAGIC_CMD="$lt_save_MAGIC_CMD"
2790 ;;
2791 esac])
2792 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2793 if test -n "$MAGIC_CMD"; then
2794 AC_MSG_RESULT($MAGIC_CMD)
2795 else
2796 AC_MSG_RESULT(no)
2797 fi
2798 _LT_DECL([], [MAGIC_CMD], [0],
2799 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
2800 ])# _LT_PATH_TOOL_PREFIX
2801
2802 # Old name:
2803 AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
2804 dnl aclocal-1.4 backwards compatibility:
2805 dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
2806
2807
2808 # _LT_PATH_MAGIC
2809 # --------------
2810 # find a file program which can recognize a shared library
2811 m4_defun([_LT_PATH_MAGIC],
2812 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
2813 if test -z "$lt_cv_path_MAGIC_CMD"; then
2814 if test -n "$ac_tool_prefix"; then
2815 _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
2816 else
2817 MAGIC_CMD=:
2818 fi
2819 fi
2820 ])# _LT_PATH_MAGIC
2821
2822
2823 # LT_PATH_LD
2824 # ----------
2825 # find the pathname to the GNU or non-GNU linker
2826 AC_DEFUN([LT_PATH_LD],
2827 [AC_REQUIRE([AC_PROG_CC])dnl
2828 AC_REQUIRE([AC_CANONICAL_HOST])dnl
2829 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
2830 m4_require([_LT_DECL_SED])dnl
2831 m4_require([_LT_DECL_EGREP])dnl
2832
2833 AC_ARG_WITH([gnu-ld],
2834 [AS_HELP_STRING([--with-gnu-ld],
2835 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
2836 [test "$withval" = no || with_gnu_ld=yes],
2837 [with_gnu_ld=no])dnl
2838
2839 ac_prog=ld
2840 if test "$GCC" = yes; then
2841 # Check if gcc -print-prog-name=ld gives a path.
2842 AC_MSG_CHECKING([for ld used by $CC])
2843 case $host in
2844 *-*-mingw*)
2845 # gcc leaves a trailing carriage return which upsets mingw
2846 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2847 *)
2848 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
2849 esac
2850 case $ac_prog in
2851 # Accept absolute paths.
2852 [[\\/]]* | ?:[[\\/]]*)
2853 re_direlt='/[[^/]][[^/]]*/\.\./'
2854 # Canonicalize the pathname of ld
2855 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
2856 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
2857 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
2858 done
2859 test -z "$LD" && LD="$ac_prog"
2860 ;;
2861 "")
2862 # If it fails, then pretend we aren't using GCC.
2863 ac_prog=ld
2864 ;;
2865 *)
2866 # If it is relative, then search for the first ld in PATH.
2867 with_gnu_ld=unknown
2868 ;;
2869 esac
2870 elif test "$with_gnu_ld" = yes; then
2871 AC_MSG_CHECKING([for GNU ld])
2872 else
2873 AC_MSG_CHECKING([for non-GNU ld])
2874 fi
2875 AC_CACHE_VAL(lt_cv_path_LD,
2876 [if test -z "$LD"; then
2877 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2878 for ac_dir in $PATH; do
2879 IFS="$lt_save_ifs"
2880 test -z "$ac_dir" && ac_dir=.
2881 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2882 lt_cv_path_LD="$ac_dir/$ac_prog"
2883 # Check to see if the program is GNU ld. I'd rather use --version,
2884 # but apparently some variants of GNU ld only accept -v.
2885 # Break only if it was the GNU/non-GNU ld that we prefer.
2886 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
2887 *GNU* | *'with BFD'*)
2888 test "$with_gnu_ld" != no && break
2889 ;;
2890 *)
2891 test "$with_gnu_ld" != yes && break
2892 ;;
2893 esac
2894 fi
2895 done
2896 IFS="$lt_save_ifs"
2897 else
2898 lt_cv_path_LD="$LD" # Let the user override the test with a path.
2899 fi])
2900 LD="$lt_cv_path_LD"
2901 if test -n "$LD"; then
2902 AC_MSG_RESULT($LD)
2903 else
2904 AC_MSG_RESULT(no)
2905 fi
2906 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
2907 _LT_PATH_LD_GNU
2908 AC_SUBST([LD])
2909
2910 _LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
2911 ])# LT_PATH_LD
2912
2913 # Old names:
2914 AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
2915 AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
2916 dnl aclocal-1.4 backwards compatibility:
2917 dnl AC_DEFUN([AM_PROG_LD], [])
2918 dnl AC_DEFUN([AC_PROG_LD], [])
2919
2920
2921 # _LT_PATH_LD_GNU
2922 #- --------------
2923 m4_defun([_LT_PATH_LD_GNU],
2924 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
2925 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
2926 case `$LD -v 2>&1 </dev/null` in
2927 *GNU* | *'with BFD'*)
2928 lt_cv_prog_gnu_ld=yes
2929 ;;
2930 *)
2931 lt_cv_prog_gnu_ld=no
2932 ;;
2933 esac])
2934 with_gnu_ld=$lt_cv_prog_gnu_ld
2935 ])# _LT_PATH_LD_GNU
2936
2937
2938 # _LT_CMD_RELOAD
2939 # --------------
2940 # find reload flag for linker
2941 # -- PORTME Some linkers may need a different reload flag.
2942 m4_defun([_LT_CMD_RELOAD],
2943 [AC_CACHE_CHECK([for $LD option to reload object files],
2944 lt_cv_ld_reload_flag,
2945 [lt_cv_ld_reload_flag='-r'])
2946 reload_flag=$lt_cv_ld_reload_flag
2947 case $reload_flag in
2948 "" | " "*) ;;
2949 *) reload_flag=" $reload_flag" ;;
2950 esac
2951 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2952 case $host_os in
2953 darwin*)
2954 if test "$GCC" = yes; then
2955 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
2956 else
2957 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2958 fi
2959 ;;
2960 esac
2961 _LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
2962 _LT_DECL([], [reload_cmds], [2])dnl
2963 ])# _LT_CMD_RELOAD
2964
2965
2966 # _LT_CHECK_MAGIC_METHOD
2967 # ----------------------
2968 # how to check for library dependencies
2969 # -- PORTME fill in with the dynamic library characteristics
2970 m4_defun([_LT_CHECK_MAGIC_METHOD],
2971 [m4_require([_LT_DECL_EGREP])
2972 m4_require([_LT_DECL_OBJDUMP])
2973 AC_CACHE_CHECK([how to recognize dependent libraries],
2974 lt_cv_deplibs_check_method,
2975 [lt_cv_file_magic_cmd='$MAGIC_CMD'
2976 lt_cv_file_magic_test_file=
2977 lt_cv_deplibs_check_method='unknown'
2978 # Need to set the preceding variable on all platforms that support
2979 # interlibrary dependencies.
2980 # 'none' -- dependencies not supported.
2981 # `unknown' -- same as none, but documents that we really don't know.
2982 # 'pass_all' -- all dependencies passed with no checks.
2983 # 'test_compile' -- check by making test program.
2984 # 'file_magic [[regex]]' -- check by looking for files in library path
2985 # which responds to the $file_magic_cmd with a given extended regex.
2986 # If you have `file' or equivalent on your system and you're not sure
2987 # whether `pass_all' will *always* work, you probably want this one.
2988
2989 case $host_os in
2990 aix[[4-9]]*)
2991 lt_cv_deplibs_check_method=pass_all
2992 ;;
2993
2994 beos*)
2995 lt_cv_deplibs_check_method=pass_all
2996 ;;
2997
2998 bsdi[[45]]*)
2999 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
3000 lt_cv_file_magic_cmd='/usr/bin/file -L'
3001 lt_cv_file_magic_test_file=/shlib/libc.so
3002 ;;
3003
3004 cygwin*)
3005 # func_win32_libid is a shell function defined in ltmain.sh
3006 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3007 lt_cv_deplibs_check_method=pass_all
3008 lt_cv_file_magic_cmd='func_win32_libid'
3009 ;;
3010
3011 mingw* | pw32*)
3012 # Base MSYS/MinGW do not provide the 'file' command needed by
3013 # func_win32_libid shell function, so use a weaker test based on 'objdump',
3014 # unless we find 'file', for example because we are cross-compiling.
3015 if ( file / ) >/dev/null 2>&1; then
3016 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3017 lt_cv_file_magic_cmd='func_win32_libid'
3018 else
3019 lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
3020 lt_cv_file_magic_cmd='$OBJDUMP -f'
3021 fi
3022 lt_cv_deplibs_check_method=pass_all
3023 ;;
3024
3025 cegcc)
3026 # use the weaker test based on 'objdump'. See mingw*.
3027 lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
3028 lt_cv_file_magic_cmd='$OBJDUMP -f'
3029 ;;
3030
3031 darwin* | rhapsody*)
3032 lt_cv_deplibs_check_method=pass_all
3033 ;;
3034
3035 freebsd* | dragonfly*)
3036 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3037 case $host_cpu in
3038 i*86 )
3039 # Not sure whether the presence of OpenBSD here was a mistake.
3040 # Let's accept both of them until this is cleared up.
3041 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
3042 lt_cv_file_magic_cmd=/usr/bin/file
3043 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
3044 ;;
3045 esac
3046 else
3047 lt_cv_deplibs_check_method=pass_all
3048 fi
3049 ;;
3050
3051 gnu*)
3052 lt_cv_deplibs_check_method=pass_all
3053 ;;
3054
3055 hpux10.20* | hpux11*)
3056 lt_cv_file_magic_cmd=/usr/bin/file
3057 case $host_cpu in
3058 ia64*)
3059 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
3060 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
3061 ;;
3062 hppa*64*)
3063 [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]']
3064 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
3065 ;;
3066 *)
3067 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
3068 lt_cv_file_magic_test_file=/usr/lib/libc.sl
3069 ;;
3070 esac
3071 ;;
3072
3073 interix[[3-9]]*)
3074 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
3075 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
3076 ;;
3077
3078 irix5* | irix6* | nonstopux*)
3079 case $LD in
3080 *-32|*"-32 ") libmagic=32-bit;;
3081 *-n32|*"-n32 ") libmagic=N32;;
3082 *-64|*"-64 ") libmagic=64-bit;;
3083 *) libmagic=never-match;;
3084 esac
3085 lt_cv_deplibs_check_method=pass_all
3086 ;;
3087
3088 # This must be Linux ELF.
3089 linux* | k*bsd*-gnu)
3090 lt_cv_deplibs_check_method=pass_all
3091 ;;
3092
3093 netbsd*)
3094 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3095 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3096 else
3097 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
3098 fi
3099 ;;
3100
3101 newos6*)
3102 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
3103 lt_cv_file_magic_cmd=/usr/bin/file
3104 lt_cv_file_magic_test_file=/usr/lib/libnls.so
3105 ;;
3106
3107 *nto* | *qnx*)
3108 lt_cv_deplibs_check_method=pass_all
3109 ;;
3110
3111 openbsd*)
3112 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
3113 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
3114 else
3115 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3116 fi
3117 ;;
3118
3119 osf3* | osf4* | osf5*)
3120 lt_cv_deplibs_check_method=pass_all
3121 ;;
3122
3123 rdos*)
3124 lt_cv_deplibs_check_method=pass_all
3125 ;;
3126
3127 solaris*)
3128 lt_cv_deplibs_check_method=pass_all
3129 ;;
3130
3131 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
3132 lt_cv_deplibs_check_method=pass_all
3133 ;;
3134
3135 sysv4 | sysv4.3*)
3136 case $host_vendor in
3137 motorola)
3138 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]]'
3139 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
3140 ;;
3141 ncr)
3142 lt_cv_deplibs_check_method=pass_all
3143 ;;
3144 sequent)
3145 lt_cv_file_magic_cmd='/bin/file'
3146 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
3147 ;;
3148 sni)
3149 lt_cv_file_magic_cmd='/bin/file'
3150 lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
3151 lt_cv_file_magic_test_file=/lib/libc.so
3152 ;;
3153 siemens)
3154 lt_cv_deplibs_check_method=pass_all
3155 ;;
3156 pc)
3157 lt_cv_deplibs_check_method=pass_all
3158 ;;
3159 esac
3160 ;;
3161
3162 tpf*)
3163 lt_cv_deplibs_check_method=pass_all
3164 ;;
3165 esac
3166 ])
3167 file_magic_cmd=$lt_cv_file_magic_cmd
3168 deplibs_check_method=$lt_cv_deplibs_check_method
3169 test -z "$deplibs_check_method" && deplibs_check_method=unknown
3170
3171 _LT_DECL([], [deplibs_check_method], [1],
3172 [Method to check whether dependent libraries are shared objects])
3173 _LT_DECL([], [file_magic_cmd], [1],
3174 [Command to use when deplibs_check_method == "file_magic"])
3175 ])# _LT_CHECK_MAGIC_METHOD
3176
3177
3178 # LT_PATH_NM
3179 # ----------
3180 # find the pathname to a BSD- or MS-compatible name lister
3181 AC_DEFUN([LT_PATH_NM],
3182 [AC_REQUIRE([AC_PROG_CC])dnl
3183 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
3184 [if test -n "$NM"; then
3185 # Let the user override the test.
3186 lt_cv_path_NM="$NM"
3187 else
3188 lt_nm_to_check="${ac_tool_prefix}nm"
3189 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
3190 lt_nm_to_check="$lt_nm_to_check nm"
3191 fi
3192 for lt_tmp_nm in $lt_nm_to_check; do
3193 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3194 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
3195 IFS="$lt_save_ifs"
3196 test -z "$ac_dir" && ac_dir=.
3197 tmp_nm="$ac_dir/$lt_tmp_nm"
3198 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
3199 # Check to see if the nm accepts a BSD-compat flag.
3200 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
3201 # nm: unknown option "B" ignored
3202 # Tru64's nm complains that /dev/null is an invalid object file
3203 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
3204 */dev/null* | *'Invalid file or object type'*)
3205 lt_cv_path_NM="$tmp_nm -B"
3206 break
3207 ;;
3208 *)
3209 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
3210 */dev/null*)
3211 lt_cv_path_NM="$tmp_nm -p"
3212 break
3213 ;;
3214 *)
3215 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
3216 continue # so that we can try to find one that supports BSD flags
3217 ;;
3218 esac
3219 ;;
3220 esac
3221 fi
3222 done
3223 IFS="$lt_save_ifs"
3224 done
3225 : ${lt_cv_path_NM=no}
3226 fi])
3227 if test "$lt_cv_path_NM" != "no"; then
3228 NM="$lt_cv_path_NM"
3229 else
3230 # Didn't find any BSD compatible name lister, look for dumpbin.
3231 AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
3232 AC_SUBST([DUMPBIN])
3233 if test "$DUMPBIN" != ":"; then
3234 NM="$DUMPBIN"
3235 fi
3236 fi
3237 test -z "$NM" && NM=nm
3238 AC_SUBST([NM])
3239 _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
3240
3241 AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
3242 [lt_cv_nm_interface="BSD nm"
3243 echo "int some_variable = 0;" > conftest.$ac_ext
3244 (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
3245 (eval "$ac_compile" 2>conftest.err)
3246 cat conftest.err >&AS_MESSAGE_LOG_FD
3247 (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
3248 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
3249 cat conftest.err >&AS_MESSAGE_LOG_FD
3250 (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
3251 cat conftest.out >&AS_MESSAGE_LOG_FD
3252 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
3253 lt_cv_nm_interface="MS dumpbin"
3254 fi
3255 rm -f conftest*])
3256 ])# LT_PATH_NM
3257
3258 # Old names:
3259 AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
3260 AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
3261 dnl aclocal-1.4 backwards compatibility:
3262 dnl AC_DEFUN([AM_PROG_NM], [])
3263 dnl AC_DEFUN([AC_PROG_NM], [])
3264
3265
3266 # LT_LIB_M
3267 # --------
3268 # check for math library
3269 AC_DEFUN([LT_LIB_M],
3270 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3271 LIBM=
3272 case $host in
3273 *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
3274 # These system don't have libm, or don't need it
3275 ;;
3276 *-ncr-sysv4.3*)
3277 AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
3278 AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
3279 ;;
3280 *)
3281 AC_CHECK_LIB(m, cos, LIBM="-lm")
3282 ;;
3283 esac
3284 AC_SUBST([LIBM])
3285 ])# LT_LIB_M
3286
3287 # Old name:
3288 AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
3289 dnl aclocal-1.4 backwards compatibility:
3290 dnl AC_DEFUN([AC_CHECK_LIBM], [])
3291
3292
3293 # _LT_COMPILER_NO_RTTI([TAGNAME])
3294 # -------------------------------
3295 m4_defun([_LT_COMPILER_NO_RTTI],
3296 [m4_require([_LT_TAG_COMPILER])dnl
3297
3298 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
3299
3300 if test "$GCC" = yes; then
3301 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
3302
3303 _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
3304 lt_cv_prog_compiler_rtti_exceptions,
3305 [-fno-rtti -fno-exceptions], [],
3306 [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
3307 fi
3308 _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
3309 [Compiler flag to turn off builtin functions])
3310 ])# _LT_COMPILER_NO_RTTI
3311
3312
3313 # _LT_CMD_GLOBAL_SYMBOLS
3314 # ----------------------
3315 m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
3316 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3317 AC_REQUIRE([AC_PROG_CC])dnl
3318 AC_REQUIRE([LT_PATH_NM])dnl
3319 AC_REQUIRE([LT_PATH_LD])dnl
3320 m4_require([_LT_DECL_SED])dnl
3321 m4_require([_LT_DECL_EGREP])dnl
3322 m4_require([_LT_TAG_COMPILER])dnl
3323
3324 # Check for command to grab the raw symbol name followed by C symbol from nm.
3325 AC_MSG_CHECKING([command to parse $NM output from $compiler object])
3326 AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
3327 [
3328 # These are sane defaults that work on at least a few old systems.
3329 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
3330
3331 # Character class describing NM global symbol codes.
3332 symcode='[[BCDEGRST]]'
3333
3334 # Regexp to match symbols that can be accessed directly from C.
3335 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
3336
3337 # Define system-specific variables.
3338 case $host_os in
3339 aix*)
3340 symcode='[[BCDT]]'
3341 ;;
3342 cygwin* | mingw* | pw32* | cegcc*)
3343 symcode='[[ABCDGISTW]]'
3344 ;;
3345 hpux*)
3346 if test "$host_cpu" = ia64; then
3347 symcode='[[ABCDEGRST]]'
3348 fi
3349 ;;
3350 irix* | nonstopux*)
3351 symcode='[[BCDEGRST]]'
3352 ;;
3353 osf*)
3354 symcode='[[BCDEGQRST]]'
3355 ;;
3356 solaris*)
3357 symcode='[[BDRT]]'
3358 ;;
3359 sco3.2v5*)
3360 symcode='[[DT]]'
3361 ;;
3362 sysv4.2uw2*)
3363 symcode='[[DT]]'
3364 ;;
3365 sysv5* | sco5v6* | unixware* | OpenUNIX*)
3366 symcode='[[ABDT]]'
3367 ;;
3368 sysv4)
3369 symcode='[[DFNSTU]]'
3370 ;;
3371 esac
3372
3373 # If we're using GNU nm, then use its standard symbol codes.
3374 case `$NM -V 2>&1` in
3375 *GNU* | *'with BFD'*)
3376 symcode='[[ABCDGIRSTW]]' ;;
3377 esac
3378
3379 # Transform an extracted symbol line into a proper C declaration.
3380 # Some systems (esp. on ia64) link data and code symbols differently,
3381 # so use this general approach.
3382 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
3383
3384 # Transform an extracted symbol line into symbol name and symbol address
3385 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
3386 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'"
3387
3388 # Handle CRLF in mingw tool chain
3389 opt_cr=
3390 case $build_os in
3391 mingw*)
3392 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
3393 ;;
3394 esac
3395
3396 # Try without a prefix underscore, then with it.
3397 for ac_symprfx in "" "_"; do
3398
3399 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
3400 symxfrm="\\1 $ac_symprfx\\2 \\2"
3401
3402 # Write the raw and C identifiers.
3403 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
3404 # Fake it for dumpbin and say T for any non-static function
3405 # and D for any global variable.
3406 # Also find C++ and __fastcall symbols from MSVC++,
3407 # which start with @ or ?.
3408 lt_cv_sys_global_symbol_pipe="$AWK ['"\
3409 " {last_section=section; section=\$ 3};"\
3410 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
3411 " \$ 0!~/External *\|/{next};"\
3412 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
3413 " {if(hide[section]) next};"\
3414 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
3415 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
3416 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
3417 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
3418 " ' prfx=^$ac_symprfx]"
3419 else
3420 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
3421 fi
3422
3423 # Check to see that the pipe works correctly.
3424 pipe_works=no
3425
3426 rm -f conftest*
3427 cat > conftest.$ac_ext <<_LT_EOF
3428 #ifdef __cplusplus
3429 extern "C" {
3430 #endif
3431 char nm_test_var;
3432 void nm_test_func(void);
3433 void nm_test_func(void){}
3434 #ifdef __cplusplus
3435 }
3436 #endif
3437 int main(){nm_test_var='a';nm_test_func();return(0);}
3438 _LT_EOF
3439
3440 if AC_TRY_EVAL(ac_compile); then
3441 # Now try to grab the symbols.
3442 nlist=conftest.nm
3443 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
3444 # Try sorting and uniquifying the output.
3445 if sort "$nlist" | uniq > "$nlist"T; then
3446 mv -f "$nlist"T "$nlist"
3447 else
3448 rm -f "$nlist"T
3449 fi
3450
3451 # Make sure that we snagged all the symbols we need.
3452 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
3453 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
3454 cat <<_LT_EOF > conftest.$ac_ext
3455 #ifdef __cplusplus
3456 extern "C" {
3457 #endif
3458
3459 _LT_EOF
3460 # Now generate the symbol file.
3461 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
3462
3463 cat <<_LT_EOF >> conftest.$ac_ext
3464
3465 /* The mapping between symbol names and symbols. */
3466 const struct {
3467 const char *name;
3468 void *address;
3469 }
3470 lt__PROGRAM__LTX_preloaded_symbols[[]] =
3471 {
3472 { "@PROGRAM@", (void *) 0 },
3473 _LT_EOF
3474 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
3475 cat <<\_LT_EOF >> conftest.$ac_ext
3476 {0, (void *) 0}
3477 };
3478
3479 /* This works around a problem in FreeBSD linker */
3480 #ifdef FREEBSD_WORKAROUND
3481 static const void *lt_preloaded_setup() {
3482 return lt__PROGRAM__LTX_preloaded_symbols;
3483 }
3484 #endif
3485
3486 #ifdef __cplusplus
3487 }
3488 #endif
3489 _LT_EOF
3490 # Now try linking the two files.
3491 mv conftest.$ac_objext conftstm.$ac_objext
3492 lt_save_LIBS="$LIBS"
3493 lt_save_CFLAGS="$CFLAGS"
3494 LIBS="conftstm.$ac_objext"
3495 CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
3496 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
3497 pipe_works=yes
3498 fi
3499 LIBS="$lt_save_LIBS"
3500 CFLAGS="$lt_save_CFLAGS"
3501 else
3502 echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
3503 fi
3504 else
3505 echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
3506 fi
3507 else
3508 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
3509 fi
3510 else
3511 echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
3512 cat conftest.$ac_ext >&5
3513 fi
3514 rm -rf conftest* conftst*
3515
3516 # Do not use the global_symbol_pipe unless it works.
3517 if test "$pipe_works" = yes; then
3518 break
3519 else
3520 lt_cv_sys_global_symbol_pipe=
3521 fi
3522 done
3523 ])
3524 if test -z "$lt_cv_sys_global_symbol_pipe"; then
3525 lt_cv_sys_global_symbol_to_cdecl=
3526 fi
3527 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
3528 AC_MSG_RESULT(failed)
3529 else
3530 AC_MSG_RESULT(ok)
3531 fi
3532
3533 _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
3534 [Take the output of nm and produce a listing of raw symbols and C names])
3535 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
3536 [Transform the output of nm in a proper C declaration])
3537 _LT_DECL([global_symbol_to_c_name_address],
3538 [lt_cv_sys_global_symbol_to_c_name_address], [1],
3539 [Transform the output of nm in a C name address pair])
3540 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
3541 [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
3542 [Transform the output of nm in a C name address pair when lib prefix is needed])
3543 ]) # _LT_CMD_GLOBAL_SYMBOLS
3544
3545
3546 # _LT_COMPILER_PIC([TAGNAME])
3547 # ---------------------------
3548 m4_defun([_LT_COMPILER_PIC],
3549 [m4_require([_LT_TAG_COMPILER])dnl
3550 _LT_TAGVAR(lt_prog_compiler_wl, $1)=
3551 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3552 _LT_TAGVAR(lt_prog_compiler_static, $1)=
3553
3554 AC_MSG_CHECKING([for $compiler option to produce PIC])
3555 m4_if([$1], [CXX], [
3556 # C++ specific cases for pic, static, wl, etc.
3557 if test "$GXX" = yes; then
3558 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3559 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3560
3561 case $host_os in
3562 aix*)
3563 # All AIX code is PIC.
3564 if test "$host_cpu" = ia64; then
3565 # AIX 5 now supports IA64 processor
3566 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3567 fi
3568 ;;
3569
3570 amigaos*)
3571 case $host_cpu in
3572 powerpc)
3573 # see comment about AmigaOS4 .so support
3574 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3575 ;;
3576 m68k)
3577 # FIXME: we need at least 68020 code to build shared libraries, but
3578 # adding the `-m68020' flag to GCC prevents building anything better,
3579 # like `-m68040'.
3580 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3581 ;;
3582 esac
3583 ;;
3584
3585 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3586 # PIC is the default for these OSes.
3587 ;;
3588 mingw* | cygwin* | os2* | pw32* | cegcc*)
3589 # This hack is so that the source file can tell whether it is being
3590 # built for inclusion in a dll (and should export symbols for example).
3591 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3592 # (--disable-auto-import) libraries
3593 m4_if([$1], [GCJ], [],
3594 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3595 ;;
3596 darwin* | rhapsody*)
3597 # PIC is the default on this platform
3598 # Common symbols not allowed in MH_DYLIB files
3599 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3600 ;;
3601 *djgpp*)
3602 # DJGPP does not support shared libraries at all
3603 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3604 ;;
3605 interix[[3-9]]*)
3606 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3607 # Instead, we relocate shared libraries at runtime.
3608 ;;
3609 sysv4*MP*)
3610 if test -d /usr/nec; then
3611 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3612 fi
3613 ;;
3614 hpux*)
3615 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
3616 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
3617 # sets the default TLS model and affects inlining.
3618 case $host_cpu in
3619 hppa*64*)
3620 ;;
3621 *)
3622 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3623 ;;
3624 esac
3625 ;;
3626 *qnx* | *nto*)
3627 # QNX uses GNU C++, but need to define -shared option too, otherwise
3628 # it will coredump.
3629 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3630 ;;
3631 *)
3632 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3633 ;;
3634 esac
3635 else
3636 case $host_os in
3637 aix[[4-9]]*)
3638 # All AIX code is PIC.
3639 if test "$host_cpu" = ia64; then
3640 # AIX 5 now supports IA64 processor
3641 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3642 else
3643 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3644 fi
3645 ;;
3646 chorus*)
3647 case $cc_basename in
3648 cxch68*)
3649 # Green Hills C++ Compiler
3650 # _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"
3651 ;;
3652 esac
3653 ;;
3654 dgux*)
3655 case $cc_basename in
3656 ec++*)
3657 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3658 ;;
3659 ghcx*)
3660 # Green Hills C++ Compiler
3661 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3662 ;;
3663 *)
3664 ;;
3665 esac
3666 ;;
3667 freebsd* | dragonfly*)
3668 # FreeBSD uses GNU C++
3669 ;;
3670 hpux9* | hpux10* | hpux11*)
3671 case $cc_basename in
3672 CC*)
3673 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3674 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3675 if test "$host_cpu" != ia64; then
3676 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3677 fi
3678 ;;
3679 aCC*)
3680 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3681 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3682 case $host_cpu in
3683 hppa*64*|ia64*)
3684 # +Z the default
3685 ;;
3686 *)
3687 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3688 ;;
3689 esac
3690 ;;
3691 *)
3692 ;;
3693 esac
3694 ;;
3695 interix*)
3696 # This is c89, which is MS Visual C++ (no shared libs)
3697 # Anyone wants to do a port?
3698 ;;
3699 irix5* | irix6* | nonstopux*)
3700 case $cc_basename in
3701 CC*)
3702 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3703 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3704 # CC pic flag -KPIC is the default.
3705 ;;
3706 *)
3707 ;;
3708 esac
3709 ;;
3710 linux* | k*bsd*-gnu)
3711 case $cc_basename in
3712 KCC*)
3713 # KAI C++ Compiler
3714 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3715 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3716 ;;
3717 ecpc* )
3718 # old Intel C++ for x86_64 which still supported -KPIC.
3719 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3720 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3721 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3722 ;;
3723 icpc* )
3724 # Intel C++, used to be incompatible with GCC.
3725 # ICC 10 doesn't accept -KPIC any more.
3726 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3727 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3728 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3729 ;;
3730 pgCC* | pgcpp*)
3731 # Portland Group C++ compiler
3732 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3733 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
3734 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3735 ;;
3736 cxx*)
3737 # Compaq C++
3738 # Make sure the PIC flag is empty. It appears that all Alpha
3739 # Linux and Compaq Tru64 Unix objects are PIC.
3740 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3741 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3742 ;;
3743 xlc* | xlC*)
3744 # IBM XL 8.0 on PPC
3745 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3746 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
3747 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
3748 ;;
3749 *)
3750 case `$CC -V 2>&1 | sed 5q` in
3751 *Sun\ C*)
3752 # Sun C++ 5.9
3753 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3754 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3755 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3756 ;;
3757 esac
3758 ;;
3759 esac
3760 ;;
3761 lynxos*)
3762 ;;
3763 m88k*)
3764 ;;
3765 mvs*)
3766 case $cc_basename in
3767 cxx*)
3768 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
3769 ;;
3770 *)
3771 ;;
3772 esac
3773 ;;
3774 netbsd*)
3775 ;;
3776 *qnx* | *nto*)
3777 # QNX uses GNU C++, but need to define -shared option too, otherwise
3778 # it will coredump.
3779 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3780 ;;
3781 osf3* | osf4* | osf5*)
3782 case $cc_basename in
3783 KCC*)
3784 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3785 ;;
3786 RCC*)
3787 # Rational C++ 2.4.1
3788 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3789 ;;
3790 cxx*)
3791 # Digital/Compaq C++
3792 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3793 # Make sure the PIC flag is empty. It appears that all Alpha
3794 # Linux and Compaq Tru64 Unix objects are PIC.
3795 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3796 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3797 ;;
3798 *)
3799 ;;
3800 esac
3801 ;;
3802 psos*)
3803 ;;
3804 solaris*)
3805 case $cc_basename in
3806 CC*)
3807 # Sun C++ 4.2, 5.x and Centerline C++
3808 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3809 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3810 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3811 ;;
3812 gcx*)
3813 # Green Hills C++ Compiler
3814 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
3815 ;;
3816 *)
3817 ;;
3818 esac
3819 ;;
3820 sunos4*)
3821 case $cc_basename in
3822 CC*)
3823 # Sun C++ 4.x
3824 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3825 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3826 ;;
3827 lcc*)
3828 # Lucid
3829 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3830 ;;
3831 *)
3832 ;;
3833 esac
3834 ;;
3835 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
3836 case $cc_basename in
3837 CC*)
3838 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3839 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3840 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3841 ;;
3842 esac
3843 ;;
3844 tandem*)
3845 case $cc_basename in
3846 NCC*)
3847 # NonStop-UX NCC 3.20
3848 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3849 ;;
3850 *)
3851 ;;
3852 esac
3853 ;;
3854 vxworks*)
3855 ;;
3856 *)
3857 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3858 ;;
3859 esac
3860 fi
3861 ],
3862 [
3863 if test "$GCC" = yes; then
3864 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3865 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3866
3867 case $host_os in
3868 aix*)
3869 # All AIX code is PIC.
3870 if test "$host_cpu" = ia64; then
3871 # AIX 5 now supports IA64 processor
3872 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3873 fi
3874 ;;
3875
3876 amigaos*)
3877 case $host_cpu in
3878 powerpc)
3879 # see comment about AmigaOS4 .so support
3880 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3881 ;;
3882 m68k)
3883 # FIXME: we need at least 68020 code to build shared libraries, but
3884 # adding the `-m68020' flag to GCC prevents building anything better,
3885 # like `-m68040'.
3886 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3887 ;;
3888 esac
3889 ;;
3890
3891 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3892 # PIC is the default for these OSes.
3893 ;;
3894
3895 mingw* | cygwin* | pw32* | os2* | cegcc*)
3896 # This hack is so that the source file can tell whether it is being
3897 # built for inclusion in a dll (and should export symbols for example).
3898 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3899 # (--disable-auto-import) libraries
3900 m4_if([$1], [GCJ], [],
3901 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3902 ;;
3903
3904 darwin* | rhapsody*)
3905 # PIC is the default on this platform
3906 # Common symbols not allowed in MH_DYLIB files
3907 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3908 ;;
3909
3910 hpux*)
3911 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
3912 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
3913 # sets the default TLS model and affects inlining.
3914 case $host_cpu in
3915 hppa*64*)
3916 # +Z the default
3917 ;;
3918 *)
3919 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3920 ;;
3921 esac
3922 ;;
3923
3924 interix[[3-9]]*)
3925 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3926 # Instead, we relocate shared libraries at runtime.
3927 ;;
3928
3929 msdosdjgpp*)
3930 # Just because we use GCC doesn't mean we suddenly get shared libraries
3931 # on systems that don't support them.
3932 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3933 enable_shared=no
3934 ;;
3935
3936 *nto* | *qnx*)
3937 # QNX uses GNU C++, but need to define -shared option too, otherwise
3938 # it will coredump.
3939 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3940 ;;
3941
3942 sysv4*MP*)
3943 if test -d /usr/nec; then
3944 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3945 fi
3946 ;;
3947
3948 *)
3949 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3950 ;;
3951 esac
3952 else
3953 # PORTME Check for flag to pass linker flags through the system compiler.
3954 case $host_os in
3955 aix*)
3956 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3957 if test "$host_cpu" = ia64; then
3958 # AIX 5 now supports IA64 processor
3959 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3960 else
3961 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3962 fi
3963 ;;
3964
3965 mingw* | cygwin* | pw32* | os2* | cegcc*)
3966 # This hack is so that the source file can tell whether it is being
3967 # built for inclusion in a dll (and should export symbols for example).
3968 m4_if([$1], [GCJ], [],
3969 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3970 ;;
3971
3972 hpux9* | hpux10* | hpux11*)
3973 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3974 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
3975 # not for PA HP-UX.
3976 case $host_cpu in
3977 hppa*64*|ia64*)
3978 # +Z the default
3979 ;;
3980 *)
3981 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3982 ;;
3983 esac
3984 # Is there a better lt_prog_compiler_static that works with the bundled CC?
3985 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3986 ;;
3987
3988 irix5* | irix6* | nonstopux*)
3989 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3990 # PIC (with -KPIC) is the default.
3991 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3992 ;;
3993
3994 linux* | k*bsd*-gnu)
3995 case $cc_basename in
3996 # old Intel for x86_64 which still supported -KPIC.
3997 ecc*)
3998 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3999 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4000 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
4001 ;;
4002 # icc used to be incompatible with GCC.
4003 # ICC 10 doesn't accept -KPIC any more.
4004 icc* | ifort*)
4005 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4006 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
4007 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
4008 ;;
4009 # Lahey Fortran 8.1.
4010 lf95*)
4011 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4012 _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
4013 _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
4014 ;;
4015 pgcc* | pgf77* | pgf90* | pgf95*)
4016 # Portland Group compilers (*not* the Pentium gcc compiler,
4017 # which looks to be a dead project)
4018 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4019 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
4020 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4021 ;;
4022 ccc*)
4023 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4024 # All Alpha code is PIC.
4025 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4026 ;;
4027 xl*)
4028 # IBM XL C 8.0/Fortran 10.1 on PPC
4029 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4030 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
4031 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
4032 ;;
4033 *)
4034 case `$CC -V 2>&1 | sed 5q` in
4035 *Sun\ C*)
4036 # Sun C 5.9
4037 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4038 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4039 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4040 ;;
4041 *Sun\ F*)
4042 # Sun Fortran 8.3 passes all unrecognized flags to the linker
4043 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4044 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4045 _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
4046 ;;
4047 esac
4048 ;;
4049 esac
4050 ;;
4051
4052 newsos6)
4053 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4054 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4055 ;;
4056
4057 *nto* | *qnx*)
4058 # QNX uses GNU C++, but need to define -shared option too, otherwise
4059 # it will coredump.
4060 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
4061 ;;
4062
4063 osf3* | osf4* | osf5*)
4064 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4065 # All OSF/1 code is PIC.
4066 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4067 ;;
4068
4069 rdos*)
4070 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4071 ;;
4072
4073 solaris*)
4074 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4075 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4076 case $cc_basename in
4077 f77* | f90* | f95*)
4078 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
4079 *)
4080 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
4081 esac
4082 ;;
4083
4084 sunos4*)
4085 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
4086 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
4087 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4088 ;;
4089
4090 sysv4 | sysv4.2uw2* | sysv4.3*)
4091 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4092 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4093 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4094 ;;
4095
4096 sysv4*MP*)
4097 if test -d /usr/nec ;then
4098 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
4099 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4100 fi
4101 ;;
4102
4103 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
4104 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4105 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4106 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4107 ;;
4108
4109 unicos*)
4110 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4111 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4112 ;;
4113
4114 uts4*)
4115 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
4116 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4117 ;;
4118
4119 *)
4120 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4121 ;;
4122 esac
4123 fi
4124 ])
4125 case $host_os in
4126 # For platforms which do not support PIC, -DPIC is meaningless:
4127 *djgpp*)
4128 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
4129 ;;
4130 *)
4131 _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
4132 ;;
4133 esac
4134 AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
4135 _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
4136 [How to pass a linker flag through the compiler])
4137
4138 #
4139 # Check to make sure the PIC flag actually works.
4140 #
4141 if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
4142 _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
4143 [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
4144 [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
4145 [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
4146 "" | " "*) ;;
4147 *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
4148 esac],
4149 [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
4150 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
4151 fi
4152 _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
4153 [Additional compiler flags for building library objects])
4154
4155 #
4156 # Check to make sure the static flag actually works.
4157 #
4158 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
4159 _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
4160 _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
4161 $lt_tmp_static_flag,
4162 [],
4163 [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
4164 _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
4165 [Compiler flag to prevent dynamic linking])
4166 ])# _LT_COMPILER_PIC
4167
4168
4169 # _LT_LINKER_SHLIBS([TAGNAME])
4170 # ----------------------------
4171 # See if the linker supports building shared libraries.
4172 m4_defun([_LT_LINKER_SHLIBS],
4173 [AC_REQUIRE([LT_PATH_LD])dnl
4174 AC_REQUIRE([LT_PATH_NM])dnl
4175 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
4176 m4_require([_LT_DECL_EGREP])dnl
4177 m4_require([_LT_DECL_SED])dnl
4178 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
4179 m4_require([_LT_TAG_COMPILER])dnl
4180 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
4181 m4_if([$1], [CXX], [
4182 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4183 case $host_os in
4184 aix[[4-9]]*)
4185 # If we're using GNU nm, then we don't want the "-C" option.
4186 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4187 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4188 _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'
4189 else
4190 _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'
4191 fi
4192 ;;
4193 pw32*)
4194 _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
4195 ;;
4196 cygwin* | mingw* | cegcc*)
4197 _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'
4198 ;;
4199 *)
4200 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4201 ;;
4202 esac
4203 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4204 ], [
4205 runpath_var=
4206 _LT_TAGVAR(allow_undefined_flag, $1)=
4207 _LT_TAGVAR(always_export_symbols, $1)=no
4208 _LT_TAGVAR(archive_cmds, $1)=
4209 _LT_TAGVAR(archive_expsym_cmds, $1)=
4210 _LT_TAGVAR(compiler_needs_object, $1)=no
4211 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
4212 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4213 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4214 _LT_TAGVAR(hardcode_automatic, $1)=no
4215 _LT_TAGVAR(hardcode_direct, $1)=no
4216 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
4217 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4218 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
4219 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4220 _LT_TAGVAR(hardcode_minus_L, $1)=no
4221 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
4222 _LT_TAGVAR(inherit_rpath, $1)=no
4223 _LT_TAGVAR(link_all_deplibs, $1)=unknown
4224 _LT_TAGVAR(module_cmds, $1)=
4225 _LT_TAGVAR(module_expsym_cmds, $1)=
4226 _LT_TAGVAR(old_archive_from_new_cmds, $1)=
4227 _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
4228 _LT_TAGVAR(thread_safe_flag_spec, $1)=
4229 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4230 # include_expsyms should be a list of space-separated symbols to be *always*
4231 # included in the symbol list
4232 _LT_TAGVAR(include_expsyms, $1)=
4233 # exclude_expsyms can be an extended regexp of symbols to exclude
4234 # it will be wrapped by ` (' and `)$', so one must not match beginning or
4235 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
4236 # as well as any symbol that contains `d'.
4237 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4238 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
4239 # platforms (ab)use it in PIC code, but their linkers get confused if
4240 # the symbol is explicitly referenced. Since portable code cannot
4241 # rely on this symbol name, it's probably fine to never include it in
4242 # preloaded symbol tables.
4243 # Exclude shared library initialization/finalization symbols.
4244 dnl Note also adjust exclude_expsyms for C++ above.
4245 extract_expsyms_cmds=
4246
4247 case $host_os in
4248 cygwin* | mingw* | pw32* | cegcc*)
4249 # FIXME: the MSVC++ port hasn't been tested in a loooong time
4250 # When not using gcc, we currently assume that we are using
4251 # Microsoft Visual C++.
4252 if test "$GCC" != yes; then
4253 with_gnu_ld=no
4254 fi
4255 ;;
4256 interix*)
4257 # we just hope/assume this is gcc and not c89 (= MSVC++)
4258 with_gnu_ld=yes
4259 ;;
4260 openbsd*)
4261 with_gnu_ld=no
4262 ;;
4263 esac
4264
4265 _LT_TAGVAR(ld_shlibs, $1)=yes
4266 if test "$with_gnu_ld" = yes; then
4267 # If archive_cmds runs LD, not CC, wlarc should be empty
4268 wlarc='${wl}'
4269
4270 # Set some defaults for GNU ld with shared library support. These
4271 # are reset later if shared libraries are not supported. Putting them
4272 # here allows them to be overridden if necessary.
4273 runpath_var=LD_RUN_PATH
4274 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4275 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
4276 # ancient GNU ld didn't support --whole-archive et. al.
4277 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
4278 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
4279 else
4280 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4281 fi
4282 supports_anon_versioning=no
4283 case `$LD -v 2>&1` in
4284 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
4285 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
4286 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
4287 *\ 2.11.*) ;; # other 2.11 versions
4288 *) supports_anon_versioning=yes ;;
4289 esac
4290
4291 # See if GNU ld supports shared libraries.
4292 case $host_os in
4293 aix[[3-9]]*)
4294 # On AIX/PPC, the GNU linker is very broken
4295 if test "$host_cpu" != ia64; then
4296 _LT_TAGVAR(ld_shlibs, $1)=no
4297 cat <<_LT_EOF 1>&2
4298
4299 *** Warning: the GNU linker, at least up to release 2.9.1, is reported
4300 *** to be unable to reliably create shared libraries on AIX.
4301 *** Therefore, libtool is disabling shared libraries support. If you
4302 *** really care for shared libraries, you may want to modify your PATH
4303 *** so that a non-GNU linker is found, and then restart.
4304
4305 _LT_EOF
4306 fi
4307 ;;
4308
4309 amigaos*)
4310 case $host_cpu in
4311 powerpc)
4312 # see comment about AmigaOS4 .so support
4313 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4314 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4315 ;;
4316 m68k)
4317 _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)'
4318 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4319 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4320 ;;
4321 esac
4322 ;;
4323
4324 beos*)
4325 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4326 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4327 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
4328 # support --undefined. This deserves some investigation. FIXME
4329 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4330 else
4331 _LT_TAGVAR(ld_shlibs, $1)=no
4332 fi
4333 ;;
4334
4335 cygwin* | mingw* | pw32* | cegcc*)
4336 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
4337 # as there is no search path for DLLs.
4338 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4339 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4340 _LT_TAGVAR(always_export_symbols, $1)=no
4341 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4342 _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'
4343
4344 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
4345 _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'
4346 # If the export-symbols file already is a .def file (1st line
4347 # is EXPORTS), use it as is; otherwise, prepend...
4348 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
4349 cp $export_symbols $output_objdir/$soname.def;
4350 else
4351 echo EXPORTS > $output_objdir/$soname.def;
4352 cat $export_symbols >> $output_objdir/$soname.def;
4353 fi~
4354 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
4355 else
4356 _LT_TAGVAR(ld_shlibs, $1)=no
4357 fi
4358 ;;
4359
4360 interix[[3-9]]*)
4361 _LT_TAGVAR(hardcode_direct, $1)=no
4362 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4363 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4364 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4365 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
4366 # Instead, shared libraries are loaded at an image base (0x10000000 by
4367 # default) and relocated if they conflict, which is a slow very memory
4368 # consuming and fragmenting process. To avoid this, we pick a random,
4369 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
4370 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
4371 _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'
4372 _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'
4373 ;;
4374
4375 gnu* | linux* | tpf* | k*bsd*-gnu)
4376 tmp_diet=no
4377 if test "$host_os" = linux-dietlibc; then
4378 case $cc_basename in
4379 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
4380 esac
4381 fi
4382 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
4383 && test "$tmp_diet" = no
4384 then
4385 tmp_addflag=
4386 tmp_sharedflag='-shared'
4387 case $cc_basename,$host_cpu in
4388 pgcc*) # Portland Group C compiler
4389 _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'
4390 tmp_addflag=' $pic_flag'
4391 ;;
4392 pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
4393 _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'
4394 tmp_addflag=' $pic_flag -Mnomain' ;;
4395 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
4396 tmp_addflag=' -i_dynamic' ;;
4397 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
4398 tmp_addflag=' -i_dynamic -nofor_main' ;;
4399 ifc* | ifort*) # Intel Fortran compiler
4400 tmp_addflag=' -nofor_main' ;;
4401 lf95*) # Lahey Fortran 8.1
4402 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4403 tmp_sharedflag='--shared' ;;
4404 xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
4405 tmp_sharedflag='-qmkshrobj'
4406 tmp_addflag= ;;
4407 esac
4408 case `$CC -V 2>&1 | sed 5q` in
4409 *Sun\ C*) # Sun C 5.9
4410 _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'
4411 _LT_TAGVAR(compiler_needs_object, $1)=yes
4412 tmp_sharedflag='-G' ;;
4413 *Sun\ F*) # Sun Fortran 8.3
4414 tmp_sharedflag='-G' ;;
4415 esac
4416 _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4417
4418 if test "x$supports_anon_versioning" = xyes; then
4419 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4420 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4421 echo "local: *; };" >> $output_objdir/$libname.ver~
4422 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
4423 fi
4424
4425 case $cc_basename in
4426 xlf*)
4427 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
4428 _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
4429 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4430 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
4431 _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
4432 if test "x$supports_anon_versioning" = xyes; then
4433 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4434 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4435 echo "local: *; };" >> $output_objdir/$libname.ver~
4436 $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
4437 fi
4438 ;;
4439 esac
4440 else
4441 _LT_TAGVAR(ld_shlibs, $1)=no
4442 fi
4443 ;;
4444
4445 netbsd*)
4446 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4447 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
4448 wlarc=
4449 else
4450 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4451 _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'
4452 fi
4453 ;;
4454
4455 solaris*)
4456 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
4457 _LT_TAGVAR(ld_shlibs, $1)=no
4458 cat <<_LT_EOF 1>&2
4459
4460 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
4461 *** create shared libraries on Solaris systems. Therefore, libtool
4462 *** is disabling shared libraries support. We urge you to upgrade GNU
4463 *** binutils to release 2.9.1 or newer. Another option is to modify
4464 *** your PATH or compiler configuration so that the native linker is
4465 *** used, and then restart.
4466
4467 _LT_EOF
4468 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4469 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4470 _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'
4471 else
4472 _LT_TAGVAR(ld_shlibs, $1)=no
4473 fi
4474 ;;
4475
4476 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
4477 case `$LD -v 2>&1` in
4478 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
4479 _LT_TAGVAR(ld_shlibs, $1)=no
4480 cat <<_LT_EOF 1>&2
4481
4482 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
4483 *** reliably create shared libraries on SCO systems. Therefore, libtool
4484 *** is disabling shared libraries support. We urge you to upgrade GNU
4485 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
4486 *** your PATH or compiler configuration so that the native linker is
4487 *** used, and then restart.
4488
4489 _LT_EOF
4490 ;;
4491 *)
4492 # For security reasons, it is highly recommended that you always
4493 # use absolute paths for naming shared libraries, and exclude the
4494 # DT_RUNPATH tag from executables and libraries. But doing so
4495 # requires that you compile everything twice, which is a pain.
4496 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4497 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4498 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4499 _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'
4500 else
4501 _LT_TAGVAR(ld_shlibs, $1)=no
4502 fi
4503 ;;
4504 esac
4505 ;;
4506
4507 sunos4*)
4508 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4509 wlarc=
4510 _LT_TAGVAR(hardcode_direct, $1)=yes
4511 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4512 ;;
4513
4514 *)
4515 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4516 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4517 _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'
4518 else
4519 _LT_TAGVAR(ld_shlibs, $1)=no
4520 fi
4521 ;;
4522 esac
4523
4524 if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
4525 runpath_var=
4526 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4527 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4528 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4529 fi
4530 else
4531 # PORTME fill in a description of your system's linker (not GNU ld)
4532 case $host_os in
4533 aix3*)
4534 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4535 _LT_TAGVAR(always_export_symbols, $1)=yes
4536 _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'
4537 # Note: this linker hardcodes the directories in LIBPATH if there
4538 # are no directories specified by -L.
4539 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4540 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
4541 # Neither direct hardcoding nor static linking is supported with a
4542 # broken collect2.
4543 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4544 fi
4545 ;;
4546
4547 aix[[4-9]]*)
4548 if test "$host_cpu" = ia64; then
4549 # On IA64, the linker does run time linking by default, so we don't
4550 # have to do anything special.
4551 aix_use_runtimelinking=no
4552 exp_sym_flag='-Bexport'
4553 no_entry_flag=""
4554 else
4555 # If we're using GNU nm, then we don't want the "-C" option.
4556 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4557 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4558 _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'
4559 else
4560 _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'
4561 fi
4562 aix_use_runtimelinking=no
4563
4564 # Test if we are trying to use run time linking or normal
4565 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
4566 # need to do runtime linking.
4567 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
4568 for ld_flag in $LDFLAGS; do
4569 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
4570 aix_use_runtimelinking=yes
4571 break
4572 fi
4573 done
4574 ;;
4575 esac
4576
4577 exp_sym_flag='-bexport'
4578 no_entry_flag='-bnoentry'
4579 fi
4580
4581 # When large executables or shared objects are built, AIX ld can
4582 # have problems creating the table of contents. If linking a library
4583 # or program results in "error TOC overflow" add -mminimal-toc to
4584 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
4585 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
4586
4587 _LT_TAGVAR(archive_cmds, $1)=''
4588 _LT_TAGVAR(hardcode_direct, $1)=yes
4589 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4590 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
4591 _LT_TAGVAR(link_all_deplibs, $1)=yes
4592 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
4593
4594 if test "$GCC" = yes; then
4595 case $host_os in aix4.[[012]]|aix4.[[012]].*)
4596 # We only want to do this on AIX 4.2 and lower, the check
4597 # below for broken collect2 doesn't work under 4.3+
4598 collect2name=`${CC} -print-prog-name=collect2`
4599 if test -f "$collect2name" &&
4600 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
4601 then
4602 # We have reworked collect2
4603 :
4604 else
4605 # We have old collect2
4606 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4607 # It fails to find uninstalled libraries when the uninstalled
4608 # path is not listed in the libpath. Setting hardcode_minus_L
4609 # to unsupported forces relinking
4610 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4611 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4612 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4613 fi
4614 ;;
4615 esac
4616 shared_flag='-shared'
4617 if test "$aix_use_runtimelinking" = yes; then
4618 shared_flag="$shared_flag "'${wl}-G'
4619 fi
4620 else
4621 # not using gcc
4622 if test "$host_cpu" = ia64; then
4623 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
4624 # chokes on -Wl,-G. The following line is correct:
4625 shared_flag='-G'
4626 else
4627 if test "$aix_use_runtimelinking" = yes; then
4628 shared_flag='${wl}-G'
4629 else
4630 shared_flag='${wl}-bM:SRE'
4631 fi
4632 fi
4633 fi
4634
4635 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
4636 # It seems that -bexpall does not export symbols beginning with
4637 # underscore (_), so it is better to generate a list of symbols to export.
4638 _LT_TAGVAR(always_export_symbols, $1)=yes
4639 if test "$aix_use_runtimelinking" = yes; then
4640 # Warning - without using the other runtime loading flags (-brtl),
4641 # -berok will link without error, but may produce a broken library.
4642 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
4643 # Determine the default libpath from the value encoded in an
4644 # empty executable.
4645 _LT_SYS_MODULE_PATH_AIX
4646 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4647 _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"
4648 else
4649 if test "$host_cpu" = ia64; then
4650 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
4651 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
4652 _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"
4653 else
4654 # Determine the default libpath from the value encoded in an
4655 # empty executable.
4656 _LT_SYS_MODULE_PATH_AIX
4657 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4658 # Warning - without using the other run time loading flags,
4659 # -berok will link without error, but may produce a broken library.
4660 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
4661 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
4662 # Exported symbols can be pulled into shared objects from archives
4663 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
4664 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
4665 # This is similar to how AIX traditionally builds its shared libraries.
4666 _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'
4667 fi
4668 fi
4669 ;;
4670
4671 amigaos*)
4672 case $host_cpu in
4673 powerpc)
4674 # see comment about AmigaOS4 .so support
4675 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4676 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4677 ;;
4678 m68k)
4679 _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)'
4680 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4681 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4682 ;;
4683 esac
4684 ;;
4685
4686 bsdi[[45]]*)
4687 _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
4688 ;;
4689
4690 cygwin* | mingw* | pw32* | cegcc*)
4691 # When not using gcc, we currently assume that we are using
4692 # Microsoft Visual C++.
4693 # hardcode_libdir_flag_spec is actually meaningless, as there is
4694 # no search path for DLLs.
4695 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
4696 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4697 # Tell ltmain to make .lib files, not .a files.
4698 libext=lib
4699 # Tell ltmain to make .dll files, not .so files.
4700 shrext_cmds=".dll"
4701 # FIXME: Setting linknames here is a bad hack.
4702 _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
4703 # The linker will automatically build a .lib file if we build a DLL.
4704 _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
4705 # FIXME: Should let the user specify the lib program.
4706 _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
4707 _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
4708 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4709 ;;
4710
4711 darwin* | rhapsody*)
4712 _LT_DARWIN_LINKER_FEATURES($1)
4713 ;;
4714
4715 dgux*)
4716 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4717 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4718 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4719 ;;
4720
4721 freebsd1*)
4722 _LT_TAGVAR(ld_shlibs, $1)=no
4723 ;;
4724
4725 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
4726 # support. Future versions do this automatically, but an explicit c++rt0.o
4727 # does not break anything, and helps significantly (at the cost of a little
4728 # extra space).
4729 freebsd2.2*)
4730 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
4731 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4732 _LT_TAGVAR(hardcode_direct, $1)=yes
4733 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4734 ;;
4735
4736 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
4737 freebsd2*)
4738 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4739 _LT_TAGVAR(hardcode_direct, $1)=yes
4740 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4741 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4742 ;;
4743
4744 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
4745 freebsd* | dragonfly*)
4746 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
4747 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4748 _LT_TAGVAR(hardcode_direct, $1)=yes
4749 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4750 ;;
4751
4752 hpux9*)
4753 if test "$GCC" = yes; then
4754 _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'
4755 else
4756 _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'
4757 fi
4758 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4759 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4760 _LT_TAGVAR(hardcode_direct, $1)=yes
4761
4762 # hardcode_minus_L: Not really in the search PATH,
4763 # but as the default location of the library.
4764 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4765 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4766 ;;
4767
4768 hpux10*)
4769 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4770 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4771 else
4772 _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
4773 fi
4774 if test "$with_gnu_ld" = no; then
4775 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4776 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
4777 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4778 _LT_TAGVAR(hardcode_direct, $1)=yes
4779 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4780 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4781 # hardcode_minus_L: Not really in the search PATH,
4782 # but as the default location of the library.
4783 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4784 fi
4785 ;;
4786
4787 hpux11*)
4788 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4789 case $host_cpu in
4790 hppa*64*)
4791 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4792 ;;
4793 ia64*)
4794 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4795 ;;
4796 *)
4797 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4798 ;;
4799 esac
4800 else
4801 case $host_cpu in
4802 hppa*64*)
4803 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4804 ;;
4805 ia64*)
4806 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4807 ;;
4808 *)
4809 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4810 ;;
4811 esac
4812 fi
4813 if test "$with_gnu_ld" = no; then
4814 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4815 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4816
4817 case $host_cpu in
4818 hppa*64*|ia64*)
4819 _LT_TAGVAR(hardcode_direct, $1)=no
4820 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4821 ;;
4822 *)
4823 _LT_TAGVAR(hardcode_direct, $1)=yes
4824 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4825 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4826
4827 # hardcode_minus_L: Not really in the search PATH,
4828 # but as the default location of the library.
4829 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4830 ;;
4831 esac
4832 fi
4833 ;;
4834
4835 irix5* | irix6* | nonstopux*)
4836 if test "$GCC" = yes; then
4837 _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'
4838 # Try to use the -exported_symbol ld option, if it does not
4839 # work, assume that -exports_file does not work either and
4840 # implicitly export all symbols.
4841 save_LDFLAGS="$LDFLAGS"
4842 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
4843 AC_LINK_IFELSE(int foo(void) {},
4844 _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'
4845 )
4846 LDFLAGS="$save_LDFLAGS"
4847 else
4848 _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'
4849 _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'
4850 fi
4851 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4852 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4853 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4854 _LT_TAGVAR(inherit_rpath, $1)=yes
4855 _LT_TAGVAR(link_all_deplibs, $1)=yes
4856 ;;
4857
4858 netbsd*)
4859 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4860 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
4861 else
4862 _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
4863 fi
4864 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4865 _LT_TAGVAR(hardcode_direct, $1)=yes
4866 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4867 ;;
4868
4869 newsos6)
4870 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4871 _LT_TAGVAR(hardcode_direct, $1)=yes
4872 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4873 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4874 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4875 ;;
4876
4877 *nto* | *qnx*)
4878 ;;
4879
4880 openbsd*)
4881 if test -f /usr/libexec/ld.so; then
4882 _LT_TAGVAR(hardcode_direct, $1)=yes
4883 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4884 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4885 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4886 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4887 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
4888 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4889 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4890 else
4891 case $host_os in
4892 openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
4893 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4894 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4895 ;;
4896 *)
4897 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4898 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4899 ;;
4900 esac
4901 fi
4902 else
4903 _LT_TAGVAR(ld_shlibs, $1)=no
4904 fi
4905 ;;
4906
4907 os2*)
4908 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4909 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4910 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4911 _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'
4912 _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
4913 ;;
4914
4915 osf3*)
4916 if test "$GCC" = yes; then
4917 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4918 _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'
4919 else
4920 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4921 _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'
4922 fi
4923 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4924 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4925 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4926 ;;
4927
4928 osf4* | osf5*) # as osf3* with the addition of -msym flag
4929 if test "$GCC" = yes; then
4930 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4931 _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'
4932 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4933 else
4934 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4935 _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'
4936 _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~
4937 $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'
4938
4939 # Both c and cxx compiler support -rpath directly
4940 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
4941 fi
4942 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4943 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4944 ;;
4945
4946 solaris*)
4947 _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
4948 if test "$GCC" = yes; then
4949 wlarc='${wl}'
4950 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4951 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4952 $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4953 else
4954 case `$CC -V 2>&1` in
4955 *"Compilers 5.0"*)
4956 wlarc=''
4957 _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
4958 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4959 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
4960 ;;
4961 *)
4962 wlarc='${wl}'
4963 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
4964 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4965 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4966 ;;
4967 esac
4968 fi
4969 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4970 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4971 case $host_os in
4972 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
4973 *)
4974 # The compiler driver will combine and reorder linker options,
4975 # but understands `-z linker_flag'. GCC discards it without `$wl',
4976 # but is careful enough not to reorder.
4977 # Supported since Solaris 2.6 (maybe 2.5.1?)
4978 if test "$GCC" = yes; then
4979 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
4980 else
4981 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
4982 fi
4983 ;;
4984 esac
4985 _LT_TAGVAR(link_all_deplibs, $1)=yes
4986 ;;
4987
4988 sunos4*)
4989 if test "x$host_vendor" = xsequent; then
4990 # Use $CC to link under sequent, because it throws in some extra .o
4991 # files that make .init and .fini sections work.
4992 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
4993 else
4994 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
4995 fi
4996 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4997 _LT_TAGVAR(hardcode_direct, $1)=yes
4998 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4999 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5000 ;;
5001
5002 sysv4)
5003 case $host_vendor in
5004 sni)
5005 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5006 _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
5007 ;;
5008 siemens)
5009 ## LD is ld it makes a PLAMLIB
5010 ## CC just makes a GrossModule.
5011 _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
5012 _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
5013 _LT_TAGVAR(hardcode_direct, $1)=no
5014 ;;
5015 motorola)
5016 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5017 _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
5018 ;;
5019 esac
5020 runpath_var='LD_RUN_PATH'
5021 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5022 ;;
5023
5024 sysv4.3*)
5025 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5026 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5027 _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
5028 ;;
5029
5030 sysv4*MP*)
5031 if test -d /usr/nec; then
5032 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5033 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5034 runpath_var=LD_RUN_PATH
5035 hardcode_runpath_var=yes
5036 _LT_TAGVAR(ld_shlibs, $1)=yes
5037 fi
5038 ;;
5039
5040 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
5041 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5042 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5043 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5044 runpath_var='LD_RUN_PATH'
5045
5046 if test "$GCC" = yes; then
5047 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5048 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5049 else
5050 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5051 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5052 fi
5053 ;;
5054
5055 sysv5* | sco3.2v5* | sco5v6*)
5056 # Note: We can NOT use -z defs as we might desire, because we do not
5057 # link with -lc, and that would cause any symbols used from libc to
5058 # always be unresolved, which means just about no library would
5059 # ever link correctly. If we're not using GNU ld we use -z text
5060 # though, which does catch some bad symbols but isn't as heavy-handed
5061 # as -z defs.
5062 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5063 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
5064 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5065 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5066 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
5067 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5068 _LT_TAGVAR(link_all_deplibs, $1)=yes
5069 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
5070 runpath_var='LD_RUN_PATH'
5071
5072 if test "$GCC" = yes; then
5073 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5074 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5075 else
5076 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5077 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5078 fi
5079 ;;
5080
5081 uts4*)
5082 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5083 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5084 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5085 ;;
5086
5087 *)
5088 _LT_TAGVAR(ld_shlibs, $1)=no
5089 ;;
5090 esac
5091
5092 if test x$host_vendor = xsni; then
5093 case $host in
5094 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
5095 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
5096 ;;
5097 esac
5098 fi
5099 fi
5100 ])
5101 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
5102 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
5103
5104 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
5105
5106 _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
5107 _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
5108 _LT_DECL([], [extract_expsyms_cmds], [2],
5109 [The commands to extract the exported symbol list from a shared archive])
5110
5111 #
5112 # Do we need to explicitly link libc?
5113 #
5114 case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
5115 x|xyes)
5116 # Assume -lc should be added
5117 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5118
5119 if test "$enable_shared" = yes && test "$GCC" = yes; then
5120 case $_LT_TAGVAR(archive_cmds, $1) in
5121 *'~'*)
5122 # FIXME: we may have to deal with multi-command sequences.
5123 ;;
5124 '$CC '*)
5125 # Test whether the compiler implicitly links with -lc since on some
5126 # systems, -lgcc has to come before -lc. If gcc already passes -lc
5127 # to ld, don't add -lc before -lgcc.
5128 AC_MSG_CHECKING([whether -lc should be explicitly linked in])
5129 $RM conftest*
5130 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
5131
5132 if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
5133 soname=conftest
5134 lib=conftest
5135 libobjs=conftest.$ac_objext
5136 deplibs=
5137 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
5138 pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
5139 compiler_flags=-v
5140 linker_flags=-v
5141 verstring=
5142 output_objdir=.
5143 libname=conftest
5144 lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
5145 _LT_TAGVAR(allow_undefined_flag, $1)=
5146 if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
5147 then
5148 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5149 else
5150 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5151 fi
5152 _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
5153 else
5154 cat conftest.err 1>&5
5155 fi
5156 $RM conftest*
5157 AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
5158 ;;
5159 esac
5160 fi
5161 ;;
5162 esac
5163
5164 _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
5165 [Whether or not to add -lc for building shared libraries])
5166 _LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
5167 [enable_shared_with_static_runtimes], [0],
5168 [Whether or not to disallow shared libs when runtime libs are static])
5169 _LT_TAGDECL([], [export_dynamic_flag_spec], [1],
5170 [Compiler flag to allow reflexive dlopens])
5171 _LT_TAGDECL([], [whole_archive_flag_spec], [1],
5172 [Compiler flag to generate shared objects directly from archives])
5173 _LT_TAGDECL([], [compiler_needs_object], [1],
5174 [Whether the compiler copes with passing no objects directly])
5175 _LT_TAGDECL([], [old_archive_from_new_cmds], [2],
5176 [Create an old-style archive from a shared archive])
5177 _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
5178 [Create a temporary old-style archive to link instead of a shared archive])
5179 _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
5180 _LT_TAGDECL([], [archive_expsym_cmds], [2])
5181 _LT_TAGDECL([], [module_cmds], [2],
5182 [Commands used to build a loadable module if different from building
5183 a shared archive.])
5184 _LT_TAGDECL([], [module_expsym_cmds], [2])
5185 _LT_TAGDECL([], [with_gnu_ld], [1],
5186 [Whether we are building with GNU ld or not])
5187 _LT_TAGDECL([], [allow_undefined_flag], [1],
5188 [Flag that allows shared libraries with undefined symbols to be built])
5189 _LT_TAGDECL([], [no_undefined_flag], [1],
5190 [Flag that enforces no undefined symbols])
5191 _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
5192 [Flag to hardcode $libdir into a binary during linking.
5193 This must work even if $libdir does not exist])
5194 _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
5195 [[If ld is used when linking, flag to hardcode $libdir into a binary
5196 during linking. This must work even if $libdir does not exist]])
5197 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
5198 [Whether we need a single "-rpath" flag with a separated argument])
5199 _LT_TAGDECL([], [hardcode_direct], [0],
5200 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5201 DIR into the resulting binary])
5202 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
5203 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5204 DIR into the resulting binary and the resulting library dependency is
5205 "absolute", i.e impossible to change by setting ${shlibpath_var} if the
5206 library is relocated])
5207 _LT_TAGDECL([], [hardcode_minus_L], [0],
5208 [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
5209 into the resulting binary])
5210 _LT_TAGDECL([], [hardcode_shlibpath_var], [0],
5211 [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
5212 into the resulting binary])
5213 _LT_TAGDECL([], [hardcode_automatic], [0],
5214 [Set to "yes" if building a shared library automatically hardcodes DIR
5215 into the library and all subsequent libraries and executables linked
5216 against it])
5217 _LT_TAGDECL([], [inherit_rpath], [0],
5218 [Set to yes if linker adds runtime paths of dependent libraries
5219 to runtime path list])
5220 _LT_TAGDECL([], [link_all_deplibs], [0],
5221 [Whether libtool must link a program against all its dependency libraries])
5222 _LT_TAGDECL([], [fix_srcfile_path], [1],
5223 [Fix the shell variable $srcfile for the compiler])
5224 _LT_TAGDECL([], [always_export_symbols], [0],
5225 [Set to "yes" if exported symbols are required])
5226 _LT_TAGDECL([], [export_symbols_cmds], [2],
5227 [The commands to list exported symbols])
5228 _LT_TAGDECL([], [exclude_expsyms], [1],
5229 [Symbols that should not be listed in the preloaded symbols])
5230 _LT_TAGDECL([], [include_expsyms], [1],
5231 [Symbols that must always be exported])
5232 _LT_TAGDECL([], [prelink_cmds], [2],
5233 [Commands necessary for linking programs (against libraries) with templates])
5234 _LT_TAGDECL([], [file_list_spec], [1],
5235 [Specify filename containing input files])
5236 dnl FIXME: Not yet implemented
5237 dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
5238 dnl [Compiler flag to generate thread safe objects])
5239 ])# _LT_LINKER_SHLIBS
5240
5241
5242 # _LT_LANG_C_CONFIG([TAG])
5243 # ------------------------
5244 # Ensure that the configuration variables for a C compiler are suitably
5245 # defined. These variables are subsequently used by _LT_CONFIG to write
5246 # the compiler configuration to `libtool'.
5247 m4_defun([_LT_LANG_C_CONFIG],
5248 [m4_require([_LT_DECL_EGREP])dnl
5249 lt_save_CC="$CC"
5250 AC_LANG_PUSH(C)
5251
5252 # Source file extension for C test sources.
5253 ac_ext=c
5254
5255 # Object file extension for compiled C test sources.
5256 objext=o
5257 _LT_TAGVAR(objext, $1)=$objext
5258
5259 # Code to be used in simple compile tests
5260 lt_simple_compile_test_code="int some_variable = 0;"
5261
5262 # Code to be used in simple link tests
5263 lt_simple_link_test_code='int main(){return(0);}'
5264
5265 _LT_TAG_COMPILER
5266 # Save the default compiler, since it gets overwritten when the other
5267 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
5268 compiler_DEFAULT=$CC
5269
5270 # save warnings/boilerplate of simple test code
5271 _LT_COMPILER_BOILERPLATE
5272 _LT_LINKER_BOILERPLATE
5273
5274 ## CAVEAT EMPTOR:
5275 ## There is no encapsulation within the following macros, do not change
5276 ## the running order or otherwise move them around unless you know exactly
5277 ## what you are doing...
5278 if test -n "$compiler"; then
5279 _LT_COMPILER_NO_RTTI($1)
5280 _LT_COMPILER_PIC($1)
5281 _LT_COMPILER_C_O($1)
5282 _LT_COMPILER_FILE_LOCKS($1)
5283 _LT_LINKER_SHLIBS($1)
5284 _LT_SYS_DYNAMIC_LINKER($1)
5285 _LT_LINKER_HARDCODE_LIBPATH($1)
5286 LT_SYS_DLOPEN_SELF
5287 _LT_CMD_STRIPLIB
5288
5289 # Report which library types will actually be built
5290 AC_MSG_CHECKING([if libtool supports shared libraries])
5291 AC_MSG_RESULT([$can_build_shared])
5292
5293 AC_MSG_CHECKING([whether to build shared libraries])
5294 test "$can_build_shared" = "no" && enable_shared=no
5295
5296 # On AIX, shared libraries and static libraries use the same namespace, and
5297 # are all built from PIC.
5298 case $host_os in
5299 aix3*)
5300 test "$enable_shared" = yes && enable_static=no
5301 if test -n "$RANLIB"; then
5302 archive_cmds="$archive_cmds~\$RANLIB \$lib"
5303 postinstall_cmds='$RANLIB $lib'
5304 fi
5305 ;;
5306
5307 aix[[4-9]]*)
5308 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
5309 test "$enable_shared" = yes && enable_static=no
5310 fi
5311 ;;
5312 esac
5313 AC_MSG_RESULT([$enable_shared])
5314
5315 AC_MSG_CHECKING([whether to build static libraries])
5316 # Make sure either enable_shared or enable_static is yes.
5317 test "$enable_shared" = yes || enable_static=yes
5318 AC_MSG_RESULT([$enable_static])
5319
5320 _LT_CONFIG($1)
5321 fi
5322 AC_LANG_POP
5323 CC="$lt_save_CC"
5324 ])# _LT_LANG_C_CONFIG
5325
5326
5327 # _LT_PROG_CXX
5328 # ------------
5329 # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
5330 # compiler, we have our own version here.
5331 m4_defun([_LT_PROG_CXX],
5332 [
5333 pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
5334 AC_PROG_CXX
5335 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
5336 ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
5337 (test "X$CXX" != "Xg++"))) ; then
5338 AC_PROG_CXXCPP
5339 else
5340 _lt_caught_CXX_error=yes
5341 fi
5342 popdef([AC_MSG_ERROR])
5343 ])# _LT_PROG_CXX
5344
5345 dnl aclocal-1.4 backwards compatibility:
5346 dnl AC_DEFUN([_LT_PROG_CXX], [])
5347
5348
5349 # _LT_LANG_CXX_CONFIG([TAG])
5350 # --------------------------
5351 # Ensure that the configuration variables for a C++ compiler are suitably
5352 # defined. These variables are subsequently used by _LT_CONFIG to write
5353 # the compiler configuration to `libtool'.
5354 m4_defun([_LT_LANG_CXX_CONFIG],
5355 [AC_REQUIRE([_LT_PROG_CXX])dnl
5356 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
5357 m4_require([_LT_DECL_EGREP])dnl
5358
5359 AC_LANG_PUSH(C++)
5360 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5361 _LT_TAGVAR(allow_undefined_flag, $1)=
5362 _LT_TAGVAR(always_export_symbols, $1)=no
5363 _LT_TAGVAR(archive_expsym_cmds, $1)=
5364 _LT_TAGVAR(compiler_needs_object, $1)=no
5365 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
5366 _LT_TAGVAR(hardcode_direct, $1)=no
5367 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
5368 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
5369 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
5370 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5371 _LT_TAGVAR(hardcode_minus_L, $1)=no
5372 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
5373 _LT_TAGVAR(hardcode_automatic, $1)=no
5374 _LT_TAGVAR(inherit_rpath, $1)=no
5375 _LT_TAGVAR(module_cmds, $1)=
5376 _LT_TAGVAR(module_expsym_cmds, $1)=
5377 _LT_TAGVAR(link_all_deplibs, $1)=unknown
5378 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
5379 _LT_TAGVAR(no_undefined_flag, $1)=
5380 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5381 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
5382
5383 # Source file extension for C++ test sources.
5384 ac_ext=cpp
5385
5386 # Object file extension for compiled C++ test sources.
5387 objext=o
5388 _LT_TAGVAR(objext, $1)=$objext
5389
5390 # No sense in running all these tests if we already determined that
5391 # the CXX compiler isn't working. Some variables (like enable_shared)
5392 # are currently assumed to apply to all compilers on this platform,
5393 # and will be corrupted by setting them based on a non-working compiler.
5394 if test "$_lt_caught_CXX_error" != yes; then
5395 # Code to be used in simple compile tests
5396 lt_simple_compile_test_code="int some_variable = 0;"
5397
5398 # Code to be used in simple link tests
5399 lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
5400
5401 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
5402 _LT_TAG_COMPILER
5403
5404 # save warnings/boilerplate of simple test code
5405 _LT_COMPILER_BOILERPLATE
5406 _LT_LINKER_BOILERPLATE
5407
5408 # Allow CC to be a program name with arguments.
5409 lt_save_CC=$CC
5410 lt_save_LD=$LD
5411 lt_save_GCC=$GCC
5412 GCC=$GXX
5413 lt_save_with_gnu_ld=$with_gnu_ld
5414 lt_save_path_LD=$lt_cv_path_LD
5415 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
5416 lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
5417 else
5418 $as_unset lt_cv_prog_gnu_ld
5419 fi
5420 if test -n "${lt_cv_path_LDCXX+set}"; then
5421 lt_cv_path_LD=$lt_cv_path_LDCXX
5422 else
5423 $as_unset lt_cv_path_LD
5424 fi
5425 test -z "${LDCXX+set}" || LD=$LDCXX
5426 CC=${CXX-"c++"}
5427 compiler=$CC
5428 _LT_TAGVAR(compiler, $1)=$CC
5429 _LT_CC_BASENAME([$compiler])
5430
5431 if test -n "$compiler"; then
5432 # We don't want -fno-exception when compiling C++ code, so set the
5433 # no_builtin_flag separately
5434 if test "$GXX" = yes; then
5435 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
5436 else
5437 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
5438 fi
5439
5440 if test "$GXX" = yes; then
5441 # Set up default GNU C++ configuration
5442
5443 LT_PATH_LD
5444
5445 # Check if GNU C++ uses GNU ld as the underlying linker, since the
5446 # archiving commands below assume that GNU ld is being used.
5447 if test "$with_gnu_ld" = yes; then
5448 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5449 _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'
5450
5451 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5452 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5453
5454 # If archive_cmds runs LD, not CC, wlarc should be empty
5455 # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
5456 # investigate it a little bit more. (MM)
5457 wlarc='${wl}'
5458
5459 # ancient GNU ld didn't support --whole-archive et. al.
5460 if eval "`$CC -print-prog-name=ld` --help 2>&1" |
5461 $GREP 'no-whole-archive' > /dev/null; then
5462 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
5463 else
5464 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5465 fi
5466 else
5467 with_gnu_ld=no
5468 wlarc=
5469
5470 # A generic and very simple default shared library creation
5471 # command for GNU C++ for the case where it uses the native
5472 # linker, instead of GNU ld. If possible, this setting should
5473 # overridden to take advantage of the native linker features on
5474 # the platform it is being used on.
5475 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
5476 fi
5477
5478 # Commands to make compiler produce verbose output that lists
5479 # what "hidden" libraries, object files and flags are used when
5480 # linking a shared library.
5481 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
5482
5483 else
5484 GXX=no
5485 with_gnu_ld=no
5486 wlarc=
5487 fi
5488
5489 # PORTME: fill in a description of your system's C++ link characteristics
5490 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
5491 _LT_TAGVAR(ld_shlibs, $1)=yes
5492 case $host_os in
5493 aix3*)
5494 # FIXME: insert proper C++ library support
5495 _LT_TAGVAR(ld_shlibs, $1)=no
5496 ;;
5497 aix[[4-9]]*)
5498 if test "$host_cpu" = ia64; then
5499 # On IA64, the linker does run time linking by default, so we don't
5500 # have to do anything special.
5501 aix_use_runtimelinking=no
5502 exp_sym_flag='-Bexport'
5503 no_entry_flag=""
5504 else
5505 aix_use_runtimelinking=no
5506
5507 # Test if we are trying to use run time linking or normal
5508 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
5509 # need to do runtime linking.
5510 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
5511 for ld_flag in $LDFLAGS; do
5512 case $ld_flag in
5513 *-brtl*)
5514 aix_use_runtimelinking=yes
5515 break
5516 ;;
5517 esac
5518 done
5519 ;;
5520 esac
5521
5522 exp_sym_flag='-bexport'
5523 no_entry_flag='-bnoentry'
5524 fi
5525
5526 # When large executables or shared objects are built, AIX ld can
5527 # have problems creating the table of contents. If linking a library
5528 # or program results in "error TOC overflow" add -mminimal-toc to
5529 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
5530 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
5531
5532 _LT_TAGVAR(archive_cmds, $1)=''
5533 _LT_TAGVAR(hardcode_direct, $1)=yes
5534 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5535 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5536 _LT_TAGVAR(link_all_deplibs, $1)=yes
5537 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
5538
5539 if test "$GXX" = yes; then
5540 case $host_os in aix4.[[012]]|aix4.[[012]].*)
5541 # We only want to do this on AIX 4.2 and lower, the check
5542 # below for broken collect2 doesn't work under 4.3+
5543 collect2name=`${CC} -print-prog-name=collect2`
5544 if test -f "$collect2name" &&
5545 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
5546 then
5547 # We have reworked collect2
5548 :
5549 else
5550 # We have old collect2
5551 _LT_TAGVAR(hardcode_direct, $1)=unsupported
5552 # It fails to find uninstalled libraries when the uninstalled
5553 # path is not listed in the libpath. Setting hardcode_minus_L
5554 # to unsupported forces relinking
5555 _LT_TAGVAR(hardcode_minus_L, $1)=yes
5556 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5557 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5558 fi
5559 esac
5560 shared_flag='-shared'
5561 if test "$aix_use_runtimelinking" = yes; then
5562 shared_flag="$shared_flag "'${wl}-G'
5563 fi
5564 else
5565 # not using gcc
5566 if test "$host_cpu" = ia64; then
5567 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
5568 # chokes on -Wl,-G. The following line is correct:
5569 shared_flag='-G'
5570 else
5571 if test "$aix_use_runtimelinking" = yes; then
5572 shared_flag='${wl}-G'
5573 else
5574 shared_flag='${wl}-bM:SRE'
5575 fi
5576 fi
5577 fi
5578
5579 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
5580 # It seems that -bexpall does not export symbols beginning with
5581 # underscore (_), so it is better to generate a list of symbols to
5582 # export.
5583 _LT_TAGVAR(always_export_symbols, $1)=yes
5584 if test "$aix_use_runtimelinking" = yes; then
5585 # Warning - without using the other runtime loading flags (-brtl),
5586 # -berok will link without error, but may produce a broken library.
5587 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
5588 # Determine the default libpath from the value encoded in an empty
5589 # executable.
5590 _LT_SYS_MODULE_PATH_AIX
5591 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5592
5593 _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"
5594 else
5595 if test "$host_cpu" = ia64; then
5596 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
5597 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
5598 _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"
5599 else
5600 # Determine the default libpath from the value encoded in an
5601 # empty executable.
5602 _LT_SYS_MODULE_PATH_AIX
5603 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5604 # Warning - without using the other run time loading flags,
5605 # -berok will link without error, but may produce a broken library.
5606 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
5607 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
5608 # Exported symbols can be pulled into shared objects from archives
5609 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
5610 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5611 # This is similar to how AIX traditionally builds its shared
5612 # libraries.
5613 _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'
5614 fi
5615 fi
5616 ;;
5617
5618 beos*)
5619 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
5620 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5621 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
5622 # support --undefined. This deserves some investigation. FIXME
5623 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5624 else
5625 _LT_TAGVAR(ld_shlibs, $1)=no
5626 fi
5627 ;;
5628
5629 chorus*)
5630 case $cc_basename in
5631 *)
5632 # FIXME: insert proper C++ library support
5633 _LT_TAGVAR(ld_shlibs, $1)=no
5634 ;;
5635 esac
5636 ;;
5637
5638 cygwin* | mingw* | pw32* | cegcc*)
5639 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
5640 # as there is no search path for DLLs.
5641 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5642 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5643 _LT_TAGVAR(always_export_symbols, $1)=no
5644 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
5645
5646 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
5647 _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'
5648 # If the export-symbols file already is a .def file (1st line
5649 # is EXPORTS), use it as is; otherwise, prepend...
5650 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
5651 cp $export_symbols $output_objdir/$soname.def;
5652 else
5653 echo EXPORTS > $output_objdir/$soname.def;
5654 cat $export_symbols >> $output_objdir/$soname.def;
5655 fi~
5656 $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'
5657 else
5658 _LT_TAGVAR(ld_shlibs, $1)=no
5659 fi
5660 ;;
5661 darwin* | rhapsody*)
5662 _LT_DARWIN_LINKER_FEATURES($1)
5663 ;;
5664
5665 dgux*)
5666 case $cc_basename in
5667 ec++*)
5668 # FIXME: insert proper C++ library support
5669 _LT_TAGVAR(ld_shlibs, $1)=no
5670 ;;
5671 ghcx*)
5672 # Green Hills C++ Compiler
5673 # FIXME: insert proper C++ library support
5674 _LT_TAGVAR(ld_shlibs, $1)=no
5675 ;;
5676 *)
5677 # FIXME: insert proper C++ library support
5678 _LT_TAGVAR(ld_shlibs, $1)=no
5679 ;;
5680 esac
5681 ;;
5682
5683 freebsd[[12]]*)
5684 # C++ shared libraries reported to be fairly broken before
5685 # switch to ELF
5686 _LT_TAGVAR(ld_shlibs, $1)=no
5687 ;;
5688
5689 freebsd-elf*)
5690 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5691 ;;
5692
5693 freebsd* | dragonfly*)
5694 # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
5695 # conventions
5696 _LT_TAGVAR(ld_shlibs, $1)=yes
5697 ;;
5698
5699 gnu*)
5700 ;;
5701
5702 hpux9*)
5703 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5704 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5705 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5706 _LT_TAGVAR(hardcode_direct, $1)=yes
5707 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5708 # but as the default
5709 # location of the library.
5710
5711 case $cc_basename in
5712 CC*)
5713 # FIXME: insert proper C++ library support
5714 _LT_TAGVAR(ld_shlibs, $1)=no
5715 ;;
5716 aCC*)
5717 _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'
5718 # Commands to make compiler produce verbose output that lists
5719 # what "hidden" libraries, object files and flags are used when
5720 # linking a shared library.
5721 #
5722 # There doesn't appear to be a way to prevent this compiler from
5723 # explicitly linking system object files so we need to strip them
5724 # from the output so that they don't get included in the library
5725 # dependencies.
5726 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'
5727 ;;
5728 *)
5729 if test "$GXX" = yes; then
5730 _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'
5731 else
5732 # FIXME: insert proper C++ library support
5733 _LT_TAGVAR(ld_shlibs, $1)=no
5734 fi
5735 ;;
5736 esac
5737 ;;
5738
5739 hpux10*|hpux11*)
5740 if test $with_gnu_ld = no; then
5741 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5742 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5743
5744 case $host_cpu in
5745 hppa*64*|ia64*)
5746 ;;
5747 *)
5748 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5749 ;;
5750 esac
5751 fi
5752 case $host_cpu in
5753 hppa*64*|ia64*)
5754 _LT_TAGVAR(hardcode_direct, $1)=no
5755 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5756 ;;
5757 *)
5758 _LT_TAGVAR(hardcode_direct, $1)=yes
5759 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5760 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5761 # but as the default
5762 # location of the library.
5763 ;;
5764 esac
5765
5766 case $cc_basename in
5767 CC*)
5768 # FIXME: insert proper C++ library support
5769 _LT_TAGVAR(ld_shlibs, $1)=no
5770 ;;
5771 aCC*)
5772 case $host_cpu in
5773 hppa*64*)
5774 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5775 ;;
5776 ia64*)
5777 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5778 ;;
5779 *)
5780 _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'
5781 ;;
5782 esac
5783 # Commands to make compiler produce verbose output that lists
5784 # what "hidden" libraries, object files and flags are used when
5785 # linking a shared library.
5786 #
5787 # There doesn't appear to be a way to prevent this compiler from
5788 # explicitly linking system object files so we need to strip them
5789 # from the output so that they don't get included in the library
5790 # dependencies.
5791 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'
5792 ;;
5793 *)
5794 if test "$GXX" = yes; then
5795 if test $with_gnu_ld = no; then
5796 case $host_cpu in
5797 hppa*64*)
5798 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5799 ;;
5800 ia64*)
5801 _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'
5802 ;;
5803 *)
5804 _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'
5805 ;;
5806 esac
5807 fi
5808 else
5809 # FIXME: insert proper C++ library support
5810 _LT_TAGVAR(ld_shlibs, $1)=no
5811 fi
5812 ;;
5813 esac
5814 ;;
5815
5816 interix[[3-9]]*)
5817 _LT_TAGVAR(hardcode_direct, $1)=no
5818 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5819 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5820 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5821 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
5822 # Instead, shared libraries are loaded at an image base (0x10000000 by
5823 # default) and relocated if they conflict, which is a slow very memory
5824 # consuming and fragmenting process. To avoid this, we pick a random,
5825 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
5826 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
5827 _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'
5828 _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'
5829 ;;
5830 irix5* | irix6*)
5831 case $cc_basename in
5832 CC*)
5833 # SGI C++
5834 _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'
5835
5836 # Archives containing C++ object files must be created using
5837 # "CC -ar", where "CC" is the IRIX C++ compiler. This is
5838 # necessary to make sure instantiated templates are included
5839 # in the archive.
5840 _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
5841 ;;
5842 *)
5843 if test "$GXX" = yes; then
5844 if test "$with_gnu_ld" = no; then
5845 _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'
5846 else
5847 _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'
5848 fi
5849 fi
5850 _LT_TAGVAR(link_all_deplibs, $1)=yes
5851 ;;
5852 esac
5853 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5854 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5855 _LT_TAGVAR(inherit_rpath, $1)=yes
5856 ;;
5857
5858 linux* | k*bsd*-gnu)
5859 case $cc_basename in
5860 KCC*)
5861 # Kuck and Associates, Inc. (KAI) C++ Compiler
5862
5863 # KCC will only create a shared library if the output file
5864 # ends with ".so" (or ".sl" for HP-UX), so rename the library
5865 # to its proper name (with version) after linking.
5866 _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'
5867 _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'
5868 # Commands to make compiler produce verbose output that lists
5869 # what "hidden" libraries, object files and flags are used when
5870 # linking a shared library.
5871 #
5872 # There doesn't appear to be a way to prevent this compiler from
5873 # explicitly linking system object files so we need to strip them
5874 # from the output so that they don't get included in the library
5875 # dependencies.
5876 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'
5877
5878 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5879 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5880
5881 # Archives containing C++ object files must be created using
5882 # "CC -Bstatic", where "CC" is the KAI C++ compiler.
5883 _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
5884 ;;
5885 icpc* | ecpc* )
5886 # Intel C++
5887 with_gnu_ld=yes
5888 # version 8.0 and above of icpc choke on multiply defined symbols
5889 # if we add $predep_objects and $postdep_objects, however 7.1 and
5890 # earlier do not add the objects themselves.
5891 case `$CC -V 2>&1` in
5892 *"Version 7."*)
5893 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5894 _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'
5895 ;;
5896 *) # Version 8.0 or newer
5897 tmp_idyn=
5898 case $host_cpu in
5899 ia64*) tmp_idyn=' -i_dynamic';;
5900 esac
5901 _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5902 _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'
5903 ;;
5904 esac
5905 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5906 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5907 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5908 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
5909 ;;
5910 pgCC* | pgcpp*)
5911 # Portland Group C++ compiler
5912 case `$CC -V` in
5913 *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
5914 _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
5915 rm -rf $tpldir~
5916 $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
5917 compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
5918 _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
5919 rm -rf $tpldir~
5920 $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
5921 $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
5922 $RANLIB $oldlib'
5923 _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
5924 rm -rf $tpldir~
5925 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5926 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5927 _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
5928 rm -rf $tpldir~
5929 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5930 $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'
5931 ;;
5932 *) # Version 6 will use weak symbols
5933 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5934 _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'
5935 ;;
5936 esac
5937
5938 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
5939 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5940 _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'
5941 ;;
5942 cxx*)
5943 # Compaq C++
5944 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5945 _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'
5946
5947 runpath_var=LD_RUN_PATH
5948 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
5949 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5950
5951 # Commands to make compiler produce verbose output that lists
5952 # what "hidden" libraries, object files and flags are used when
5953 # linking a shared library.
5954 #
5955 # There doesn't appear to be a way to prevent this compiler from
5956 # explicitly linking system object files so we need to strip them
5957 # from the output so that they don't get included in the library
5958 # dependencies.
5959 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'
5960 ;;
5961 xl*)
5962 # IBM XL 8.0 on PPC, with GNU ld
5963 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5964 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5965 _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5966 if test "x$supports_anon_versioning" = xyes; then
5967 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
5968 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
5969 echo "local: *; };" >> $output_objdir/$libname.ver~
5970 $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
5971 fi
5972 ;;
5973 *)
5974 case `$CC -V 2>&1 | sed 5q` in
5975 *Sun\ C*)
5976 # Sun C++ 5.9
5977 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
5978 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5979 _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'
5980 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
5981 _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'
5982 _LT_TAGVAR(compiler_needs_object, $1)=yes
5983
5984 # Not sure whether something based on
5985 # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
5986 # would be better.
5987 output_verbose_link_cmd='echo'
5988
5989 # Archives containing C++ object files must be created using
5990 # "CC -xar", where "CC" is the Sun C++ compiler. This is
5991 # necessary to make sure instantiated templates are included
5992 # in the archive.
5993 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
5994 ;;
5995 esac
5996 ;;
5997 esac
5998 ;;
5999
6000 lynxos*)
6001 # FIXME: insert proper C++ library support
6002 _LT_TAGVAR(ld_shlibs, $1)=no
6003 ;;
6004
6005 m88k*)
6006 # FIXME: insert proper C++ library support
6007 _LT_TAGVAR(ld_shlibs, $1)=no
6008 ;;
6009
6010 mvs*)
6011 case $cc_basename in
6012 cxx*)
6013 # FIXME: insert proper C++ library support
6014 _LT_TAGVAR(ld_shlibs, $1)=no
6015 ;;
6016 *)
6017 # FIXME: insert proper C++ library support
6018 _LT_TAGVAR(ld_shlibs, $1)=no
6019 ;;
6020 esac
6021 ;;
6022
6023 netbsd*)
6024 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
6025 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
6026 wlarc=
6027 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
6028 _LT_TAGVAR(hardcode_direct, $1)=yes
6029 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6030 fi
6031 # Workaround some broken pre-1.5 toolchains
6032 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
6033 ;;
6034
6035 *nto* | *qnx*)
6036 _LT_TAGVAR(ld_shlibs, $1)=yes
6037 ;;
6038
6039 openbsd2*)
6040 # C++ shared libraries are fairly broken
6041 _LT_TAGVAR(ld_shlibs, $1)=no
6042 ;;
6043
6044 openbsd*)
6045 if test -f /usr/libexec/ld.so; then
6046 _LT_TAGVAR(hardcode_direct, $1)=yes
6047 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6048 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
6049 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
6050 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6051 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
6052 _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'
6053 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
6054 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
6055 fi
6056 output_verbose_link_cmd=echo
6057 else
6058 _LT_TAGVAR(ld_shlibs, $1)=no
6059 fi
6060 ;;
6061
6062 osf3* | osf4* | osf5*)
6063 case $cc_basename in
6064 KCC*)
6065 # Kuck and Associates, Inc. (KAI) C++ Compiler
6066
6067 # KCC will only create a shared library if the output file
6068 # ends with ".so" (or ".sl" for HP-UX), so rename the library
6069 # to its proper name (with version) after linking.
6070 _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'
6071
6072 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6073 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6074
6075 # Archives containing C++ object files must be created using
6076 # the KAI C++ compiler.
6077 case $host in
6078 osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
6079 *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
6080 esac
6081 ;;
6082 RCC*)
6083 # Rational C++ 2.4.1
6084 # FIXME: insert proper C++ library support
6085 _LT_TAGVAR(ld_shlibs, $1)=no
6086 ;;
6087 cxx*)
6088 case $host in
6089 osf3*)
6090 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6091 _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'
6092 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6093 ;;
6094 *)
6095 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
6096 _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'
6097 _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
6098 echo "-hidden">> $lib.exp~
6099 $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~
6100 $RM $lib.exp'
6101 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
6102 ;;
6103 esac
6104
6105 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6106
6107 # Commands to make compiler produce verbose output that lists
6108 # what "hidden" libraries, object files and flags are used when
6109 # linking a shared library.
6110 #
6111 # There doesn't appear to be a way to prevent this compiler from
6112 # explicitly linking system object files so we need to strip them
6113 # from the output so that they don't get included in the library
6114 # dependencies.
6115 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'
6116 ;;
6117 *)
6118 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6119 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6120 case $host in
6121 osf3*)
6122 _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'
6123 ;;
6124 *)
6125 _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'
6126 ;;
6127 esac
6128
6129 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6130 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6131
6132 # Commands to make compiler produce verbose output that lists
6133 # what "hidden" libraries, object files and flags are used when
6134 # linking a shared library.
6135 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6136
6137 else
6138 # FIXME: insert proper C++ library support
6139 _LT_TAGVAR(ld_shlibs, $1)=no
6140 fi
6141 ;;
6142 esac
6143 ;;
6144
6145 psos*)
6146 # FIXME: insert proper C++ library support
6147 _LT_TAGVAR(ld_shlibs, $1)=no
6148 ;;
6149
6150 sunos4*)
6151 case $cc_basename in
6152 CC*)
6153 # Sun C++ 4.x
6154 # FIXME: insert proper C++ library support
6155 _LT_TAGVAR(ld_shlibs, $1)=no
6156 ;;
6157 lcc*)
6158 # Lucid
6159 # FIXME: insert proper C++ library support
6160 _LT_TAGVAR(ld_shlibs, $1)=no
6161 ;;
6162 *)
6163 # FIXME: insert proper C++ library support
6164 _LT_TAGVAR(ld_shlibs, $1)=no
6165 ;;
6166 esac
6167 ;;
6168
6169 solaris*)
6170 case $cc_basename in
6171 CC*)
6172 # Sun C++ 4.2, 5.x and Centerline C++
6173 _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
6174 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
6175 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
6176 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6177 $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'
6178
6179 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
6180 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6181 case $host_os in
6182 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6183 *)
6184 # The compiler driver will combine and reorder linker options,
6185 # but understands `-z linker_flag'.
6186 # Supported since Solaris 2.6 (maybe 2.5.1?)
6187 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
6188 ;;
6189 esac
6190 _LT_TAGVAR(link_all_deplibs, $1)=yes
6191
6192 output_verbose_link_cmd='echo'
6193
6194 # Archives containing C++ object files must be created using
6195 # "CC -xar", where "CC" is the Sun C++ compiler. This is
6196 # necessary to make sure instantiated templates are included
6197 # in the archive.
6198 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
6199 ;;
6200 gcx*)
6201 # Green Hills C++ Compiler
6202 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6203
6204 # The C++ compiler must be used to create the archive.
6205 _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
6206 ;;
6207 *)
6208 # GNU C++ compiler with Solaris linker
6209 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6210 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
6211 if $CC --version | $GREP -v '^2\.7' > /dev/null; then
6212 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6213 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6214 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6215
6216 # Commands to make compiler produce verbose output that lists
6217 # what "hidden" libraries, object files and flags are used when
6218 # linking a shared library.
6219 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6220 else
6221 # g++ 2.7 appears to require `-G' NOT `-shared' on this
6222 # platform.
6223 _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6224 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6225 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6226
6227 # Commands to make compiler produce verbose output that lists
6228 # what "hidden" libraries, object files and flags are used when
6229 # linking a shared library.
6230 output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6231 fi
6232
6233 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
6234 case $host_os in
6235 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6236 *)
6237 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
6238 ;;
6239 esac
6240 fi
6241 ;;
6242 esac
6243 ;;
6244
6245 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
6246 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6247 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6248 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6249 runpath_var='LD_RUN_PATH'
6250
6251 case $cc_basename in
6252 CC*)
6253 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6254 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6255 ;;
6256 *)
6257 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6258 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6259 ;;
6260 esac
6261 ;;
6262
6263 sysv5* | sco3.2v5* | sco5v6*)
6264 # Note: We can NOT use -z defs as we might desire, because we do not
6265 # link with -lc, and that would cause any symbols used from libc to
6266 # always be unresolved, which means just about no library would
6267 # ever link correctly. If we're not using GNU ld we use -z text
6268 # though, which does catch some bad symbols but isn't as heavy-handed
6269 # as -z defs.
6270 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6271 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
6272 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6273 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6274 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
6275 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
6276 _LT_TAGVAR(link_all_deplibs, $1)=yes
6277 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
6278 runpath_var='LD_RUN_PATH'
6279
6280 case $cc_basename in
6281 CC*)
6282 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6283 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6284 ;;
6285 *)
6286 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6287 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6288 ;;
6289 esac
6290 ;;
6291
6292 tandem*)
6293 case $cc_basename in
6294 NCC*)
6295 # NonStop-UX NCC 3.20
6296 # FIXME: insert proper C++ library support
6297 _LT_TAGVAR(ld_shlibs, $1)=no
6298 ;;
6299 *)
6300 # FIXME: insert proper C++ library support
6301 _LT_TAGVAR(ld_shlibs, $1)=no
6302 ;;
6303 esac
6304 ;;
6305
6306 vxworks*)
6307 # FIXME: insert proper C++ library support
6308 _LT_TAGVAR(ld_shlibs, $1)=no
6309 ;;
6310
6311 *)
6312 # FIXME: insert proper C++ library support
6313 _LT_TAGVAR(ld_shlibs, $1)=no
6314 ;;
6315 esac
6316
6317 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
6318 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
6319
6320 _LT_TAGVAR(GCC, $1)="$GXX"
6321 _LT_TAGVAR(LD, $1)="$LD"
6322
6323 ## CAVEAT EMPTOR:
6324 ## There is no encapsulation within the following macros, do not change
6325 ## the running order or otherwise move them around unless you know exactly
6326 ## what you are doing...
6327 _LT_SYS_HIDDEN_LIBDEPS($1)
6328 _LT_COMPILER_PIC($1)
6329 _LT_COMPILER_C_O($1)
6330 _LT_COMPILER_FILE_LOCKS($1)
6331 _LT_LINKER_SHLIBS($1)
6332 _LT_SYS_DYNAMIC_LINKER($1)
6333 _LT_LINKER_HARDCODE_LIBPATH($1)
6334
6335 _LT_CONFIG($1)
6336 fi # test -n "$compiler"
6337
6338 CC=$lt_save_CC
6339 LDCXX=$LD
6340 LD=$lt_save_LD
6341 GCC=$lt_save_GCC
6342 with_gnu_ld=$lt_save_with_gnu_ld
6343 lt_cv_path_LDCXX=$lt_cv_path_LD
6344 lt_cv_path_LD=$lt_save_path_LD
6345 lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
6346 lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
6347 fi # test "$_lt_caught_CXX_error" != yes
6348
6349 AC_LANG_POP
6350 ])# _LT_LANG_CXX_CONFIG
6351
6352
6353 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
6354 # ---------------------------------
6355 # Figure out "hidden" library dependencies from verbose
6356 # compiler output when linking a shared library.
6357 # Parse the compiler output and extract the necessary
6358 # objects, libraries and library flags.
6359 m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
6360 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
6361 # Dependencies to place before and after the object being linked:
6362 _LT_TAGVAR(predep_objects, $1)=
6363 _LT_TAGVAR(postdep_objects, $1)=
6364 _LT_TAGVAR(predeps, $1)=
6365 _LT_TAGVAR(postdeps, $1)=
6366 _LT_TAGVAR(compiler_lib_search_path, $1)=
6367
6368 dnl we can't use the lt_simple_compile_test_code here,
6369 dnl because it contains code intended for an executable,
6370 dnl not a library. It's possible we should let each
6371 dnl tag define a new lt_????_link_test_code variable,
6372 dnl but it's only used here...
6373 m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
6374 int a;
6375 void foo (void) { a = 0; }
6376 _LT_EOF
6377 ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
6378 class Foo
6379 {
6380 public:
6381 Foo (void) { a = 0; }
6382 private:
6383 int a;
6384 };
6385 _LT_EOF
6386 ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
6387 subroutine foo
6388 implicit none
6389 integer*4 a
6390 a=0
6391 return
6392 end
6393 _LT_EOF
6394 ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
6395 subroutine foo
6396 implicit none
6397 integer a
6398 a=0
6399 return
6400 end
6401 _LT_EOF
6402 ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
6403 public class foo {
6404 private int a;
6405 public void bar (void) {
6406 a = 0;
6407 }
6408 };
6409 _LT_EOF
6410 ])
6411 dnl Parse the compiler output and extract the necessary
6412 dnl objects, libraries and library flags.
6413 if AC_TRY_EVAL(ac_compile); then
6414 # Parse the compiler output and extract the necessary
6415 # objects, libraries and library flags.
6416
6417 # Sentinel used to keep track of whether or not we are before
6418 # the conftest object file.
6419 pre_test_object_deps_done=no
6420
6421 for p in `eval "$output_verbose_link_cmd"`; do
6422 case $p in
6423
6424 -L* | -R* | -l*)
6425 # Some compilers place space between "-{L,R}" and the path.
6426 # Remove the space.
6427 if test $p = "-L" ||
6428 test $p = "-R"; then
6429 prev=$p
6430 continue
6431 else
6432 prev=
6433 fi
6434
6435 if test "$pre_test_object_deps_done" = no; then
6436 case $p in
6437 -L* | -R*)
6438 # Internal compiler library paths should come after those
6439 # provided the user. The postdeps already come after the
6440 # user supplied libs so there is no need to process them.
6441 if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
6442 _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
6443 else
6444 _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
6445 fi
6446 ;;
6447 # The "-l" case would never come before the object being
6448 # linked, so don't bother handling this case.
6449 esac
6450 else
6451 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
6452 _LT_TAGVAR(postdeps, $1)="${prev}${p}"
6453 else
6454 _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
6455 fi
6456 fi
6457 ;;
6458
6459 *.$objext)
6460 # This assumes that the test object file only shows up
6461 # once in the compiler output.
6462 if test "$p" = "conftest.$objext"; then
6463 pre_test_object_deps_done=yes
6464 continue
6465 fi
6466
6467 if test "$pre_test_object_deps_done" = no; then
6468 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
6469 _LT_TAGVAR(predep_objects, $1)="$p"
6470 else
6471 _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
6472 fi
6473 else
6474 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
6475 _LT_TAGVAR(postdep_objects, $1)="$p"
6476 else
6477 _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
6478 fi
6479 fi
6480 ;;
6481
6482 *) ;; # Ignore the rest.
6483
6484 esac
6485 done
6486
6487 # Clean up.
6488 rm -f a.out a.exe
6489 else
6490 echo "libtool.m4: error: problem compiling $1 test program"
6491 fi
6492
6493 $RM -f confest.$objext
6494
6495 # PORTME: override above test on systems where it is broken
6496 m4_if([$1], [CXX],
6497 [case $host_os in
6498 interix[[3-9]]*)
6499 # Interix 3.5 installs completely hosed .la files for C++, so rather than
6500 # hack all around it, let's just trust "g++" to DTRT.
6501 _LT_TAGVAR(predep_objects,$1)=
6502 _LT_TAGVAR(postdep_objects,$1)=
6503 _LT_TAGVAR(postdeps,$1)=
6504 ;;
6505
6506 linux*)
6507 case `$CC -V 2>&1 | sed 5q` in
6508 *Sun\ C*)
6509 # Sun C++ 5.9
6510
6511 # The more standards-conforming stlport4 library is
6512 # incompatible with the Cstd library. Avoid specifying
6513 # it if it's in CXXFLAGS. Ignore libCrun as
6514 # -library=stlport4 depends on it.
6515 case " $CXX $CXXFLAGS " in
6516 *" -library=stlport4 "*)
6517 solaris_use_stlport4=yes
6518 ;;
6519 esac
6520
6521 if test "$solaris_use_stlport4" != yes; then
6522 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6523 fi
6524 ;;
6525 esac
6526 ;;
6527
6528 solaris*)
6529 case $cc_basename in
6530 CC*)
6531 # The more standards-conforming stlport4 library is
6532 # incompatible with the Cstd library. Avoid specifying
6533 # it if it's in CXXFLAGS. Ignore libCrun as
6534 # -library=stlport4 depends on it.
6535 case " $CXX $CXXFLAGS " in
6536 *" -library=stlport4 "*)
6537 solaris_use_stlport4=yes
6538 ;;
6539 esac
6540
6541 # Adding this requires a known-good setup of shared libraries for
6542 # Sun compiler versions before 5.6, else PIC objects from an old
6543 # archive will be linked into the output, leading to subtle bugs.
6544 if test "$solaris_use_stlport4" != yes; then
6545 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6546 fi
6547 ;;
6548 esac
6549 ;;
6550 esac
6551 ])
6552
6553 case " $_LT_TAGVAR(postdeps, $1) " in
6554 *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
6555 esac
6556 _LT_TAGVAR(compiler_lib_search_dirs, $1)=
6557 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
6558 _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
6559 fi
6560 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
6561 [The directories searched by this compiler when creating a shared library])
6562 _LT_TAGDECL([], [predep_objects], [1],
6563 [Dependencies to place before and after the objects being linked to
6564 create a shared library])
6565 _LT_TAGDECL([], [postdep_objects], [1])
6566 _LT_TAGDECL([], [predeps], [1])
6567 _LT_TAGDECL([], [postdeps], [1])
6568 _LT_TAGDECL([], [compiler_lib_search_path], [1],
6569 [The library search path used internally by the compiler when linking
6570 a shared library])
6571 ])# _LT_SYS_HIDDEN_LIBDEPS
6572
6573
6574 # _LT_PROG_F77
6575 # ------------
6576 # Since AC_PROG_F77 is broken, in that it returns the empty string
6577 # if there is no fortran compiler, we have our own version here.
6578 m4_defun([_LT_PROG_F77],
6579 [
6580 pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
6581 AC_PROG_F77
6582 if test -z "$F77" || test "X$F77" = "Xno"; then
6583 _lt_disable_F77=yes
6584 fi
6585 popdef([AC_MSG_ERROR])
6586 ])# _LT_PROG_F77
6587
6588 dnl aclocal-1.4 backwards compatibility:
6589 dnl AC_DEFUN([_LT_PROG_F77], [])
6590
6591
6592 # _LT_LANG_F77_CONFIG([TAG])
6593 # --------------------------
6594 # Ensure that the configuration variables for a Fortran 77 compiler are
6595 # suitably defined. These variables are subsequently used by _LT_CONFIG
6596 # to write the compiler configuration to `libtool'.
6597 m4_defun([_LT_LANG_F77_CONFIG],
6598 [AC_REQUIRE([_LT_PROG_F77])dnl
6599 AC_LANG_PUSH(Fortran 77)
6600
6601 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6602 _LT_TAGVAR(allow_undefined_flag, $1)=
6603 _LT_TAGVAR(always_export_symbols, $1)=no
6604 _LT_TAGVAR(archive_expsym_cmds, $1)=
6605 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6606 _LT_TAGVAR(hardcode_direct, $1)=no
6607 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6608 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6609 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6610 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6611 _LT_TAGVAR(hardcode_minus_L, $1)=no
6612 _LT_TAGVAR(hardcode_automatic, $1)=no
6613 _LT_TAGVAR(inherit_rpath, $1)=no
6614 _LT_TAGVAR(module_cmds, $1)=
6615 _LT_TAGVAR(module_expsym_cmds, $1)=
6616 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6617 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6618 _LT_TAGVAR(no_undefined_flag, $1)=
6619 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6620 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6621
6622 # Source file extension for f77 test sources.
6623 ac_ext=f
6624
6625 # Object file extension for compiled f77 test sources.
6626 objext=o
6627 _LT_TAGVAR(objext, $1)=$objext
6628
6629 # No sense in running all these tests if we already determined that
6630 # the F77 compiler isn't working. Some variables (like enable_shared)
6631 # are currently assumed to apply to all compilers on this platform,
6632 # and will be corrupted by setting them based on a non-working compiler.
6633 if test "$_lt_disable_F77" != yes; then
6634 # Code to be used in simple compile tests
6635 lt_simple_compile_test_code="\
6636 subroutine t
6637 return
6638 end
6639 "
6640
6641 # Code to be used in simple link tests
6642 lt_simple_link_test_code="\
6643 program t
6644 end
6645 "
6646
6647 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6648 _LT_TAG_COMPILER
6649
6650 # save warnings/boilerplate of simple test code
6651 _LT_COMPILER_BOILERPLATE
6652 _LT_LINKER_BOILERPLATE
6653
6654 # Allow CC to be a program name with arguments.
6655 lt_save_CC="$CC"
6656 lt_save_GCC=$GCC
6657 CC=${F77-"f77"}
6658 compiler=$CC
6659 _LT_TAGVAR(compiler, $1)=$CC
6660 _LT_CC_BASENAME([$compiler])
6661 GCC=$G77
6662 if test -n "$compiler"; then
6663 AC_MSG_CHECKING([if libtool supports shared libraries])
6664 AC_MSG_RESULT([$can_build_shared])
6665
6666 AC_MSG_CHECKING([whether to build shared libraries])
6667 test "$can_build_shared" = "no" && enable_shared=no
6668
6669 # On AIX, shared libraries and static libraries use the same namespace, and
6670 # are all built from PIC.
6671 case $host_os in
6672 aix3*)
6673 test "$enable_shared" = yes && enable_static=no
6674 if test -n "$RANLIB"; then
6675 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6676 postinstall_cmds='$RANLIB $lib'
6677 fi
6678 ;;
6679 aix[[4-9]]*)
6680 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6681 test "$enable_shared" = yes && enable_static=no
6682 fi
6683 ;;
6684 esac
6685 AC_MSG_RESULT([$enable_shared])
6686
6687 AC_MSG_CHECKING([whether to build static libraries])
6688 # Make sure either enable_shared or enable_static is yes.
6689 test "$enable_shared" = yes || enable_static=yes
6690 AC_MSG_RESULT([$enable_static])
6691
6692 _LT_TAGVAR(GCC, $1)="$G77"
6693 _LT_TAGVAR(LD, $1)="$LD"
6694
6695 ## CAVEAT EMPTOR:
6696 ## There is no encapsulation within the following macros, do not change
6697 ## the running order or otherwise move them around unless you know exactly
6698 ## what you are doing...
6699 _LT_COMPILER_PIC($1)
6700 _LT_COMPILER_C_O($1)
6701 _LT_COMPILER_FILE_LOCKS($1)
6702 _LT_LINKER_SHLIBS($1)
6703 _LT_SYS_DYNAMIC_LINKER($1)
6704 _LT_LINKER_HARDCODE_LIBPATH($1)
6705
6706 _LT_CONFIG($1)
6707 fi # test -n "$compiler"
6708
6709 GCC=$lt_save_GCC
6710 CC="$lt_save_CC"
6711 fi # test "$_lt_disable_F77" != yes
6712
6713 AC_LANG_POP
6714 ])# _LT_LANG_F77_CONFIG
6715
6716
6717 # _LT_PROG_FC
6718 # -----------
6719 # Since AC_PROG_FC is broken, in that it returns the empty string
6720 # if there is no fortran compiler, we have our own version here.
6721 m4_defun([_LT_PROG_FC],
6722 [
6723 pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
6724 AC_PROG_FC
6725 if test -z "$FC" || test "X$FC" = "Xno"; then
6726 _lt_disable_FC=yes
6727 fi
6728 popdef([AC_MSG_ERROR])
6729 ])# _LT_PROG_FC
6730
6731 dnl aclocal-1.4 backwards compatibility:
6732 dnl AC_DEFUN([_LT_PROG_FC], [])
6733
6734
6735 # _LT_LANG_FC_CONFIG([TAG])
6736 # -------------------------
6737 # Ensure that the configuration variables for a Fortran compiler are
6738 # suitably defined. These variables are subsequently used by _LT_CONFIG
6739 # to write the compiler configuration to `libtool'.
6740 m4_defun([_LT_LANG_FC_CONFIG],
6741 [AC_REQUIRE([_LT_PROG_FC])dnl
6742 AC_LANG_PUSH(Fortran)
6743
6744 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6745 _LT_TAGVAR(allow_undefined_flag, $1)=
6746 _LT_TAGVAR(always_export_symbols, $1)=no
6747 _LT_TAGVAR(archive_expsym_cmds, $1)=
6748 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6749 _LT_TAGVAR(hardcode_direct, $1)=no
6750 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6751 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6752 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6753 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6754 _LT_TAGVAR(hardcode_minus_L, $1)=no
6755 _LT_TAGVAR(hardcode_automatic, $1)=no
6756 _LT_TAGVAR(inherit_rpath, $1)=no
6757 _LT_TAGVAR(module_cmds, $1)=
6758 _LT_TAGVAR(module_expsym_cmds, $1)=
6759 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6760 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6761 _LT_TAGVAR(no_undefined_flag, $1)=
6762 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6763 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6764
6765 # Source file extension for fc test sources.
6766 ac_ext=${ac_fc_srcext-f}
6767
6768 # Object file extension for compiled fc test sources.
6769 objext=o
6770 _LT_TAGVAR(objext, $1)=$objext
6771
6772 # No sense in running all these tests if we already determined that
6773 # the FC compiler isn't working. Some variables (like enable_shared)
6774 # are currently assumed to apply to all compilers on this platform,
6775 # and will be corrupted by setting them based on a non-working compiler.
6776 if test "$_lt_disable_FC" != yes; then
6777 # Code to be used in simple compile tests
6778 lt_simple_compile_test_code="\
6779 subroutine t
6780 return
6781 end
6782 "
6783
6784 # Code to be used in simple link tests
6785 lt_simple_link_test_code="\
6786 program t
6787 end
6788 "
6789
6790 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6791 _LT_TAG_COMPILER
6792
6793 # save warnings/boilerplate of simple test code
6794 _LT_COMPILER_BOILERPLATE
6795 _LT_LINKER_BOILERPLATE
6796
6797 # Allow CC to be a program name with arguments.
6798 lt_save_CC="$CC"
6799 lt_save_GCC=$GCC
6800 CC=${FC-"f95"}
6801 compiler=$CC
6802 GCC=$ac_cv_fc_compiler_gnu
6803
6804 _LT_TAGVAR(compiler, $1)=$CC
6805 _LT_CC_BASENAME([$compiler])
6806
6807 if test -n "$compiler"; then
6808 AC_MSG_CHECKING([if libtool supports shared libraries])
6809 AC_MSG_RESULT([$can_build_shared])
6810
6811 AC_MSG_CHECKING([whether to build shared libraries])
6812 test "$can_build_shared" = "no" && enable_shared=no
6813
6814 # On AIX, shared libraries and static libraries use the same namespace, and
6815 # are all built from PIC.
6816 case $host_os in
6817 aix3*)
6818 test "$enable_shared" = yes && enable_static=no
6819 if test -n "$RANLIB"; then
6820 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6821 postinstall_cmds='$RANLIB $lib'
6822 fi
6823 ;;
6824 aix[[4-9]]*)
6825 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6826 test "$enable_shared" = yes && enable_static=no
6827 fi
6828 ;;
6829 esac
6830 AC_MSG_RESULT([$enable_shared])
6831
6832 AC_MSG_CHECKING([whether to build static libraries])
6833 # Make sure either enable_shared or enable_static is yes.
6834 test "$enable_shared" = yes || enable_static=yes
6835 AC_MSG_RESULT([$enable_static])
6836
6837 _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
6838 _LT_TAGVAR(LD, $1)="$LD"
6839
6840 ## CAVEAT EMPTOR:
6841 ## There is no encapsulation within the following macros, do not change
6842 ## the running order or otherwise move them around unless you know exactly
6843 ## what you are doing...
6844 _LT_SYS_HIDDEN_LIBDEPS($1)
6845 _LT_COMPILER_PIC($1)
6846 _LT_COMPILER_C_O($1)
6847 _LT_COMPILER_FILE_LOCKS($1)
6848 _LT_LINKER_SHLIBS($1)
6849 _LT_SYS_DYNAMIC_LINKER($1)
6850 _LT_LINKER_HARDCODE_LIBPATH($1)
6851
6852 _LT_CONFIG($1)
6853 fi # test -n "$compiler"
6854
6855 GCC=$lt_save_GCC
6856 CC="$lt_save_CC"
6857 fi # test "$_lt_disable_FC" != yes
6858
6859 AC_LANG_POP
6860 ])# _LT_LANG_FC_CONFIG
6861
6862
6863 # _LT_LANG_GCJ_CONFIG([TAG])
6864 # --------------------------
6865 # Ensure that the configuration variables for the GNU Java Compiler compiler
6866 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6867 # to write the compiler configuration to `libtool'.
6868 m4_defun([_LT_LANG_GCJ_CONFIG],
6869 [AC_REQUIRE([LT_PROG_GCJ])dnl
6870 AC_LANG_SAVE
6871
6872 # Source file extension for Java test sources.
6873 ac_ext=java
6874
6875 # Object file extension for compiled Java test sources.
6876 objext=o
6877 _LT_TAGVAR(objext, $1)=$objext
6878
6879 # Code to be used in simple compile tests
6880 lt_simple_compile_test_code="class foo {}"
6881
6882 # Code to be used in simple link tests
6883 lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
6884
6885 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6886 _LT_TAG_COMPILER
6887
6888 # save warnings/boilerplate of simple test code
6889 _LT_COMPILER_BOILERPLATE
6890 _LT_LINKER_BOILERPLATE
6891
6892 # Allow CC to be a program name with arguments.
6893 lt_save_CC="$CC"
6894 lt_save_GCC=$GCC
6895 GCC=yes
6896 CC=${GCJ-"gcj"}
6897 compiler=$CC
6898 _LT_TAGVAR(compiler, $1)=$CC
6899 _LT_TAGVAR(LD, $1)="$LD"
6900 _LT_CC_BASENAME([$compiler])
6901
6902 # GCJ did not exist at the time GCC didn't implicitly link libc in.
6903 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6904
6905 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6906
6907 ## CAVEAT EMPTOR:
6908 ## There is no encapsulation within the following macros, do not change
6909 ## the running order or otherwise move them around unless you know exactly
6910 ## what you are doing...
6911 if test -n "$compiler"; then
6912 _LT_COMPILER_NO_RTTI($1)
6913 _LT_COMPILER_PIC($1)
6914 _LT_COMPILER_C_O($1)
6915 _LT_COMPILER_FILE_LOCKS($1)
6916 _LT_LINKER_SHLIBS($1)
6917 _LT_LINKER_HARDCODE_LIBPATH($1)
6918
6919 _LT_CONFIG($1)
6920 fi
6921
6922 AC_LANG_RESTORE
6923
6924 GCC=$lt_save_GCC
6925 CC="$lt_save_CC"
6926 ])# _LT_LANG_GCJ_CONFIG
6927
6928
6929 # _LT_LANG_RC_CONFIG([TAG])
6930 # -------------------------
6931 # Ensure that the configuration variables for the Windows resource compiler
6932 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6933 # to write the compiler configuration to `libtool'.
6934 m4_defun([_LT_LANG_RC_CONFIG],
6935 [AC_REQUIRE([LT_PROG_RC])dnl
6936 AC_LANG_SAVE
6937
6938 # Source file extension for RC test sources.
6939 ac_ext=rc
6940
6941 # Object file extension for compiled RC test sources.
6942 objext=o
6943 _LT_TAGVAR(objext, $1)=$objext
6944
6945 # Code to be used in simple compile tests
6946 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
6947
6948 # Code to be used in simple link tests
6949 lt_simple_link_test_code="$lt_simple_compile_test_code"
6950
6951 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6952 _LT_TAG_COMPILER
6953
6954 # save warnings/boilerplate of simple test code
6955 _LT_COMPILER_BOILERPLATE
6956 _LT_LINKER_BOILERPLATE
6957
6958 # Allow CC to be a program name with arguments.
6959 lt_save_CC="$CC"
6960 lt_save_GCC=$GCC
6961 GCC=
6962 CC=${RC-"windres"}
6963 compiler=$CC
6964 _LT_TAGVAR(compiler, $1)=$CC
6965 _LT_CC_BASENAME([$compiler])
6966 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
6967
6968 if test -n "$compiler"; then
6969 :
6970 _LT_CONFIG($1)
6971 fi
6972
6973 GCC=$lt_save_GCC
6974 AC_LANG_RESTORE
6975 CC="$lt_save_CC"
6976 ])# _LT_LANG_RC_CONFIG
6977
6978
6979 # LT_PROG_GCJ
6980 # -----------
6981 AC_DEFUN([LT_PROG_GCJ],
6982 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
6983 [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
6984 [AC_CHECK_TOOL(GCJ, gcj,)
6985 test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
6986 AC_SUBST(GCJFLAGS)])])[]dnl
6987 ])
6988
6989 # Old name:
6990 AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
6991 dnl aclocal-1.4 backwards compatibility:
6992 dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
6993
6994
6995 # LT_PROG_RC
6996 # ----------
6997 AC_DEFUN([LT_PROG_RC],
6998 [AC_CHECK_TOOL(RC, windres,)
6999 ])
7000
7001 # Old name:
7002 AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
7003 dnl aclocal-1.4 backwards compatibility:
7004 dnl AC_DEFUN([LT_AC_PROG_RC], [])
7005
7006
7007 # _LT_DECL_EGREP
7008 # --------------
7009 # If we don't have a new enough Autoconf to choose the best grep
7010 # available, choose the one first in the user's PATH.
7011 m4_defun([_LT_DECL_EGREP],
7012 [AC_REQUIRE([AC_PROG_EGREP])dnl
7013 AC_REQUIRE([AC_PROG_FGREP])dnl
7014 test -z "$GREP" && GREP=grep
7015 _LT_DECL([], [GREP], [1], [A grep program that handles long lines])
7016 _LT_DECL([], [EGREP], [1], [An ERE matcher])
7017 _LT_DECL([], [FGREP], [1], [A literal string matcher])
7018 dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
7019 AC_SUBST([GREP])
7020 ])
7021
7022
7023 # _LT_DECL_OBJDUMP
7024 # --------------
7025 # If we don't have a new enough Autoconf to choose the best objdump
7026 # available, choose the one first in the user's PATH.
7027 m4_defun([_LT_DECL_OBJDUMP],
7028 [AC_CHECK_TOOL(OBJDUMP, objdump, false)
7029 test -z "$OBJDUMP" && OBJDUMP=objdump
7030 _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
7031 AC_SUBST([OBJDUMP])
7032 ])
7033
7034
7035 # _LT_DECL_SED
7036 # ------------
7037 # Check for a fully-functional sed program, that truncates
7038 # as few characters as possible. Prefer GNU sed if found.
7039 m4_defun([_LT_DECL_SED],
7040 [AC_PROG_SED
7041 test -z "$SED" && SED=sed
7042 Xsed="$SED -e 1s/^X//"
7043 _LT_DECL([], [SED], [1], [A sed program that does not truncate output])
7044 _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
7045 [Sed that helps us avoid accidentally triggering echo(1) options like -n])
7046 ])# _LT_DECL_SED
7047
7048 m4_ifndef([AC_PROG_SED], [
7049 ############################################################
7050 # NOTE: This macro has been submitted for inclusion into #
7051 # GNU Autoconf as AC_PROG_SED. When it is available in #
7052 # a released version of Autoconf we should remove this #
7053 # macro and use it instead. #
7054 ############################################################
7055
7056 m4_defun([AC_PROG_SED],
7057 [AC_MSG_CHECKING([for a sed that does not truncate output])
7058 AC_CACHE_VAL(lt_cv_path_SED,
7059 [# Loop through the user's path and test for sed and gsed.
7060 # Then use that list of sed's as ones to test for truncation.
7061 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7062 for as_dir in $PATH
7063 do
7064 IFS=$as_save_IFS
7065 test -z "$as_dir" && as_dir=.
7066 for lt_ac_prog in sed gsed; do
7067 for ac_exec_ext in '' $ac_executable_extensions; do
7068 if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
7069 lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
7070 fi
7071 done
7072 done
7073 done
7074 IFS=$as_save_IFS
7075 lt_ac_max=0
7076 lt_ac_count=0
7077 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
7078 # along with /bin/sed that truncates output.
7079 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
7080 test ! -f $lt_ac_sed && continue
7081 cat /dev/null > conftest.in
7082 lt_ac_count=0
7083 echo $ECHO_N "0123456789$ECHO_C" >conftest.in
7084 # Check for GNU sed and select it if it is found.
7085 if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
7086 lt_cv_path_SED=$lt_ac_sed
7087 break
7088 fi
7089 while true; do
7090 cat conftest.in conftest.in >conftest.tmp
7091 mv conftest.tmp conftest.in
7092 cp conftest.in conftest.nl
7093 echo >>conftest.nl
7094 $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
7095 cmp -s conftest.out conftest.nl || break
7096 # 10000 chars as input seems more than enough
7097 test $lt_ac_count -gt 10 && break
7098 lt_ac_count=`expr $lt_ac_count + 1`
7099 if test $lt_ac_count -gt $lt_ac_max; then
7100 lt_ac_max=$lt_ac_count
7101 lt_cv_path_SED=$lt_ac_sed
7102 fi
7103 done
7104 done
7105 ])
7106 SED=$lt_cv_path_SED
7107 AC_SUBST([SED])
7108 AC_MSG_RESULT([$SED])
7109 ])#AC_PROG_SED
7110 ])#m4_ifndef
7111
7112 # Old name:
7113 AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
7114 dnl aclocal-1.4 backwards compatibility:
7115 dnl AC_DEFUN([LT_AC_PROG_SED], [])
7116
7117
7118 # _LT_CHECK_SHELL_FEATURES
7119 # ------------------------
7120 # Find out whether the shell is Bourne or XSI compatible,
7121 # or has some other useful features.
7122 m4_defun([_LT_CHECK_SHELL_FEATURES],
7123 [AC_MSG_CHECKING([whether the shell understands some XSI constructs])
7124 # Try some XSI features
7125 xsi_shell=no
7126 ( _lt_dummy="a/b/c"
7127 test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
7128 = c,a/b,, \
7129 && eval 'test $(( 1 + 1 )) -eq 2 \
7130 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
7131 && xsi_shell=yes
7132 AC_MSG_RESULT([$xsi_shell])
7133 _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
7134
7135 AC_MSG_CHECKING([whether the shell understands "+="])
7136 lt_shell_append=no
7137 ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
7138 >/dev/null 2>&1 \
7139 && lt_shell_append=yes
7140 AC_MSG_RESULT([$lt_shell_append])
7141 _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
7142
7143 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
7144 lt_unset=unset
7145 else
7146 lt_unset=false
7147 fi
7148 _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
7149
7150 # test EBCDIC or ASCII
7151 case `echo X|tr X '\101'` in
7152 A) # ASCII based system
7153 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
7154 lt_SP2NL='tr \040 \012'
7155 lt_NL2SP='tr \015\012 \040\040'
7156 ;;
7157 *) # EBCDIC based system
7158 lt_SP2NL='tr \100 \n'
7159 lt_NL2SP='tr \r\n \100\100'
7160 ;;
7161 esac
7162 _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
7163 _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
7164 ])# _LT_CHECK_SHELL_FEATURES
7165
7166
7167 # _LT_PROG_XSI_SHELLFNS
7168 # ---------------------
7169 # Bourne and XSI compatible variants of some useful shell functions.
7170 m4_defun([_LT_PROG_XSI_SHELLFNS],
7171 [case $xsi_shell in
7172 yes)
7173 cat << \_LT_EOF >> "$cfgfile"
7174
7175 # func_dirname file append nondir_replacement
7176 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7177 # otherwise set result to NONDIR_REPLACEMENT.
7178 func_dirname ()
7179 {
7180 case ${1} in
7181 */*) func_dirname_result="${1%/*}${2}" ;;
7182 * ) func_dirname_result="${3}" ;;
7183 esac
7184 }
7185
7186 # func_basename file
7187 func_basename ()
7188 {
7189 func_basename_result="${1##*/}"
7190 }
7191
7192 # func_dirname_and_basename file append nondir_replacement
7193 # perform func_basename and func_dirname in a single function
7194 # call:
7195 # dirname: Compute the dirname of FILE. If nonempty,
7196 # add APPEND to the result, otherwise set result
7197 # to NONDIR_REPLACEMENT.
7198 # value returned in "$func_dirname_result"
7199 # basename: Compute filename of FILE.
7200 # value retuned in "$func_basename_result"
7201 # Implementation must be kept synchronized with func_dirname
7202 # and func_basename. For efficiency, we do not delegate to
7203 # those functions but instead duplicate the functionality here.
7204 func_dirname_and_basename ()
7205 {
7206 case ${1} in
7207 */*) func_dirname_result="${1%/*}${2}" ;;
7208 * ) func_dirname_result="${3}" ;;
7209 esac
7210 func_basename_result="${1##*/}"
7211 }
7212
7213 # func_stripname prefix suffix name
7214 # strip PREFIX and SUFFIX off of NAME.
7215 # PREFIX and SUFFIX must not contain globbing or regex special
7216 # characters, hashes, percent signs, but SUFFIX may contain a leading
7217 # dot (in which case that matches only a dot).
7218 func_stripname ()
7219 {
7220 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
7221 # positional parameters, so assign one to ordinary parameter first.
7222 func_stripname_result=${3}
7223 func_stripname_result=${func_stripname_result#"${1}"}
7224 func_stripname_result=${func_stripname_result%"${2}"}
7225 }
7226
7227 # func_opt_split
7228 func_opt_split ()
7229 {
7230 func_opt_split_opt=${1%%=*}
7231 func_opt_split_arg=${1#*=}
7232 }
7233
7234 # func_lo2o object
7235 func_lo2o ()
7236 {
7237 case ${1} in
7238 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
7239 *) func_lo2o_result=${1} ;;
7240 esac
7241 }
7242
7243 # func_xform libobj-or-source
7244 func_xform ()
7245 {
7246 func_xform_result=${1%.*}.lo
7247 }
7248
7249 # func_arith arithmetic-term...
7250 func_arith ()
7251 {
7252 func_arith_result=$(( $[*] ))
7253 }
7254
7255 # func_len string
7256 # STRING may not start with a hyphen.
7257 func_len ()
7258 {
7259 func_len_result=${#1}
7260 }
7261
7262 _LT_EOF
7263 ;;
7264 *) # Bourne compatible functions.
7265 cat << \_LT_EOF >> "$cfgfile"
7266
7267 # func_dirname file append nondir_replacement
7268 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7269 # otherwise set result to NONDIR_REPLACEMENT.
7270 func_dirname ()
7271 {
7272 # Extract subdirectory from the argument.
7273 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
7274 if test "X$func_dirname_result" = "X${1}"; then
7275 func_dirname_result="${3}"
7276 else
7277 func_dirname_result="$func_dirname_result${2}"
7278 fi
7279 }
7280
7281 # func_basename file
7282 func_basename ()
7283 {
7284 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
7285 }
7286
7287 dnl func_dirname_and_basename
7288 dnl A portable version of this function is already defined in general.m4sh
7289 dnl so there is no need for it here.
7290
7291 # func_stripname prefix suffix name
7292 # strip PREFIX and SUFFIX off of NAME.
7293 # PREFIX and SUFFIX must not contain globbing or regex special
7294 # characters, hashes, percent signs, but SUFFIX may contain a leading
7295 # dot (in which case that matches only a dot).
7296 # func_strip_suffix prefix name
7297 func_stripname ()
7298 {
7299 case ${2} in
7300 .*) func_stripname_result=`$ECHO "X${3}" \
7301 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
7302 *) func_stripname_result=`$ECHO "X${3}" \
7303 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
7304 esac
7305 }
7306
7307 # sed scripts:
7308 my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
7309 my_sed_long_arg='1s/^-[[^=]]*=//'
7310
7311 # func_opt_split
7312 func_opt_split ()
7313 {
7314 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
7315 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
7316 }
7317
7318 # func_lo2o object
7319 func_lo2o ()
7320 {
7321 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
7322 }
7323
7324 # func_xform libobj-or-source
7325 func_xform ()
7326 {
7327 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
7328 }
7329
7330 # func_arith arithmetic-term...
7331 func_arith ()
7332 {
7333 func_arith_result=`expr "$[@]"`
7334 }
7335
7336 # func_len string
7337 # STRING may not start with a hyphen.
7338 func_len ()
7339 {
7340 func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
7341 }
7342
7343 _LT_EOF
7344 esac
7345
7346 case $lt_shell_append in
7347 yes)
7348 cat << \_LT_EOF >> "$cfgfile"
7349
7350 # func_append var value
7351 # Append VALUE to the end of shell variable VAR.
7352 func_append ()
7353 {
7354 eval "$[1]+=\$[2]"
7355 }
7356 _LT_EOF
7357 ;;
7358 *)
7359 cat << \_LT_EOF >> "$cfgfile"
7360
7361 # func_append var value
7362 # Append VALUE to the end of shell variable VAR.
7363 func_append ()
7364 {
7365 eval "$[1]=\$$[1]\$[2]"
7366 }
7367
7368 _LT_EOF
7369 ;;
7370 esac
7371 ])
7372
+0
-370
acinclude/ltoptions.m4 less more
0 ##############################################################################
1 # Helper functions for option handling. -*- Autoconf -*-
2 #
3 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 # Written by Gary V. Vaughan, 2004
5 #
6 # This file is free software; the Free Software Foundation gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9
10 # serial 6 ltoptions.m4
11
12 # This is to help aclocal find these macros, as it can't see m4_define.
13 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
14
15
16 # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
17 # ------------------------------------------
18 m4_define([_LT_MANGLE_OPTION],
19 [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
20
21
22 # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
23 # ---------------------------------------
24 # Set option OPTION-NAME for macro MACRO-NAME, and if there is a
25 # matching handler defined, dispatch to it. Other OPTION-NAMEs are
26 # saved as a flag.
27 m4_define([_LT_SET_OPTION],
28 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
29 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
30 _LT_MANGLE_DEFUN([$1], [$2]),
31 [m4_warning([Unknown $1 option `$2'])])[]dnl
32 ])
33
34
35 # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
36 # ------------------------------------------------------------
37 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
38 m4_define([_LT_IF_OPTION],
39 [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
40
41
42 # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
43 # -------------------------------------------------------
44 # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
45 # are set.
46 m4_define([_LT_UNLESS_OPTIONS],
47 [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
48 [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
49 [m4_define([$0_found])])])[]dnl
50 m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
51 ])[]dnl
52 ])
53
54
55 # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
56 # ----------------------------------------
57 # OPTION-LIST is a space-separated list of Libtool options associated
58 # with MACRO-NAME. If any OPTION has a matching handler declared with
59 # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
60 # the unknown option and exit.
61 m4_defun([_LT_SET_OPTIONS],
62 [# Set options
63 m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
64 [_LT_SET_OPTION([$1], _LT_Option)])
65
66 m4_if([$1],[LT_INIT],[
67 dnl
68 dnl Simply set some default values (i.e off) if boolean options were not
69 dnl specified:
70 _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
71 ])
72 _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
73 ])
74 dnl
75 dnl If no reference was made to various pairs of opposing options, then
76 dnl we run the default mode handler for the pair. For example, if neither
77 dnl `shared' nor `disable-shared' was passed, we enable building of shared
78 dnl archives by default:
79 _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
80 _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
81 _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
82 _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
83 [_LT_ENABLE_FAST_INSTALL])
84 ])
85 ])# _LT_SET_OPTIONS
86
87
88 ## --------------------------------- ##
89 ## Macros to handle LT_INIT options. ##
90 ## --------------------------------- ##
91
92 # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
93 # -----------------------------------------
94 m4_define([_LT_MANGLE_DEFUN],
95 [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
96
97
98 # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
99 # -----------------------------------------------
100 m4_define([LT_OPTION_DEFINE],
101 [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
102 ])# LT_OPTION_DEFINE
103
104
105 # dlopen
106 # ------
107 LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
108 ])
109
110 AU_DEFUN([AC_LIBTOOL_DLOPEN],
111 [_LT_SET_OPTION([LT_INIT], [dlopen])
112 AC_DIAGNOSE([obsolete],
113 [$0: Remove this warning and the call to _LT_SET_OPTION when you
114 put the `dlopen' option into LT_INIT's first parameter.])
115 ])
116
117 dnl aclocal-1.4 backwards compatibility:
118 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
119
120
121 # win32-dll
122 # ---------
123 # Declare package support for building win32 dll's.
124 LT_OPTION_DEFINE([LT_INIT], [win32-dll],
125 [enable_win32_dll=yes
126
127 case $host in
128 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
129 AC_CHECK_TOOL(AS, as, false)
130 AC_CHECK_TOOL(DLLTOOL, dlltool, false)
131 AC_CHECK_TOOL(OBJDUMP, objdump, false)
132 ;;
133 esac
134
135 test -z "$AS" && AS=as
136 _LT_DECL([], [AS], [0], [Assembler program])dnl
137
138 test -z "$DLLTOOL" && DLLTOOL=dlltool
139 _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
140
141 test -z "$OBJDUMP" && OBJDUMP=objdump
142 _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
143 ])# win32-dll
144
145 AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
146 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
147 _LT_SET_OPTION([LT_INIT], [win32-dll])
148 AC_DIAGNOSE([obsolete],
149 [$0: Remove this warning and the call to _LT_SET_OPTION when you
150 put the `win32-dll' option into LT_INIT's first parameter.])
151 ])
152
153 dnl aclocal-1.4 backwards compatibility:
154 dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
155
156
157 # _LT_ENABLE_SHARED([DEFAULT])
158 # ----------------------------
159 # implement the --enable-shared flag, and supports the `shared' and
160 # `disable-shared' LT_INIT options.
161 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
162 m4_define([_LT_ENABLE_SHARED],
163 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
164 AC_ARG_ENABLE([shared],
165 [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
166 [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
167 [p=${PACKAGE-default}
168 case $enableval in
169 yes) enable_shared=yes ;;
170 no) enable_shared=no ;;
171 *)
172 enable_shared=no
173 # Look at the argument we got. We use all the common list separators.
174 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
175 for pkg in $enableval; do
176 IFS="$lt_save_ifs"
177 if test "X$pkg" = "X$p"; then
178 enable_shared=yes
179 fi
180 done
181 IFS="$lt_save_ifs"
182 ;;
183 esac],
184 [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
185
186 _LT_DECL([build_libtool_libs], [enable_shared], [0],
187 [Whether or not to build shared libraries])
188 ])# _LT_ENABLE_SHARED
189
190 LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
191 LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
192
193 # Old names:
194 AC_DEFUN([AC_ENABLE_SHARED],
195 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
196 ])
197
198 AC_DEFUN([AC_DISABLE_SHARED],
199 [_LT_SET_OPTION([LT_INIT], [disable-shared])
200 ])
201
202 AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
203 AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
204
205 dnl aclocal-1.4 backwards compatibility:
206 dnl AC_DEFUN([AM_ENABLE_SHARED], [])
207 dnl AC_DEFUN([AM_DISABLE_SHARED], [])
208
209
210
211 # _LT_ENABLE_STATIC([DEFAULT])
212 # ----------------------------
213 # implement the --enable-static flag, and support the `static' and
214 # `disable-static' LT_INIT options.
215 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
216 m4_define([_LT_ENABLE_STATIC],
217 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
218 AC_ARG_ENABLE([static],
219 [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
220 [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
221 [p=${PACKAGE-default}
222 case $enableval in
223 yes) enable_static=yes ;;
224 no) enable_static=no ;;
225 *)
226 enable_static=no
227 # Look at the argument we got. We use all the common list separators.
228 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
229 for pkg in $enableval; do
230 IFS="$lt_save_ifs"
231 if test "X$pkg" = "X$p"; then
232 enable_static=yes
233 fi
234 done
235 IFS="$lt_save_ifs"
236 ;;
237 esac],
238 [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
239
240 _LT_DECL([build_old_libs], [enable_static], [0],
241 [Whether or not to build static libraries])
242 ])# _LT_ENABLE_STATIC
243
244 LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
245 LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
246
247 # Old names:
248 AC_DEFUN([AC_ENABLE_STATIC],
249 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
250 ])
251
252 AC_DEFUN([AC_DISABLE_STATIC],
253 [_LT_SET_OPTION([LT_INIT], [disable-static])
254 ])
255
256 AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
257 AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
258
259 dnl aclocal-1.4 backwards compatibility:
260 dnl AC_DEFUN([AM_ENABLE_STATIC], [])
261 dnl AC_DEFUN([AM_DISABLE_STATIC], [])
262
263
264
265 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
266 # ----------------------------------
267 # implement the --enable-fast-install flag, and support the `fast-install'
268 # and `disable-fast-install' LT_INIT options.
269 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
270 m4_define([_LT_ENABLE_FAST_INSTALL],
271 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
272 AC_ARG_ENABLE([fast-install],
273 [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
274 [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
275 [p=${PACKAGE-default}
276 case $enableval in
277 yes) enable_fast_install=yes ;;
278 no) enable_fast_install=no ;;
279 *)
280 enable_fast_install=no
281 # Look at the argument we got. We use all the common list separators.
282 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
283 for pkg in $enableval; do
284 IFS="$lt_save_ifs"
285 if test "X$pkg" = "X$p"; then
286 enable_fast_install=yes
287 fi
288 done
289 IFS="$lt_save_ifs"
290 ;;
291 esac],
292 [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
293
294 _LT_DECL([fast_install], [enable_fast_install], [0],
295 [Whether or not to optimize for fast installation])dnl
296 ])# _LT_ENABLE_FAST_INSTALL
297
298 LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
299 LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
300
301 # Old names:
302 AU_DEFUN([AC_ENABLE_FAST_INSTALL],
303 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
304 AC_DIAGNOSE([obsolete],
305 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
306 the `fast-install' option into LT_INIT's first parameter.])
307 ])
308
309 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
310 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
311 AC_DIAGNOSE([obsolete],
312 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
313 the `disable-fast-install' option into LT_INIT's first parameter.])
314 ])
315
316 dnl aclocal-1.4 backwards compatibility:
317 dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
318 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
319
320
321 # _LT_WITH_PIC([MODE])
322 # --------------------
323 # implement the --with-pic flag, and support the `pic-only' and `no-pic'
324 # LT_INIT options.
325 # MODE is either `yes' or `no'. If omitted, it defaults to `both'.
326 m4_define([_LT_WITH_PIC],
327 [AC_ARG_WITH([pic],
328 [AS_HELP_STRING([--with-pic],
329 [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
330 [pic_mode="$withval"],
331 [pic_mode=default])
332
333 test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
334
335 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
336 ])# _LT_WITH_PIC
337
338 LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
339 LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
340
341 # Old name:
342 AU_DEFUN([AC_LIBTOOL_PICMODE],
343 [_LT_SET_OPTION([LT_INIT], [pic-only])
344 AC_DIAGNOSE([obsolete],
345 [$0: Remove this warning and the call to _LT_SET_OPTION when you
346 put the `pic-only' option into LT_INIT's first parameter.])
347 ])
348
349 dnl aclocal-1.4 backwards compatibility:
350 dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
351
352 ## ----------------- ##
353 ## LTDL_INIT Options ##
354 ## ----------------- ##
355
356 m4_define([_LTDL_MODE], [])
357 LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
358 [m4_define([_LTDL_MODE], [nonrecursive])])
359 LT_OPTION_DEFINE([LTDL_INIT], [recursive],
360 [m4_define([_LTDL_MODE], [recursive])])
361 LT_OPTION_DEFINE([LTDL_INIT], [subproject],
362 [m4_define([_LTDL_MODE], [subproject])])
363
364 m4_define([_LTDL_TYPE], [])
365 LT_OPTION_DEFINE([LTDL_INIT], [installable],
366 [m4_define([_LTDL_TYPE], [installable])])
367 LT_OPTION_DEFINE([LTDL_INIT], [convenience],
368 [m4_define([_LTDL_TYPE], [convenience])])
369
+0
-125
acinclude/ltsugar.m4 less more
0 ##############################################################################
1 # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
2 #
3 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 # Written by Gary V. Vaughan, 2004
5 #
6 # This file is free software; the Free Software Foundation gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9
10 # serial 6 ltsugar.m4
11
12 # This is to help aclocal find these macros, as it can't see m4_define.
13 AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
14
15
16 # lt_join(SEP, ARG1, [ARG2...])
17 # -----------------------------
18 # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
19 # associated separator.
20 # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
21 # versions in m4sugar had bugs.
22 m4_define([lt_join],
23 [m4_if([$#], [1], [],
24 [$#], [2], [[$2]],
25 [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
26 m4_define([_lt_join],
27 [m4_if([$#$2], [2], [],
28 [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
29
30
31 # lt_car(LIST)
32 # lt_cdr(LIST)
33 # ------------
34 # Manipulate m4 lists.
35 # These macros are necessary as long as will still need to support
36 # Autoconf-2.59 which quotes differently.
37 m4_define([lt_car], [[$1]])
38 m4_define([lt_cdr],
39 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
40 [$#], 1, [],
41 [m4_dquote(m4_shift($@))])])
42 m4_define([lt_unquote], $1)
43
44
45 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
46 # ------------------------------------------
47 # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
48 # Note that neither SEPARATOR nor STRING are expanded; they are appended
49 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
50 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
51 # than defined and empty).
52 #
53 # This macro is needed until we can rely on Autoconf 2.62, since earlier
54 # versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
55 m4_define([lt_append],
56 [m4_define([$1],
57 m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
58
59
60
61 # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
62 # ----------------------------------------------------------
63 # Produce a SEP delimited list of all paired combinations of elements of
64 # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
65 # has the form PREFIXmINFIXSUFFIXn.
66 # Needed until we can rely on m4_combine added in Autoconf 2.62.
67 m4_define([lt_combine],
68 [m4_if(m4_eval([$# > 3]), [1],
69 [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
70 [[m4_foreach([_Lt_prefix], [$2],
71 [m4_foreach([_Lt_suffix],
72 ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
73 [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
74
75
76 # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
77 # -----------------------------------------------------------------------
78 # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
79 # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
80 m4_define([lt_if_append_uniq],
81 [m4_ifdef([$1],
82 [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
83 [lt_append([$1], [$2], [$3])$4],
84 [$5])],
85 [lt_append([$1], [$2], [$3])$4])])
86
87
88 # lt_dict_add(DICT, KEY, VALUE)
89 # -----------------------------
90 m4_define([lt_dict_add],
91 [m4_define([$1($2)], [$3])])
92
93
94 # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
95 # --------------------------------------------
96 m4_define([lt_dict_add_subkey],
97 [m4_define([$1($2:$3)], [$4])])
98
99
100 # lt_dict_fetch(DICT, KEY, [SUBKEY])
101 # ----------------------------------
102 m4_define([lt_dict_fetch],
103 [m4_ifval([$3],
104 m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
105 m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
106
107
108 # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
109 # -----------------------------------------------------------------
110 m4_define([lt_if_dict_fetch],
111 [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
112 [$5],
113 [$6])])
114
115
116 # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
117 # --------------------------------------------------------------
118 m4_define([lt_dict_filter],
119 [m4_if([$5], [], [],
120 [lt_join(m4_quote(m4_default([$4], [[, ]])),
121 lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
122 [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
123 ])
124
+0
-25
acinclude/ltversion.m4 less more
0 ##############################################################################
1 # ltversion.m4 -- version numbers -*- Autoconf -*-
2 #
3 # Copyright (C) 2004 Free Software Foundation, Inc.
4 # Written by Scott James Remnant, 2004
5 #
6 # This file is free software; the Free Software Foundation gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9
10 # Generated from ltversion.in.
11
12 # serial 3012 ltversion.m4
13 # This file is part of GNU Libtool
14
15 m4_define([LT_PACKAGE_VERSION], [2.2.6])
16 m4_define([LT_PACKAGE_REVISION], [1.3012])
17
18 AC_DEFUN([LTVERSION_VERSION],
19 [macro_version='2.2.6'
20 macro_revision='1.3012'
21 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 _LT_DECL(, macro_revision, 0)
23 ])
24
+0
-93
acinclude/lt~obsolete.m4 less more
0 ##############################################################################
1 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
2 #
3 # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
4 # Written by Scott James Remnant, 2004.
5 #
6 # This file is free software; the Free Software Foundation gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9
10 # serial 4 lt~obsolete.m4
11
12 # These exist entirely to fool aclocal when bootstrapping libtool.
13 #
14 # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
15 # which have later been changed to m4_define as they aren't part of the
16 # exported API, or moved to Autoconf or Automake where they belong.
17 #
18 # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
19 # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
20 # using a macro with the same name in our local m4/libtool.m4 it'll
21 # pull the old libtool.m4 in (it doesn't see our shiny new m4_define
22 # and doesn't know about Autoconf macros at all.)
23 #
24 # So we provide this file, which has a silly filename so it's always
25 # included after everything else. This provides aclocal with the
26 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
27 # because those macros already exist, or will be overwritten later.
28 # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
29 #
30 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
31 # Yes, that means every name once taken will need to remain here until
32 # we give up compatibility with versions before 1.7, at which point
33 # we need to keep only those names which we still refer to.
34
35 # This is to help aclocal find these macros, as it can't see m4_define.
36 AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
37
38 m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
39 m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
40 m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
41 m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
42 m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
43 m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
44 m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
45 m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
46 m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
47 m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
48 m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
49 m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
50 m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
51 m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
52 m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
53 m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
54 m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
55 m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
56 m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
57 m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
58 m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
59 m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
60 m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
61 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
62 m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
63 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
64 m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
65 m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
66 m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
67 m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
68 m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
69 m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
70 m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
71 m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
72 m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
73 m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
74 m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
75 m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
76 m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
77 m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
78 m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
79 m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
80 m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
81 m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
82 m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
83 m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
84 m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
85 m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
86 m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
87 m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
88 m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
89 m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
90 m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
91 m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
92 m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
0 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1 #
2 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
21 # the same distribution terms that you use for the rest of that program.
22
23 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
24 # ----------------------------------
0 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1 # serial 12 (pkg-config-0.29.2)
2
3 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
4 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
5 dnl
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
10 dnl
11 dnl This program is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 dnl 02111-1307, USA.
20 dnl
21 dnl As a special exception to the GNU General Public License, if you
22 dnl distribute this file as part of a program that contains a
23 dnl configuration script generated by Autoconf, you may include it under
24 dnl the same distribution terms that you use for the rest of that
25 dnl program.
26
27 dnl PKG_PREREQ(MIN-VERSION)
28 dnl -----------------------
29 dnl Since: 0.29
30 dnl
31 dnl Verify that the version of the pkg-config macros are at least
32 dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
33 dnl installed version of pkg-config, this checks the developer's version
34 dnl of pkg.m4 when generating configure.
35 dnl
36 dnl To ensure that this macro is defined, also add:
37 dnl m4_ifndef([PKG_PREREQ],
38 dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
39 dnl
40 dnl See the "Since" comment for each macro you use to see what version
41 dnl of the macros you require.
42 m4_defun([PKG_PREREQ],
43 [m4_define([PKG_MACROS_VERSION], [0.29.2])
44 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
45 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
46 ])dnl PKG_PREREQ
47
48 dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
49 dnl ----------------------------------
50 dnl Since: 0.16
51 dnl
52 dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
53 dnl first found in the path. Checks that the version of pkg-config found
54 dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
55 dnl used since that's the first version where most current features of
56 dnl pkg-config existed.
2557 AC_DEFUN([PKG_PROG_PKG_CONFIG],
2658 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
27 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
28 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
59 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
60 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
61 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
62 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
63 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
64
2965 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3066 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
3167 fi
3874 AC_MSG_RESULT([no])
3975 PKG_CONFIG=""
4076 fi
41
42 fi[]dnl
43 ])# PKG_PROG_PKG_CONFIG
44
45 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
46 #
47 # Check to see whether a particular set of modules exists. Similar
48 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
49 #
50 #
51 # Similar to PKG_CHECK_MODULES, make sure that the first instance of
52 # this or PKG_CHECK_MODULES is called, or make sure to call
53 # PKG_CHECK_EXISTS manually
54 # --------------------------------------------------------------
77 fi[]dnl
78 ])dnl PKG_PROG_PKG_CONFIG
79
80 dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
81 dnl -------------------------------------------------------------------
82 dnl Since: 0.18
83 dnl
84 dnl Check to see whether a particular set of modules exists. Similar to
85 dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
86 dnl
87 dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
88 dnl only at the first occurence in configure.ac, so if the first place
89 dnl it's called might be skipped (such as if it is within an "if", you
90 dnl have to call PKG_CHECK_EXISTS manually
5591 AC_DEFUN([PKG_CHECK_EXISTS],
5692 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
5793 if test -n "$PKG_CONFIG" && \
5894 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
59 m4_ifval([$2], [$2], [:])
95 m4_default([$2], [:])
6096 m4_ifvaln([$3], [else
6197 $3])dnl
6298 fi])
6399
64
65 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
66 # ---------------------------------------------
100 dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
101 dnl ---------------------------------------------
102 dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
103 dnl pkg_failed based on the result.
67104 m4_define([_PKG_CONFIG],
68 [if test -n "$PKG_CONFIG"; then
69 if test -n "$$1"; then
70 pkg_cv_[]$1="$$1"
71 else
72 PKG_CHECK_EXISTS([$3],
73 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
74 [pkg_failed=yes])
75 fi
76 else
77 pkg_failed=untried
78 fi[]dnl
79 ])# _PKG_CONFIG
80
81 # _PKG_SHORT_ERRORS_SUPPORTED
82 # -----------------------------
105 [if test -n "$$1"; then
106 pkg_cv_[]$1="$$1"
107 elif test -n "$PKG_CONFIG"; then
108 PKG_CHECK_EXISTS([$3],
109 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
110 test "x$?" != "x0" && pkg_failed=yes ],
111 [pkg_failed=yes])
112 else
113 pkg_failed=untried
114 fi[]dnl
115 ])dnl _PKG_CONFIG
116
117 dnl _PKG_SHORT_ERRORS_SUPPORTED
118 dnl ---------------------------
119 dnl Internal check to see if pkg-config supports short errors.
83120 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
84121 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
85122 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
87124 else
88125 _pkg_short_errors_supported=no
89126 fi[]dnl
90 ])# _PKG_SHORT_ERRORS_SUPPORTED
91
92
93 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
94 # [ACTION-IF-NOT-FOUND])
95 #
96 #
97 # Note that if there is a possibility the first call to
98 # PKG_CHECK_MODULES might not happen, you should be sure to include an
99 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
100 #
101 #
102 # --------------------------------------------------------------
127 ])dnl _PKG_SHORT_ERRORS_SUPPORTED
128
129
130 dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
131 dnl [ACTION-IF-NOT-FOUND])
132 dnl --------------------------------------------------------------
133 dnl Since: 0.4.0
134 dnl
135 dnl Note that if there is a possibility the first call to
136 dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
137 dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
103138 AC_DEFUN([PKG_CHECK_MODULES],
104139 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
105140 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
106141 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
107142
108143 pkg_failed=no
109 AC_MSG_CHECKING([for $1])
144 AC_MSG_CHECKING([for $2])
110145
111146 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
112147 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
116151 See the pkg-config man page for more details.])
117152
118153 if test $pkg_failed = yes; then
154 AC_MSG_RESULT([no])
119155 _PKG_SHORT_ERRORS_SUPPORTED
120156 if test $_pkg_short_errors_supported = yes; then
121 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
122 else
123 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
157 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
158 else
159 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
124160 fi
125161 # Put the nasty error message in config.log where it belongs
126162 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
127163
128 ifelse([$4], , [AC_MSG_ERROR(dnl
164 m4_default([$4], [AC_MSG_ERROR(
129165 [Package requirements ($2) were not met:
130166
131167 $$1_PKG_ERRORS
133169 Consider adjusting the PKG_CONFIG_PATH environment variable if you
134170 installed software in a non-standard prefix.
135171
136 _PKG_TEXT
137 ])],
138 [AC_MSG_RESULT([no])
139 $4])
172 _PKG_TEXT])[]dnl
173 ])
140174 elif test $pkg_failed = untried; then
141 ifelse([$4], , [AC_MSG_FAILURE(dnl
175 AC_MSG_RESULT([no])
176 m4_default([$4], [AC_MSG_FAILURE(
142177 [The pkg-config script could not be found or is too old. Make sure it
143178 is in your PATH or set the PKG_CONFIG environment variable to the full
144179 path to pkg-config.
145180
146181 _PKG_TEXT
147182
148 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
149 [$4])
183 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
184 ])
150185 else
151186 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
152187 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
153188 AC_MSG_RESULT([yes])
154 ifelse([$3], , :, [$3])
155 fi[]dnl
156 ])# PKG_CHECK_MODULES
189 $3
190 fi[]dnl
191 ])dnl PKG_CHECK_MODULES
192
193
194 dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
195 dnl [ACTION-IF-NOT-FOUND])
196 dnl ---------------------------------------------------------------------
197 dnl Since: 0.29
198 dnl
199 dnl Checks for existence of MODULES and gathers its build flags with
200 dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
201 dnl and VARIABLE-PREFIX_LIBS from --libs.
202 dnl
203 dnl Note that if there is a possibility the first call to
204 dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
205 dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
206 dnl configure.ac.
207 AC_DEFUN([PKG_CHECK_MODULES_STATIC],
208 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
209 _save_PKG_CONFIG=$PKG_CONFIG
210 PKG_CONFIG="$PKG_CONFIG --static"
211 PKG_CHECK_MODULES($@)
212 PKG_CONFIG=$_save_PKG_CONFIG[]dnl
213 ])dnl PKG_CHECK_MODULES_STATIC
214
215
216 dnl PKG_INSTALLDIR([DIRECTORY])
217 dnl -------------------------
218 dnl Since: 0.27
219 dnl
220 dnl Substitutes the variable pkgconfigdir as the location where a module
221 dnl should install pkg-config .pc files. By default the directory is
222 dnl $libdir/pkgconfig, but the default can be changed by passing
223 dnl DIRECTORY. The user can override through the --with-pkgconfigdir
224 dnl parameter.
225 AC_DEFUN([PKG_INSTALLDIR],
226 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
227 m4_pushdef([pkg_description],
228 [pkg-config installation directory @<:@]pkg_default[@:>@])
229 AC_ARG_WITH([pkgconfigdir],
230 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
231 [with_pkgconfigdir=]pkg_default)
232 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
233 m4_popdef([pkg_default])
234 m4_popdef([pkg_description])
235 ])dnl PKG_INSTALLDIR
236
237
238 dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
239 dnl --------------------------------
240 dnl Since: 0.27
241 dnl
242 dnl Substitutes the variable noarch_pkgconfigdir as the location where a
243 dnl module should install arch-independent pkg-config .pc files. By
244 dnl default the directory is $datadir/pkgconfig, but the default can be
245 dnl changed by passing DIRECTORY. The user can override through the
246 dnl --with-noarch-pkgconfigdir parameter.
247 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
248 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
249 m4_pushdef([pkg_description],
250 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
251 AC_ARG_WITH([noarch-pkgconfigdir],
252 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
253 [with_noarch_pkgconfigdir=]pkg_default)
254 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
255 m4_popdef([pkg_default])
256 m4_popdef([pkg_description])
257 ])dnl PKG_NOARCH_INSTALLDIR
258
259
260 dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
261 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
262 dnl -------------------------------------------
263 dnl Since: 0.28
264 dnl
265 dnl Retrieves the value of the pkg-config variable for the given module.
266 AC_DEFUN([PKG_CHECK_VAR],
267 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
268 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
269
270 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
271 AS_VAR_COPY([$1], [pkg_cv_][$1])
272
273 AS_VAR_IF([$1], [""], [$5], [$4])dnl
274 ])dnl PKG_CHECK_VAR
44 # stolen from Manish Singh
55 # Shamelessly stolen from Owen Taylor
66
7 # serial 1
7 # serial 2
88
99 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1010 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
1111 dnl
1212 AC_DEFUN([AM_PATH_SDL2],
13 [dnl
13 [dnl
1414 dnl Get the cflags and libraries from the sdl2-config script
1515 dnl
1616 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
7979 dnl checks the results of sdl2-config to some extent
8080 dnl
8181 rm -f conf.sdltest
82 AC_TRY_RUN([
82 AC_RUN_IFELSE([AC_LANG_SOURCE([[
8383 #include <stdio.h>
8484 #include <stdlib.h>
85 #include <string.h>
8685 #include "SDL.h"
87
88 char*
89 my_strdup (char *str)
90 {
91 char *new_str;
92
93 if (str)
94 {
95 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
96 strcpy (new_str, str);
97 }
98 else
99 new_str = NULL;
100
101 return new_str;
102 }
10386
10487 int main (int argc, char *argv[])
10588 {
10689 int major, minor, micro;
107 char *tmp_version;
90 FILE *fp = fopen("conf.sdltest", "w");
10891
109 /* This hangs on some systems (?)
110 system ("touch conf.sdltest");
111 */
112 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
92 if (fp) fclose(fp);
11393
114 /* HP/UX 9 (%@#!) writes to sscanf strings */
115 tmp_version = my_strdup("$min_sdl_version");
116 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
94 if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
11795 printf("%s, bad version string\n", "$min_sdl_version");
11896 exit(1);
11997 }
136114 }
137115 }
138116
139 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
117 ]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
140118 CFLAGS="$ac_save_CFLAGS"
141119 CXXFLAGS="$ac_save_CXXFLAGS"
142120 LIBS="$ac_save_LIBS"
164142 CFLAGS="$CFLAGS $SDL_CFLAGS"
165143 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
166144 LIBS="$LIBS $SDL_LIBS"
167 AC_TRY_LINK([
145 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
168146 #include <stdio.h>
169147 #include "SDL.h"
170148
172150 { return 0; }
173151 #undef main
174152 #define main K_and_R_C_main
175 ], [ return 0; ],
153 ]], [[ return 0; ]])],
176154 [ echo "*** The test program compiled, but did not run. This usually means"
177155 echo "*** that the run-time linker is not finding SDL or finding the wrong"
178156 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+0
-8345
aclocal.m4 less more
0 ##############################################################################
1 # Based on libtool-2.2.6a
2 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
3 #
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
5 # 2006, 2007, 2008 Free Software Foundation, Inc.
6 # Written by Gordon Matzigkeit, 1996
7 #
8 # This file is free software; the Free Software Foundation gives
9 # unlimited permission to copy and/or distribute it, with or without
10 # modifications, as long as this notice is preserved.
11
12 m4_define([_LT_COPYING], [dnl
13 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
14 # 2006, 2007, 2008 Free Software Foundation, Inc.
15 # Written by Gordon Matzigkeit, 1996
16 #
17 # This file is part of GNU Libtool.
18 #
19 # GNU Libtool is free software; you can redistribute it and/or
20 # modify it under the terms of the GNU General Public License as
21 # published by the Free Software Foundation; either version 2 of
22 # the License, or (at your option) any later version.
23 #
24 # As a special exception to the GNU General Public License,
25 # if you distribute this file as part of a program or library that
26 # is built using GNU Libtool, you may include this file under the
27 # same distribution terms that you use for the rest of that program.
28 #
29 # GNU Libtool is distributed in the hope that it will be useful,
30 # but WITHOUT ANY WARRANTY; without even the implied warranty of
31 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 # GNU General Public License for more details.
33 #
34 # You should have received a copy of the GNU General Public License
35 # along with GNU Libtool; see the file COPYING. If not, a copy
36 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
37 # obtained by writing to the Free Software Foundation, Inc.,
38 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39 ])
40
41 # serial 56 LT_INIT
42
43
44 # LT_PREREQ(VERSION)
45 # ------------------
46 # Complain and exit if this libtool version is less that VERSION.
47 m4_defun([LT_PREREQ],
48 [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
49 [m4_default([$3],
50 [m4_fatal([Libtool version $1 or higher is required],
51 63)])],
52 [$2])])
53
54
55 # _LT_CHECK_BUILDDIR
56 # ------------------
57 # Complain if the absolute build directory name contains unusual characters
58 m4_defun([_LT_CHECK_BUILDDIR],
59 [case `pwd` in
60 *\ * | *\ *)
61 AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
62 esac
63 ])
64
65
66 # LT_INIT([OPTIONS])
67 # ------------------
68 AC_DEFUN([LT_INIT],
69 [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
70 AC_BEFORE([$0], [LT_LANG])dnl
71 AC_BEFORE([$0], [LT_OUTPUT])dnl
72 AC_BEFORE([$0], [LTDL_INIT])dnl
73 m4_require([_LT_CHECK_BUILDDIR])dnl
74
75 dnl Autoconf doesn't catch unexpanded LT_ macros by default:
76 m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
77 m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
78 dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
79 dnl unless we require an AC_DEFUNed macro:
80 AC_REQUIRE([LTOPTIONS_VERSION])dnl
81 AC_REQUIRE([LTSUGAR_VERSION])dnl
82 AC_REQUIRE([LTVERSION_VERSION])dnl
83 AC_REQUIRE([LTOBSOLETE_VERSION])dnl
84 m4_require([_LT_PROG_LTMAIN])dnl
85
86 dnl Parse OPTIONS
87 _LT_SET_OPTIONS([$0], [$1])
88
89 # This can be used to rebuild libtool when needed
90 LIBTOOL_DEPS="$ltmain"
91
92 # Always use our own libtool.
93 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
94 AC_SUBST(LIBTOOL)dnl
95
96 _LT_SETUP
97
98 # Only expand once:
99 m4_define([LT_INIT])
100 ])# LT_INIT
101
102 # Old names:
103 AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
104 AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
105 dnl aclocal-1.4 backwards compatibility:
106 dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
107 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
108
109
110 # _LT_CC_BASENAME(CC)
111 # -------------------
112 # Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
113 m4_defun([_LT_CC_BASENAME],
114 [for cc_temp in $1""; do
115 case $cc_temp in
116 compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
117 distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
118 \-*) ;;
119 *) break;;
120 esac
121 done
122 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
123 ])
124
125
126 # _LT_FILEUTILS_DEFAULTS
127 # ----------------------
128 # It is okay to use these file commands and assume they have been set
129 # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
130 m4_defun([_LT_FILEUTILS_DEFAULTS],
131 [: ${CP="cp -f"}
132 : ${MV="mv -f"}
133 : ${RM="rm -f"}
134 ])# _LT_FILEUTILS_DEFAULTS
135
136
137 # _LT_SETUP
138 # ---------
139 m4_defun([_LT_SETUP],
140 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
141 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
142 _LT_DECL([], [host_alias], [0], [The host system])dnl
143 _LT_DECL([], [host], [0])dnl
144 _LT_DECL([], [host_os], [0])dnl
145 dnl
146 _LT_DECL([], [build_alias], [0], [The build system])dnl
147 _LT_DECL([], [build], [0])dnl
148 _LT_DECL([], [build_os], [0])dnl
149 dnl
150 AC_REQUIRE([AC_PROG_CC])dnl
151 AC_REQUIRE([LT_PATH_LD])dnl
152 AC_REQUIRE([LT_PATH_NM])dnl
153 dnl
154 AC_REQUIRE([AC_PROG_LN_S])dnl
155 test -z "$LN_S" && LN_S="ln -s"
156 _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
157 dnl
158 AC_REQUIRE([LT_CMD_MAX_LEN])dnl
159 _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
160 _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
161 dnl
162 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
163 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
164 m4_require([_LT_CMD_RELOAD])dnl
165 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
166 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
167 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
168
169 _LT_CONFIG_LIBTOOL_INIT([
170 # See if we are running on zsh, and set the options which allow our
171 # commands through without removal of \ escapes INIT.
172 if test -n "\${ZSH_VERSION+set}" ; then
173 setopt NO_GLOB_SUBST
174 fi
175 ])
176 if test -n "${ZSH_VERSION+set}" ; then
177 setopt NO_GLOB_SUBST
178 fi
179
180 _LT_CHECK_OBJDIR
181
182 m4_require([_LT_TAG_COMPILER])dnl
183 _LT_PROG_ECHO_BACKSLASH
184
185 case $host_os in
186 aix3*)
187 # AIX sometimes has problems with the GCC collect2 program. For some
188 # reason, if we set the COLLECT_NAMES environment variable, the problems
189 # vanish in a puff of smoke.
190 if test "X${COLLECT_NAMES+set}" != Xset; then
191 COLLECT_NAMES=
192 export COLLECT_NAMES
193 fi
194 ;;
195 esac
196
197 # Sed substitution that helps us do robust quoting. It backslashifies
198 # metacharacters that are still active within double-quoted strings.
199 sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
200
201 # Same as above, but do not quote variable references.
202 double_quote_subst='s/\([["`\\]]\)/\\\1/g'
203
204 # Sed substitution to delay expansion of an escaped shell variable in a
205 # double_quote_subst'ed string.
206 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
207
208 # Sed substitution to delay expansion of an escaped single quote.
209 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
210
211 # Sed substitution to avoid accidental globbing in evaled expressions
212 no_glob_subst='s/\*/\\\*/g'
213
214 # Global variables:
215 ofile=libtool
216 can_build_shared=yes
217
218 # All known linkers require a `.a' archive for static linking (except MSVC,
219 # which needs '.lib').
220 libext=a
221
222 with_gnu_ld="$lt_cv_prog_gnu_ld"
223
224 old_CC="$CC"
225 old_CFLAGS="$CFLAGS"
226
227 # Set sane defaults for various variables
228 test -z "$CC" && CC=cc
229 test -z "$LTCC" && LTCC=$CC
230 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
231 test -z "$LD" && LD=ld
232 test -z "$ac_objext" && ac_objext=o
233
234 _LT_CC_BASENAME([$compiler])
235
236 # Only perform the check for file, if the check method requires it
237 test -z "$MAGIC_CMD" && MAGIC_CMD=file
238 case $deplibs_check_method in
239 file_magic*)
240 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
241 _LT_PATH_MAGIC
242 fi
243 ;;
244 esac
245
246 # Use C for the default configuration in the libtool script
247 LT_SUPPORTED_TAG([CC])
248 _LT_LANG_C_CONFIG
249 _LT_LANG_DEFAULT_CONFIG
250 _LT_CONFIG_COMMANDS
251 ])# _LT_SETUP
252
253
254 # _LT_PROG_LTMAIN
255 # ---------------
256 # Note that this code is called both from `configure', and `config.status'
257 # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
258 # `config.status' has no value for ac_aux_dir unless we are using Automake,
259 # so we pass a copy along to make sure it has a sensible value anyway.
260 m4_defun([_LT_PROG_LTMAIN],
261 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
262 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
263 ltmain="$ac_aux_dir/ltmain.sh"
264 ])# _LT_PROG_LTMAIN
265
266
267 ## ------------------------------------- ##
268 ## Accumulate code for creating libtool. ##
269 ## ------------------------------------- ##
270
271 # So that we can recreate a full libtool script including additional
272 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
273 # in macros and then make a single call at the end using the `libtool'
274 # label.
275
276
277 # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
278 # ----------------------------------------
279 # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
280 m4_define([_LT_CONFIG_LIBTOOL_INIT],
281 [m4_ifval([$1],
282 [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
283 [$1
284 ])])])
285
286 # Initialize.
287 m4_define([_LT_OUTPUT_LIBTOOL_INIT])
288
289
290 # _LT_CONFIG_LIBTOOL([COMMANDS])
291 # ------------------------------
292 # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
293 m4_define([_LT_CONFIG_LIBTOOL],
294 [m4_ifval([$1],
295 [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
296 [$1
297 ])])])
298
299 # Initialize.
300 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
301
302
303 # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
304 # -----------------------------------------------------
305 m4_defun([_LT_CONFIG_SAVE_COMMANDS],
306 [_LT_CONFIG_LIBTOOL([$1])
307 _LT_CONFIG_LIBTOOL_INIT([$2])
308 ])
309
310
311 # _LT_FORMAT_COMMENT([COMMENT])
312 # -----------------------------
313 # Add leading comment marks to the start of each line, and a trailing
314 # full-stop to the whole comment if one is not present already.
315 m4_define([_LT_FORMAT_COMMENT],
316 [m4_ifval([$1], [
317 m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
318 [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
319 )])
320
321
322
323 ## ------------------------ ##
324 ## FIXME: Eliminate VARNAME ##
325 ## ------------------------ ##
326
327
328 # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
329 # -------------------------------------------------------------------
330 # CONFIGNAME is the name given to the value in the libtool script.
331 # VARNAME is the (base) name used in the configure script.
332 # VALUE may be 0, 1 or 2 for a computed quote escaped value based on
333 # VARNAME. Any other value will be used directly.
334 m4_define([_LT_DECL],
335 [lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
336 [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
337 [m4_ifval([$1], [$1], [$2])])
338 lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
339 m4_ifval([$4],
340 [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
341 lt_dict_add_subkey([lt_decl_dict], [$2],
342 [tagged?], [m4_ifval([$5], [yes], [no])])])
343 ])
344
345
346 # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
347 # --------------------------------------------------------
348 m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
349
350
351 # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
352 # ------------------------------------------------
353 m4_define([lt_decl_tag_varnames],
354 [_lt_decl_filter([tagged?], [yes], $@)])
355
356
357 # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
358 # ---------------------------------------------------------
359 m4_define([_lt_decl_filter],
360 [m4_case([$#],
361 [0], [m4_fatal([$0: too few arguments: $#])],
362 [1], [m4_fatal([$0: too few arguments: $#: $1])],
363 [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
364 [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
365 [lt_dict_filter([lt_decl_dict], $@)])[]dnl
366 ])
367
368
369 # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
370 # --------------------------------------------------
371 m4_define([lt_decl_quote_varnames],
372 [_lt_decl_filter([value], [1], $@)])
373
374
375 # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
376 # ---------------------------------------------------
377 m4_define([lt_decl_dquote_varnames],
378 [_lt_decl_filter([value], [2], $@)])
379
380
381 # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
382 # ---------------------------------------------------
383 m4_define([lt_decl_varnames_tagged],
384 [m4_assert([$# <= 2])dnl
385 _$0(m4_quote(m4_default([$1], [[, ]])),
386 m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
387 m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
388 m4_define([_lt_decl_varnames_tagged],
389 [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
390
391
392 # lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
393 # ------------------------------------------------
394 m4_define([lt_decl_all_varnames],
395 [_$0(m4_quote(m4_default([$1], [[, ]])),
396 m4_if([$2], [],
397 m4_quote(lt_decl_varnames),
398 m4_quote(m4_shift($@))))[]dnl
399 ])
400 m4_define([_lt_decl_all_varnames],
401 [lt_join($@, lt_decl_varnames_tagged([$1],
402 lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
403 ])
404
405
406 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
407 # ------------------------------------
408 # Quote a variable value, and forward it to `config.status' so that its
409 # declaration there will have the same value as in `configure'. VARNAME
410 # must have a single quote delimited value for this to work.
411 m4_define([_LT_CONFIG_STATUS_DECLARE],
412 [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
413
414
415 # _LT_CONFIG_STATUS_DECLARATIONS
416 # ------------------------------
417 # We delimit libtool config variables with single quotes, so when
418 # we write them to config.status, we have to be sure to quote all
419 # embedded single quotes properly. In configure, this macro expands
420 # each variable declared with _LT_DECL (and _LT_TAGDECL) into:
421 #
422 # <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
423 m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
424 [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
425 [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
426
427
428 # _LT_LIBTOOL_TAGS
429 # ----------------
430 # Output comment and list of tags supported by the script
431 m4_defun([_LT_LIBTOOL_TAGS],
432 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
433 available_tags="_LT_TAGS"dnl
434 ])
435
436
437 # _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
438 # -----------------------------------
439 # Extract the dictionary values for VARNAME (optionally with TAG) and
440 # expand to a commented shell variable setting:
441 #
442 # # Some comment about what VAR is for.
443 # visible_name=$lt_internal_name
444 m4_define([_LT_LIBTOOL_DECLARE],
445 [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
446 [description])))[]dnl
447 m4_pushdef([_libtool_name],
448 m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
449 m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
450 [0], [_libtool_name=[$]$1],
451 [1], [_libtool_name=$lt_[]$1],
452 [2], [_libtool_name=$lt_[]$1],
453 [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
454 m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
455 ])
456
457
458 # _LT_LIBTOOL_CONFIG_VARS
459 # -----------------------
460 # Produce commented declarations of non-tagged libtool config variables
461 # suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
462 # script. Tagged libtool config variables (even for the LIBTOOL CONFIG
463 # section) are produced by _LT_LIBTOOL_TAG_VARS.
464 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
465 [m4_foreach([_lt_var],
466 m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
467 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
468
469
470 # _LT_LIBTOOL_TAG_VARS(TAG)
471 # -------------------------
472 m4_define([_LT_LIBTOOL_TAG_VARS],
473 [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
474 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
475
476
477 # _LT_TAGVAR(VARNAME, [TAGNAME])
478 # ------------------------------
479 m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
480
481
482 # _LT_CONFIG_COMMANDS
483 # -------------------
484 # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
485 # variables for single and double quote escaping we saved from calls
486 # to _LT_DECL, we can put quote escaped variables declarations
487 # into `config.status', and then the shell code to quote escape them in
488 # for loops in `config.status'. Finally, any additional code accumulated
489 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
490 m4_defun([_LT_CONFIG_COMMANDS],
491 [AC_PROVIDE_IFELSE([LT_OUTPUT],
492 dnl If the libtool generation code has been placed in $CONFIG_LT,
493 dnl instead of duplicating it all over again into config.status,
494 dnl then we will have config.status run $CONFIG_LT later, so it
495 dnl needs to know what name is stored there:
496 [AC_CONFIG_COMMANDS([libtool],
497 [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
498 dnl If the libtool generation code is destined for config.status,
499 dnl expand the accumulated commands and init code now:
500 [AC_CONFIG_COMMANDS([libtool],
501 [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
502 ])#_LT_CONFIG_COMMANDS
503
504
505 # Initialize.
506 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
507 [
508
509 # The HP-UX ksh and POSIX shell print the target directory to stdout
510 # if CDPATH is set.
511 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
512
513 sed_quote_subst='$sed_quote_subst'
514 double_quote_subst='$double_quote_subst'
515 delay_variable_subst='$delay_variable_subst'
516 _LT_CONFIG_STATUS_DECLARATIONS
517 LTCC='$LTCC'
518 LTCFLAGS='$LTCFLAGS'
519 compiler='$compiler_DEFAULT'
520
521 # Quote evaled strings.
522 for var in lt_decl_all_varnames([[ \
523 ]], lt_decl_quote_varnames); do
524 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
525 *[[\\\\\\\`\\"\\\$]]*)
526 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
527 ;;
528 *)
529 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
530 ;;
531 esac
532 done
533
534 # Double-quote double-evaled strings.
535 for var in lt_decl_all_varnames([[ \
536 ]], lt_decl_dquote_varnames); do
537 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
538 *[[\\\\\\\`\\"\\\$]]*)
539 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
540 ;;
541 *)
542 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
543 ;;
544 esac
545 done
546
547 # Fix-up fallback echo if it was mangled by the above quoting rules.
548 case \$lt_ECHO in
549 *'\\\[$]0 --fallback-echo"')dnl "
550 lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
551 ;;
552 esac
553
554 _LT_OUTPUT_LIBTOOL_INIT
555 ])
556
557
558 # LT_OUTPUT
559 # ---------
560 # This macro allows early generation of the libtool script (before
561 # AC_OUTPUT is called), incase it is used in configure for compilation
562 # tests.
563 AC_DEFUN([LT_OUTPUT],
564 [: ${CONFIG_LT=./config.lt}
565 AC_MSG_NOTICE([creating $CONFIG_LT])
566 cat >"$CONFIG_LT" <<_LTEOF
567 #! $SHELL
568 # Generated by $as_me.
569 # Run this file to recreate a libtool stub with the current configuration.
570
571 lt_cl_silent=false
572 SHELL=\${CONFIG_SHELL-$SHELL}
573 _LTEOF
574
575 cat >>"$CONFIG_LT" <<\_LTEOF
576 AS_SHELL_SANITIZE
577 _AS_PREPARE
578
579 exec AS_MESSAGE_FD>&1
580 exec AS_MESSAGE_LOG_FD>>config.log
581 {
582 echo
583 AS_BOX([Running $as_me.])
584 } >&AS_MESSAGE_LOG_FD
585
586 lt_cl_help="\
587 \`$as_me' creates a local libtool stub from the current configuration,
588 for use in further configure time tests before the real libtool is
589 generated.
590
591 Usage: $[0] [[OPTIONS]]
592
593 -h, --help print this help, then exit
594 -V, --version print version number, then exit
595 -q, --quiet do not print progress messages
596 -d, --debug don't remove temporary files
597
598 Report bugs to <bug-libtool@gnu.org>."
599
600 lt_cl_version="\
601 m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
602 m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
603 configured by $[0], generated by m4_PACKAGE_STRING.
604
605 Copyright (C) 2008 Free Software Foundation, Inc.
606 This config.lt script is free software; the Free Software Foundation
607 gives unlimited permision to copy, distribute and modify it."
608
609 while test $[#] != 0
610 do
611 case $[1] in
612 --version | --v* | -V )
613 echo "$lt_cl_version"; exit 0 ;;
614 --help | --h* | -h )
615 echo "$lt_cl_help"; exit 0 ;;
616 --debug | --d* | -d )
617 debug=: ;;
618 --quiet | --q* | --silent | --s* | -q )
619 lt_cl_silent=: ;;
620
621 -*) AC_MSG_ERROR([unrecognized option: $[1]
622 Try \`$[0] --help' for more information.]) ;;
623
624 *) AC_MSG_ERROR([unrecognized argument: $[1]
625 Try \`$[0] --help' for more information.]) ;;
626 esac
627 shift
628 done
629
630 if $lt_cl_silent; then
631 exec AS_MESSAGE_FD>/dev/null
632 fi
633 _LTEOF
634
635 cat >>"$CONFIG_LT" <<_LTEOF
636 _LT_OUTPUT_LIBTOOL_COMMANDS_INIT
637 _LTEOF
638
639 cat >>"$CONFIG_LT" <<\_LTEOF
640 AC_MSG_NOTICE([creating $ofile])
641 _LT_OUTPUT_LIBTOOL_COMMANDS
642 AS_EXIT(0)
643 _LTEOF
644 chmod +x "$CONFIG_LT"
645
646 # configure is writing to config.log, but config.lt does its own redirection,
647 # appending to config.log, which fails on DOS, as config.log is still kept
648 # open by configure. Here we exec the FD to /dev/null, effectively closing
649 # config.log, so it can be properly (re)opened and appended to by config.lt.
650 if test "$no_create" != yes; then
651 lt_cl_success=:
652 test "$silent" = yes &&
653 lt_config_lt_args="$lt_config_lt_args --quiet"
654 exec AS_MESSAGE_LOG_FD>/dev/null
655 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
656 exec AS_MESSAGE_LOG_FD>>config.log
657 $lt_cl_success || AS_EXIT(1)
658 fi
659 ])# LT_OUTPUT
660
661
662 # _LT_CONFIG(TAG)
663 # ---------------
664 # If TAG is the built-in tag, create an initial libtool script with a
665 # default configuration from the untagged config vars. Otherwise add code
666 # to config.status for appending the configuration named by TAG from the
667 # matching tagged config vars.
668 m4_defun([_LT_CONFIG],
669 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
670 _LT_CONFIG_SAVE_COMMANDS([
671 m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
672 m4_if(_LT_TAG, [C], [
673 # See if we are running on zsh, and set the options which allow our
674 # commands through without removal of \ escapes.
675 if test -n "${ZSH_VERSION+set}" ; then
676 setopt NO_GLOB_SUBST
677 fi
678
679 cfgfile="${ofile}T"
680 trap "$RM \"$cfgfile\"; exit 1" 1 2 15
681 $RM "$cfgfile"
682
683 cat <<_LT_EOF >> "$cfgfile"
684 #! $SHELL
685
686 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
687 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
688 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
689 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
690 #
691 _LT_COPYING
692 _LT_LIBTOOL_TAGS
693
694 # ### BEGIN LIBTOOL CONFIG
695 _LT_LIBTOOL_CONFIG_VARS
696 _LT_LIBTOOL_TAG_VARS
697 # ### END LIBTOOL CONFIG
698
699 _LT_EOF
700
701 case $host_os in
702 aix3*)
703 cat <<\_LT_EOF >> "$cfgfile"
704 # AIX sometimes has problems with the GCC collect2 program. For some
705 # reason, if we set the COLLECT_NAMES environment variable, the problems
706 # vanish in a puff of smoke.
707 if test "X${COLLECT_NAMES+set}" != Xset; then
708 COLLECT_NAMES=
709 export COLLECT_NAMES
710 fi
711 _LT_EOF
712 ;;
713 esac
714
715 _LT_PROG_LTMAIN
716
717 # We use sed instead of cat because bash on DJGPP gets confused if
718 # if finds mixed CR/LF and LF-only lines. Since sed operates in
719 # text mode, it properly converts lines to CR/LF. This bash problem
720 # is reportedly fixed, but why not run on old versions too?
721 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
722 || (rm -f "$cfgfile"; exit 1)
723
724 _LT_PROG_XSI_SHELLFNS
725
726 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
727 || (rm -f "$cfgfile"; exit 1)
728
729 mv -f "$cfgfile" "$ofile" ||
730 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
731 chmod +x "$ofile"
732 ],
733 [cat <<_LT_EOF >> "$ofile"
734
735 dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
736 dnl in a comment (ie after a #).
737 # ### BEGIN LIBTOOL TAG CONFIG: $1
738 _LT_LIBTOOL_TAG_VARS(_LT_TAG)
739 # ### END LIBTOOL TAG CONFIG: $1
740 _LT_EOF
741 ])dnl /m4_if
742 ],
743 [m4_if([$1], [], [
744 PACKAGE='$PACKAGE'
745 VERSION='$VERSION'
746 TIMESTAMP='$TIMESTAMP'
747 RM='$RM'
748 ofile='$ofile'], [])
749 ])dnl /_LT_CONFIG_SAVE_COMMANDS
750 ])# _LT_CONFIG
751
752
753 # LT_SUPPORTED_TAG(TAG)
754 # ---------------------
755 # Trace this macro to discover what tags are supported by the libtool
756 # --tag option, using:
757 # autoconf --trace 'LT_SUPPORTED_TAG:$1'
758 AC_DEFUN([LT_SUPPORTED_TAG], [])
759
760
761 # C support is built-in for now
762 m4_define([_LT_LANG_C_enabled], [])
763 m4_define([_LT_TAGS], [])
764
765
766 # LT_LANG(LANG)
767 # -------------
768 # Enable libtool support for the given language if not already enabled.
769 AC_DEFUN([LT_LANG],
770 [AC_BEFORE([$0], [LT_OUTPUT])dnl
771 m4_case([$1],
772 [C], [_LT_LANG(C)],
773 [C++], [_LT_LANG(CXX)],
774 [Java], [_LT_LANG(GCJ)],
775 [Fortran 77], [_LT_LANG(F77)],
776 [Fortran], [_LT_LANG(FC)],
777 [Windows Resource], [_LT_LANG(RC)],
778 [m4_ifdef([_LT_LANG_]$1[_CONFIG],
779 [_LT_LANG($1)],
780 [m4_fatal([$0: unsupported language: "$1"])])])dnl
781 ])# LT_LANG
782
783
784 # _LT_LANG(LANGNAME)
785 # ------------------
786 m4_defun([_LT_LANG],
787 [m4_ifdef([_LT_LANG_]$1[_enabled], [],
788 [LT_SUPPORTED_TAG([$1])dnl
789 m4_append([_LT_TAGS], [$1 ])dnl
790 m4_define([_LT_LANG_]$1[_enabled], [])dnl
791 _LT_LANG_$1_CONFIG($1)])dnl
792 ])# _LT_LANG
793
794
795 # _LT_LANG_DEFAULT_CONFIG
796 # -----------------------
797 m4_defun([_LT_LANG_DEFAULT_CONFIG],
798 [AC_PROVIDE_IFELSE([AC_PROG_CXX],
799 [LT_LANG(CXX)],
800 [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
801
802 AC_PROVIDE_IFELSE([AC_PROG_F77],
803 [LT_LANG(F77)],
804 [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
805
806 AC_PROVIDE_IFELSE([AC_PROG_FC],
807 [LT_LANG(FC)],
808 [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
809
810 dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
811 dnl pulling things in needlessly.
812 AC_PROVIDE_IFELSE([AC_PROG_GCJ],
813 [LT_LANG(GCJ)],
814 [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
815 [LT_LANG(GCJ)],
816 [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
817 [LT_LANG(GCJ)],
818 [m4_ifdef([AC_PROG_GCJ],
819 [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
820 m4_ifdef([A][M_PROG_GCJ],
821 [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
822 m4_ifdef([LT_PROG_GCJ],
823 [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
824
825 AC_PROVIDE_IFELSE([LT_PROG_RC],
826 [LT_LANG(RC)],
827 [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
828 ])# _LT_LANG_DEFAULT_CONFIG
829
830 # Obsolete macros:
831 AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
832 AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
833 AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
834 AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
835 dnl aclocal-1.4 backwards compatibility:
836 dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
837 dnl AC_DEFUN([AC_LIBTOOL_F77], [])
838 dnl AC_DEFUN([AC_LIBTOOL_FC], [])
839 dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
840
841
842 # _LT_TAG_COMPILER
843 # ----------------
844 m4_defun([_LT_TAG_COMPILER],
845 [AC_REQUIRE([AC_PROG_CC])dnl
846
847 _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
848 _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
849 _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
850 _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
851
852 # If no C compiler was specified, use CC.
853 LTCC=${LTCC-"$CC"}
854
855 # If no C compiler flags were specified, use CFLAGS.
856 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
857
858 # Allow CC to be a program name with arguments.
859 compiler=$CC
860 ])# _LT_TAG_COMPILER
861
862
863 # _LT_COMPILER_BOILERPLATE
864 # ------------------------
865 # Check for compiler boilerplate output or warnings with
866 # the simple compiler test code.
867 m4_defun([_LT_COMPILER_BOILERPLATE],
868 [m4_require([_LT_DECL_SED])dnl
869 ac_outfile=conftest.$ac_objext
870 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
871 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
872 _lt_compiler_boilerplate=`cat conftest.err`
873 $RM conftest*
874 ])# _LT_COMPILER_BOILERPLATE
875
876
877 # _LT_LINKER_BOILERPLATE
878 # ----------------------
879 # Check for linker boilerplate output or warnings with
880 # the simple link test code.
881 m4_defun([_LT_LINKER_BOILERPLATE],
882 [m4_require([_LT_DECL_SED])dnl
883 ac_outfile=conftest.$ac_objext
884 echo "$lt_simple_link_test_code" >conftest.$ac_ext
885 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
886 _lt_linker_boilerplate=`cat conftest.err`
887 $RM -r conftest*
888 ])# _LT_LINKER_BOILERPLATE
889
890 # _LT_REQUIRED_DARWIN_CHECKS
891 # -------------------------
892 m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
893 case $host_os in
894 rhapsody* | darwin*)
895 AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
896 AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
897 AC_CHECK_TOOL([LIPO], [lipo], [:])
898 AC_CHECK_TOOL([OTOOL], [otool], [:])
899 AC_CHECK_TOOL([OTOOL64], [otool64], [:])
900 _LT_DECL([], [DSYMUTIL], [1],
901 [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
902 _LT_DECL([], [NMEDIT], [1],
903 [Tool to change global to local symbols on Mac OS X])
904 _LT_DECL([], [LIPO], [1],
905 [Tool to manipulate fat objects and archives on Mac OS X])
906 _LT_DECL([], [OTOOL], [1],
907 [ldd/readelf like tool for Mach-O binaries on Mac OS X])
908 _LT_DECL([], [OTOOL64], [1],
909 [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
910
911 AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
912 [lt_cv_apple_cc_single_mod=no
913 if test -z "${LT_MULTI_MODULE}"; then
914 # By default we will add the -single_module flag. You can override
915 # by either setting the environment variable LT_MULTI_MODULE
916 # non-empty at configure time, or by adding -multi_module to the
917 # link flags.
918 rm -rf libconftest.dylib*
919 echo "int foo(void){return 1;}" > conftest.c
920 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
921 -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
922 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
923 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
924 _lt_result=$?
925 if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
926 lt_cv_apple_cc_single_mod=yes
927 else
928 cat conftest.err >&AS_MESSAGE_LOG_FD
929 fi
930 rm -rf libconftest.dylib*
931 rm -f conftest.*
932 fi])
933 AC_CACHE_CHECK([for -exported_symbols_list linker flag],
934 [lt_cv_ld_exported_symbols_list],
935 [lt_cv_ld_exported_symbols_list=no
936 save_LDFLAGS=$LDFLAGS
937 echo "_main" > conftest.sym
938 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
939 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
940 [lt_cv_ld_exported_symbols_list=yes],
941 [lt_cv_ld_exported_symbols_list=no])
942 LDFLAGS="$save_LDFLAGS"
943 ])
944 case $host_os in
945 rhapsody* | darwin1.[[012]])
946 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
947 darwin1.*)
948 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
949 darwin*) # darwin 5.x on
950 # if running on 10.5 or later, the deployment target defaults
951 # to the OS version, if on x86, and 10.4, the deployment
952 # target defaults to 10.4. Don't you love it?
953 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
954 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
955 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
956 10.[[012]]*)
957 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
958 10.*)
959 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
960 esac
961 ;;
962 esac
963 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
964 _lt_dar_single_mod='$single_module'
965 fi
966 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
967 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
968 else
969 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
970 fi
971 if test "$DSYMUTIL" != ":"; then
972 _lt_dsymutil='~$DSYMUTIL $lib || :'
973 else
974 _lt_dsymutil=
975 fi
976 ;;
977 esac
978 ])
979
980
981 # _LT_DARWIN_LINKER_FEATURES
982 # --------------------------
983 # Checks for linker and compiler features on darwin
984 m4_defun([_LT_DARWIN_LINKER_FEATURES],
985 [
986 m4_require([_LT_REQUIRED_DARWIN_CHECKS])
987 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
988 _LT_TAGVAR(hardcode_direct, $1)=no
989 _LT_TAGVAR(hardcode_automatic, $1)=yes
990 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
991 _LT_TAGVAR(whole_archive_flag_spec, $1)=''
992 _LT_TAGVAR(link_all_deplibs, $1)=yes
993 _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
994 case $cc_basename in
995 ifort*) _lt_dar_can_shared=yes ;;
996 *) _lt_dar_can_shared=$GCC ;;
997 esac
998 if test "$_lt_dar_can_shared" = "yes"; then
999 output_verbose_link_cmd=echo
1000 _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}"
1001 _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
1002 _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}"
1003 _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}"
1004 m4_if([$1], [CXX],
1005 [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
1006 _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}"
1007 _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}"
1008 fi
1009 ],[])
1010 else
1011 _LT_TAGVAR(ld_shlibs, $1)=no
1012 fi
1013 ])
1014
1015 # _LT_SYS_MODULE_PATH_AIX
1016 # -----------------------
1017 # Links a minimal program and checks the executable
1018 # for the system default hardcoded library path. In most cases,
1019 # this is /usr/lib:/lib, but when the MPI compilers are used
1020 # the location of the communication and MPI libs are included too.
1021 # If we don't find anything, use the default library path according
1022 # to the aix ld manual.
1023 m4_defun([_LT_SYS_MODULE_PATH_AIX],
1024 [m4_require([_LT_DECL_SED])dnl
1025 AC_LINK_IFELSE(AC_LANG_PROGRAM,[
1026 lt_aix_libpath_sed='
1027 /Import File Strings/,/^$/ {
1028 /^0/ {
1029 s/^0 *\(.*\)$/\1/
1030 p
1031 }
1032 }'
1033 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1034 # Check for a 64-bit object if we didn't find anything.
1035 if test -z "$aix_libpath"; then
1036 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1037 fi],[])
1038 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
1039 ])# _LT_SYS_MODULE_PATH_AIX
1040
1041
1042 # _LT_SHELL_INIT(ARG)
1043 # -------------------
1044 m4_define([_LT_SHELL_INIT],
1045 [ifdef([AC_DIVERSION_NOTICE],
1046 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
1047 [AC_DIVERT_PUSH(NOTICE)])
1048 $1
1049 AC_DIVERT_POP
1050 ])# _LT_SHELL_INIT
1051
1052
1053 # _LT_PROG_ECHO_BACKSLASH
1054 # -----------------------
1055 # Add some code to the start of the generated configure script which
1056 # will find an echo command which doesn't interpret backslashes.
1057 m4_defun([_LT_PROG_ECHO_BACKSLASH],
1058 [_LT_SHELL_INIT([
1059 # Check that we are running under the correct shell.
1060 SHELL=${CONFIG_SHELL-/bin/sh}
1061
1062 case X$lt_ECHO in
1063 X*--fallback-echo)
1064 # Remove one level of quotation (which was required for Make).
1065 ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
1066 ;;
1067 esac
1068
1069 ECHO=${lt_ECHO-echo}
1070 if test "X[$]1" = X--no-reexec; then
1071 # Discard the --no-reexec flag, and continue.
1072 shift
1073 elif test "X[$]1" = X--fallback-echo; then
1074 # Avoid inline document here, it may be left over
1075 :
1076 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
1077 # Yippee, $ECHO works!
1078 :
1079 else
1080 # Restart under the correct shell.
1081 exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
1082 fi
1083
1084 if test "X[$]1" = X--fallback-echo; then
1085 # used as fallback echo
1086 shift
1087 cat <<_LT_EOF
1088 [$]*
1089 _LT_EOF
1090 exit 0
1091 fi
1092
1093 # The HP-UX ksh and POSIX shell print the target directory to stdout
1094 # if CDPATH is set.
1095 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1096
1097 if test -z "$lt_ECHO"; then
1098 if test "X${echo_test_string+set}" != Xset; then
1099 # find a string as large as possible, as long as the shell can cope with it
1100 for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
1101 # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
1102 if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
1103 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
1104 then
1105 break
1106 fi
1107 done
1108 fi
1109
1110 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1111 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1112 test "X$echo_testing_string" = "X$echo_test_string"; then
1113 :
1114 else
1115 # The Solaris, AIX, and Digital Unix default echo programs unquote
1116 # backslashes. This makes it impossible to quote backslashes using
1117 # echo "$something" | sed 's/\\/\\\\/g'
1118 #
1119 # So, first we look for a working echo in the user's PATH.
1120
1121 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
1122 for dir in $PATH /usr/ucb; do
1123 IFS="$lt_save_ifs"
1124 if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
1125 test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
1126 echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
1127 test "X$echo_testing_string" = "X$echo_test_string"; then
1128 ECHO="$dir/echo"
1129 break
1130 fi
1131 done
1132 IFS="$lt_save_ifs"
1133
1134 if test "X$ECHO" = Xecho; then
1135 # We didn't find a better echo, so look for alternatives.
1136 if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
1137 echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
1138 test "X$echo_testing_string" = "X$echo_test_string"; then
1139 # This shell has a builtin print -r that does the trick.
1140 ECHO='print -r'
1141 elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
1142 test "X$CONFIG_SHELL" != X/bin/ksh; then
1143 # If we have ksh, try running configure again with it.
1144 ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1145 export ORIGINAL_CONFIG_SHELL
1146 CONFIG_SHELL=/bin/ksh
1147 export CONFIG_SHELL
1148 exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
1149 else
1150 # Try using printf.
1151 ECHO='printf %s\n'
1152 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1153 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1154 test "X$echo_testing_string" = "X$echo_test_string"; then
1155 # Cool, printf works
1156 :
1157 elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1158 test "X$echo_testing_string" = 'X\t' &&
1159 echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1160 test "X$echo_testing_string" = "X$echo_test_string"; then
1161 CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
1162 export CONFIG_SHELL
1163 SHELL="$CONFIG_SHELL"
1164 export SHELL
1165 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1166 elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1167 test "X$echo_testing_string" = 'X\t' &&
1168 echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1169 test "X$echo_testing_string" = "X$echo_test_string"; then
1170 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1171 else
1172 # maybe with a smaller string...
1173 prev=:
1174
1175 for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
1176 if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
1177 then
1178 break
1179 fi
1180 prev="$cmd"
1181 done
1182
1183 if test "$prev" != 'sed 50q "[$]0"'; then
1184 echo_test_string=`eval $prev`
1185 export echo_test_string
1186 exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
1187 else
1188 # Oops. We lost completely, so just stick with echo.
1189 ECHO=echo
1190 fi
1191 fi
1192 fi
1193 fi
1194 fi
1195 fi
1196
1197 # Copy echo and quote the copy suitably for passing to libtool from
1198 # the Makefile, instead of quoting the original, which is used later.
1199 lt_ECHO=$ECHO
1200 if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
1201 lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
1202 fi
1203
1204 AC_SUBST(lt_ECHO)
1205 ])
1206 _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
1207 _LT_DECL([], [ECHO], [1],
1208 [An echo program that does not interpret backslashes])
1209 ])# _LT_PROG_ECHO_BACKSLASH
1210
1211
1212 # _LT_ENABLE_LOCK
1213 # ---------------
1214 m4_defun([_LT_ENABLE_LOCK],
1215 [AC_ARG_ENABLE([libtool-lock],
1216 [AS_HELP_STRING([--disable-libtool-lock],
1217 [avoid locking (might break parallel builds)])])
1218 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
1219
1220 # Some flags need to be propagated to the compiler or linker for good
1221 # libtool support.
1222 case $host in
1223 ia64-*-hpux*)
1224 # Find out which ABI we are using.
1225 echo 'int i;' > conftest.$ac_ext
1226 if AC_TRY_EVAL(ac_compile); then
1227 case `/usr/bin/file conftest.$ac_objext` in
1228 *ELF-32*)
1229 HPUX_IA64_MODE="32"
1230 ;;
1231 *ELF-64*)
1232 HPUX_IA64_MODE="64"
1233 ;;
1234 esac
1235 fi
1236 rm -rf conftest*
1237 ;;
1238 *-*-irix6*)
1239 # Find out which ABI we are using.
1240 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1241 if AC_TRY_EVAL(ac_compile); then
1242 if test "$lt_cv_prog_gnu_ld" = yes; then
1243 case `/usr/bin/file conftest.$ac_objext` in
1244 *32-bit*)
1245 LD="${LD-ld} -melf32bsmip"
1246 ;;
1247 *N32*)
1248 LD="${LD-ld} -melf32bmipn32"
1249 ;;
1250 *64-bit*)
1251 LD="${LD-ld} -melf64bmip"
1252 ;;
1253 esac
1254 else
1255 case `/usr/bin/file conftest.$ac_objext` in
1256 *32-bit*)
1257 LD="${LD-ld} -32"
1258 ;;
1259 *N32*)
1260 LD="${LD-ld} -n32"
1261 ;;
1262 *64-bit*)
1263 LD="${LD-ld} -64"
1264 ;;
1265 esac
1266 fi
1267 fi
1268 rm -rf conftest*
1269 ;;
1270
1271 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
1272 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
1273 # Find out which ABI we are using.
1274 echo 'int i;' > conftest.$ac_ext
1275 if AC_TRY_EVAL(ac_compile); then
1276 case `/usr/bin/file conftest.o` in
1277 *32-bit*)
1278 case $host in
1279 x86_64-*kfreebsd*-gnu)
1280 LD="${LD-ld} -m elf_i386_fbsd"
1281 ;;
1282 x86_64-*linux*)
1283 LD="${LD-ld} -m elf_i386"
1284 ;;
1285 ppc64-*linux*|powerpc64-*linux*)
1286 LD="${LD-ld} -m elf32ppclinux"
1287 ;;
1288 s390x-*linux*)
1289 LD="${LD-ld} -m elf_s390"
1290 ;;
1291 sparc64-*linux*)
1292 LD="${LD-ld} -m elf32_sparc"
1293 ;;
1294 esac
1295 ;;
1296 *64-bit*)
1297 case $host in
1298 x86_64-*kfreebsd*-gnu)
1299 LD="${LD-ld} -m elf_x86_64_fbsd"
1300 ;;
1301 x86_64-*linux*)
1302 LD="${LD-ld} -m elf_x86_64"
1303 ;;
1304 powerpc64le-*linux*)
1305 LD="${LD-ld} -m elf64lppc"
1306 ;;
1307 powerpc64-*linux*)
1308 LD="${LD-ld} -m elf64ppc"
1309 ;;
1310 s390*-*linux*|s390*-*tpf*)
1311 LD="${LD-ld} -m elf64_s390"
1312 ;;
1313 sparc*-*linux*)
1314 LD="${LD-ld} -m elf64_sparc"
1315 ;;
1316 esac
1317 ;;
1318 esac
1319 fi
1320 rm -rf conftest*
1321 ;;
1322
1323 *-*-sco3.2v5*)
1324 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1325 SAVE_CFLAGS="$CFLAGS"
1326 CFLAGS="$CFLAGS -belf"
1327 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1328 [AC_LANG_PUSH(C)
1329 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
1330 AC_LANG_POP])
1331 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1332 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1333 CFLAGS="$SAVE_CFLAGS"
1334 fi
1335 ;;
1336 sparc*-*solaris*)
1337 # Find out which ABI we are using.
1338 echo 'int i;' > conftest.$ac_ext
1339 if AC_TRY_EVAL(ac_compile); then
1340 case `/usr/bin/file conftest.o` in
1341 *64-bit*)
1342 case $lt_cv_prog_gnu_ld in
1343 yes*) LD="${LD-ld} -m elf64_sparc" ;;
1344 *)
1345 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
1346 LD="${LD-ld} -64"
1347 fi
1348 ;;
1349 esac
1350 ;;
1351 esac
1352 fi
1353 rm -rf conftest*
1354 ;;
1355 esac
1356
1357 need_locks="$enable_libtool_lock"
1358 ])# _LT_ENABLE_LOCK
1359
1360
1361 # _LT_CMD_OLD_ARCHIVE
1362 # -------------------
1363 m4_defun([_LT_CMD_OLD_ARCHIVE],
1364 [AC_CHECK_TOOL(AR, ar, false)
1365 test -z "$AR" && AR=ar
1366 test -z "$AR_FLAGS" && AR_FLAGS=cru
1367 _LT_DECL([], [AR], [1], [The archiver])
1368 _LT_DECL([], [AR_FLAGS], [1])
1369
1370 AC_CHECK_TOOL(STRIP, strip, :)
1371 test -z "$STRIP" && STRIP=:
1372 _LT_DECL([], [STRIP], [1], [A symbol stripping program])
1373
1374 AC_CHECK_TOOL(RANLIB, ranlib, :)
1375 test -z "$RANLIB" && RANLIB=:
1376 _LT_DECL([], [RANLIB], [1],
1377 [Commands used to install an old-style archive])
1378
1379 # Determine commands to create old-style static archives.
1380 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
1381 old_postinstall_cmds='chmod 644 $oldlib'
1382 old_postuninstall_cmds=
1383
1384 if test -n "$RANLIB"; then
1385 case $host_os in
1386 openbsd*)
1387 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
1388 ;;
1389 *)
1390 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
1391 ;;
1392 esac
1393 old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
1394 fi
1395 _LT_DECL([], [old_postinstall_cmds], [2])
1396 _LT_DECL([], [old_postuninstall_cmds], [2])
1397 _LT_TAGDECL([], [old_archive_cmds], [2],
1398 [Commands used to build an old-style archive])
1399 ])# _LT_CMD_OLD_ARCHIVE
1400
1401
1402 # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1403 # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
1404 # ----------------------------------------------------------------
1405 # Check whether the given compiler option works
1406 AC_DEFUN([_LT_COMPILER_OPTION],
1407 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1408 m4_require([_LT_DECL_SED])dnl
1409 AC_CACHE_CHECK([$1], [$2],
1410 [$2=no
1411 m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
1412 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1413 lt_compiler_flag="$3"
1414 # Insert the option either (1) after the last *FLAGS variable, or
1415 # (2) before a word containing "conftest.", or (3) at the end.
1416 # Note that $ac_compile itself does not contain backslashes and begins
1417 # with a dollar sign (not a hyphen), so the echo should work correctly.
1418 # The option is referenced via a variable to avoid confusing sed.
1419 lt_compile=`echo "$ac_compile" | $SED \
1420 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1421 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1422 -e 's:$: $lt_compiler_flag:'`
1423 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1424 (eval "$lt_compile" 2>conftest.err)
1425 ac_status=$?
1426 cat conftest.err >&AS_MESSAGE_LOG_FD
1427 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1428 if (exit $ac_status) && test -s "$ac_outfile"; then
1429 # The compiler can only warn and ignore the option if not recognized
1430 # So say no if there are warnings other than the usual output.
1431 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
1432 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1433 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
1434 $2=yes
1435 fi
1436 fi
1437 $RM conftest*
1438 ])
1439
1440 if test x"[$]$2" = xyes; then
1441 m4_if([$5], , :, [$5])
1442 else
1443 m4_if([$6], , :, [$6])
1444 fi
1445 ])# _LT_COMPILER_OPTION
1446
1447 # Old name:
1448 AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
1449 dnl aclocal-1.4 backwards compatibility:
1450 dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
1451
1452
1453 # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1454 # [ACTION-SUCCESS], [ACTION-FAILURE])
1455 # ----------------------------------------------------
1456 # Check whether the given linker option works
1457 AC_DEFUN([_LT_LINKER_OPTION],
1458 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1459 m4_require([_LT_DECL_SED])dnl
1460 AC_CACHE_CHECK([$1], [$2],
1461 [$2=no
1462 save_LDFLAGS="$LDFLAGS"
1463 LDFLAGS="$LDFLAGS $3"
1464 echo "$lt_simple_link_test_code" > conftest.$ac_ext
1465 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
1466 # The linker can only warn and ignore the option if not recognized
1467 # So say no if there are warnings
1468 if test -s conftest.err; then
1469 # Append any errors to the config.log.
1470 cat conftest.err 1>&AS_MESSAGE_LOG_FD
1471 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
1472 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1473 if diff conftest.exp conftest.er2 >/dev/null; then
1474 $2=yes
1475 fi
1476 else
1477 $2=yes
1478 fi
1479 fi
1480 $RM -r conftest*
1481 LDFLAGS="$save_LDFLAGS"
1482 ])
1483
1484 if test x"[$]$2" = xyes; then
1485 m4_if([$4], , :, [$4])
1486 else
1487 m4_if([$5], , :, [$5])
1488 fi
1489 ])# _LT_LINKER_OPTION
1490
1491 # Old name:
1492 AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
1493 dnl aclocal-1.4 backwards compatibility:
1494 dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
1495
1496
1497 # LT_CMD_MAX_LEN
1498 #---------------
1499 AC_DEFUN([LT_CMD_MAX_LEN],
1500 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1501 # find the maximum length of command line arguments
1502 AC_MSG_CHECKING([the maximum length of command line arguments])
1503 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
1504 i=0
1505 teststring="ABCD"
1506
1507 case $build_os in
1508 msdosdjgpp*)
1509 # On DJGPP, this test can blow up pretty badly due to problems in libc
1510 # (any single argument exceeding 2000 bytes causes a buffer overrun
1511 # during glob expansion). Even if it were fixed, the result of this
1512 # check would be larger than it should be.
1513 lt_cv_sys_max_cmd_len=12288; # 12K is about right
1514 ;;
1515
1516 gnu*)
1517 # Under GNU Hurd, this test is not required because there is
1518 # no limit to the length of command line arguments.
1519 # Libtool will interpret -1 as no limit whatsoever
1520 lt_cv_sys_max_cmd_len=-1;
1521 ;;
1522
1523 cygwin* | mingw* | cegcc*)
1524 # On Win9x/ME, this test blows up -- it succeeds, but takes
1525 # about 5 minutes as the teststring grows exponentially.
1526 # Worse, since 9x/ME are not pre-emptively multitasking,
1527 # you end up with a "frozen" computer, even though with patience
1528 # the test eventually succeeds (with a max line length of 256k).
1529 # Instead, let's just punt: use the minimum linelength reported by
1530 # all of the supported platforms: 8192 (on NT/2K/XP).
1531 lt_cv_sys_max_cmd_len=8192;
1532 ;;
1533
1534 beos*)
1535 # On BeOS, this test takes a really really long time.
1536 # So we just punt and use a minimum line length of 8192.
1537 lt_cv_sys_max_cmd_len=8192;
1538 ;;
1539
1540 amigaos*)
1541 # On AmigaOS with pdksh, this test takes hours, literally.
1542 # So we just punt and use a minimum line length of 8192.
1543 lt_cv_sys_max_cmd_len=8192;
1544 ;;
1545
1546 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
1547 # This has been around since 386BSD, at least. Likely further.
1548 if test -x /sbin/sysctl; then
1549 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
1550 elif test -x /usr/sbin/sysctl; then
1551 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
1552 else
1553 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
1554 fi
1555 # And add a safety zone
1556 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1557 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1558 ;;
1559
1560 interix*)
1561 # We know the value 262144 and hardcode it with a safety zone (like BSD)
1562 lt_cv_sys_max_cmd_len=196608
1563 ;;
1564
1565 osf*)
1566 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
1567 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
1568 # nice to cause kernel panics so lets avoid the loop below.
1569 # First set a reasonable default.
1570 lt_cv_sys_max_cmd_len=16384
1571 #
1572 if test -x /sbin/sysconfig; then
1573 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
1574 *1*) lt_cv_sys_max_cmd_len=-1 ;;
1575 esac
1576 fi
1577 ;;
1578 sco3.2v5*)
1579 lt_cv_sys_max_cmd_len=102400
1580 ;;
1581 sysv5* | sco5v6* | sysv4.2uw2*)
1582 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
1583 if test -n "$kargmax"; then
1584 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
1585 else
1586 lt_cv_sys_max_cmd_len=32768
1587 fi
1588 ;;
1589 *)
1590 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
1591 if test -n "$lt_cv_sys_max_cmd_len"; then
1592 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1593 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1594 else
1595 # Make teststring a little bigger before we do anything with it.
1596 # a 1K string should be a reasonable start.
1597 for i in 1 2 3 4 5 6 7 8 ; do
1598 teststring=$teststring$teststring
1599 done
1600 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
1601 # If test is not a shell built-in, we'll probably end up computing a
1602 # maximum length that is only half of the actual maximum length, but
1603 # we can't tell.
1604 while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
1605 = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
1606 test $i != 17 # 1/2 MB should be enough
1607 do
1608 i=`expr $i + 1`
1609 teststring=$teststring$teststring
1610 done
1611 # Only check the string length outside the loop.
1612 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
1613 teststring=
1614 # Add a significant safety factor because C++ compilers can tack on
1615 # massive amounts of additional arguments before passing them to the
1616 # linker. It appears as though 1/2 is a usable value.
1617 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
1618 fi
1619 ;;
1620 esac
1621 ])
1622 if test -n $lt_cv_sys_max_cmd_len ; then
1623 AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
1624 else
1625 AC_MSG_RESULT(none)
1626 fi
1627 max_cmd_len=$lt_cv_sys_max_cmd_len
1628 _LT_DECL([], [max_cmd_len], [0],
1629 [What is the maximum length of a command?])
1630 ])# LT_CMD_MAX_LEN
1631
1632 # Old name:
1633 AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
1634 dnl aclocal-1.4 backwards compatibility:
1635 dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
1636
1637
1638 # _LT_HEADER_DLFCN
1639 # ----------------
1640 m4_defun([_LT_HEADER_DLFCN],
1641 [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
1642 ])# _LT_HEADER_DLFCN
1643
1644
1645 # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
1646 # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
1647 # ----------------------------------------------------------------
1648 m4_defun([_LT_TRY_DLOPEN_SELF],
1649 [m4_require([_LT_HEADER_DLFCN])dnl
1650 if test "$cross_compiling" = yes; then :
1651 [$4]
1652 else
1653 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1654 lt_status=$lt_dlunknown
1655 cat > conftest.$ac_ext <<_LT_EOF
1656 [#line __oline__ "configure"
1657 #include "confdefs.h"
1658
1659 #if HAVE_DLFCN_H
1660 #include <dlfcn.h>
1661 #endif
1662
1663 #include <stdio.h>
1664
1665 #ifdef RTLD_GLOBAL
1666 # define LT_DLGLOBAL RTLD_GLOBAL
1667 #else
1668 # ifdef DL_GLOBAL
1669 # define LT_DLGLOBAL DL_GLOBAL
1670 # else
1671 # define LT_DLGLOBAL 0
1672 # endif
1673 #endif
1674
1675 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
1676 find out it does not work in some platform. */
1677 #ifndef LT_DLLAZY_OR_NOW
1678 # ifdef RTLD_LAZY
1679 # define LT_DLLAZY_OR_NOW RTLD_LAZY
1680 # else
1681 # ifdef DL_LAZY
1682 # define LT_DLLAZY_OR_NOW DL_LAZY
1683 # else
1684 # ifdef RTLD_NOW
1685 # define LT_DLLAZY_OR_NOW RTLD_NOW
1686 # else
1687 # ifdef DL_NOW
1688 # define LT_DLLAZY_OR_NOW DL_NOW
1689 # else
1690 # define LT_DLLAZY_OR_NOW 0
1691 # endif
1692 # endif
1693 # endif
1694 # endif
1695 #endif
1696
1697 void fnord() { int i=42;}
1698 int main ()
1699 {
1700 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
1701 int status = $lt_dlunknown;
1702
1703 if (self)
1704 {
1705 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
1706 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
1707 /* dlclose (self); */
1708 }
1709 else
1710 puts (dlerror ());
1711
1712 return status;
1713 }]
1714 _LT_EOF
1715 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
1716 (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
1717 lt_status=$?
1718 case x$lt_status in
1719 x$lt_dlno_uscore) $1 ;;
1720 x$lt_dlneed_uscore) $2 ;;
1721 x$lt_dlunknown|x*) $3 ;;
1722 esac
1723 else :
1724 # compilation failed
1725 $3
1726 fi
1727 fi
1728 rm -fr conftest*
1729 ])# _LT_TRY_DLOPEN_SELF
1730
1731
1732 # LT_SYS_DLOPEN_SELF
1733 # ------------------
1734 AC_DEFUN([LT_SYS_DLOPEN_SELF],
1735 [m4_require([_LT_HEADER_DLFCN])dnl
1736 if test "x$enable_dlopen" != xyes; then
1737 enable_dlopen=unknown
1738 enable_dlopen_self=unknown
1739 enable_dlopen_self_static=unknown
1740 else
1741 lt_cv_dlopen=no
1742 lt_cv_dlopen_libs=
1743
1744 case $host_os in
1745 beos*)
1746 lt_cv_dlopen="load_add_on"
1747 lt_cv_dlopen_libs=
1748 lt_cv_dlopen_self=yes
1749 ;;
1750
1751 mingw* | pw32* | cegcc*)
1752 lt_cv_dlopen="LoadLibrary"
1753 lt_cv_dlopen_libs=
1754 ;;
1755
1756 cygwin*)
1757 lt_cv_dlopen="dlopen"
1758 lt_cv_dlopen_libs=
1759 ;;
1760
1761 darwin*)
1762 # if libdl is installed we need to link against it
1763 AC_CHECK_LIB([dl], [dlopen],
1764 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
1765 lt_cv_dlopen="dyld"
1766 lt_cv_dlopen_libs=
1767 lt_cv_dlopen_self=yes
1768 ])
1769 ;;
1770
1771 *)
1772 AC_CHECK_FUNC([shl_load],
1773 [lt_cv_dlopen="shl_load"],
1774 [AC_CHECK_LIB([dld], [shl_load],
1775 [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
1776 [AC_CHECK_FUNC([dlopen],
1777 [lt_cv_dlopen="dlopen"],
1778 [AC_CHECK_LIB([dl], [dlopen],
1779 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
1780 [AC_CHECK_LIB([svld], [dlopen],
1781 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
1782 [AC_CHECK_LIB([dld], [dld_link],
1783 [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
1784 ])
1785 ])
1786 ])
1787 ])
1788 ])
1789 ;;
1790 esac
1791
1792 if test "x$lt_cv_dlopen" != xno; then
1793 enable_dlopen=yes
1794 else
1795 enable_dlopen=no
1796 fi
1797
1798 case $lt_cv_dlopen in
1799 dlopen)
1800 save_CPPFLAGS="$CPPFLAGS"
1801 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
1802
1803 save_LDFLAGS="$LDFLAGS"
1804 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
1805
1806 save_LIBS="$LIBS"
1807 LIBS="$lt_cv_dlopen_libs $LIBS"
1808
1809 AC_CACHE_CHECK([whether a program can dlopen itself],
1810 lt_cv_dlopen_self, [dnl
1811 _LT_TRY_DLOPEN_SELF(
1812 lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
1813 lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
1814 ])
1815
1816 if test "x$lt_cv_dlopen_self" = xyes; then
1817 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
1818 AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
1819 lt_cv_dlopen_self_static, [dnl
1820 _LT_TRY_DLOPEN_SELF(
1821 lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
1822 lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
1823 ])
1824 fi
1825
1826 CPPFLAGS="$save_CPPFLAGS"
1827 LDFLAGS="$save_LDFLAGS"
1828 LIBS="$save_LIBS"
1829 ;;
1830 esac
1831
1832 case $lt_cv_dlopen_self in
1833 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
1834 *) enable_dlopen_self=unknown ;;
1835 esac
1836
1837 case $lt_cv_dlopen_self_static in
1838 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
1839 *) enable_dlopen_self_static=unknown ;;
1840 esac
1841 fi
1842 _LT_DECL([dlopen_support], [enable_dlopen], [0],
1843 [Whether dlopen is supported])
1844 _LT_DECL([dlopen_self], [enable_dlopen_self], [0],
1845 [Whether dlopen of programs is supported])
1846 _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
1847 [Whether dlopen of statically linked programs is supported])
1848 ])# LT_SYS_DLOPEN_SELF
1849
1850 # Old name:
1851 AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
1852 dnl aclocal-1.4 backwards compatibility:
1853 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
1854
1855
1856 # _LT_COMPILER_C_O([TAGNAME])
1857 # ---------------------------
1858 # Check to see if options -c and -o are simultaneously supported by compiler.
1859 # This macro does not hard code the compiler like AC_PROG_CC_C_O.
1860 m4_defun([_LT_COMPILER_C_O],
1861 [m4_require([_LT_DECL_SED])dnl
1862 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1863 m4_require([_LT_TAG_COMPILER])dnl
1864 AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
1865 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
1866 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
1867 $RM -r conftest 2>/dev/null
1868 mkdir conftest
1869 cd conftest
1870 mkdir out
1871 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1872
1873 lt_compiler_flag="-o out/conftest2.$ac_objext"
1874 # Insert the option either (1) after the last *FLAGS variable, or
1875 # (2) before a word containing "conftest.", or (3) at the end.
1876 # Note that $ac_compile itself does not contain backslashes and begins
1877 # with a dollar sign (not a hyphen), so the echo should work correctly.
1878 lt_compile=`echo "$ac_compile" | $SED \
1879 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1880 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1881 -e 's:$: $lt_compiler_flag:'`
1882 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1883 (eval "$lt_compile" 2>out/conftest.err)
1884 ac_status=$?
1885 cat out/conftest.err >&AS_MESSAGE_LOG_FD
1886 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1887 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1888 then
1889 # The compiler can only warn and ignore the option if not recognized
1890 # So say no if there are warnings
1891 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
1892 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
1893 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
1894 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
1895 fi
1896 fi
1897 chmod u+w . 2>&AS_MESSAGE_LOG_FD
1898 $RM conftest*
1899 # SGI C++ compiler will create directory out/ii_files/ for
1900 # template instantiation
1901 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
1902 $RM out/* && rmdir out
1903 cd ..
1904 $RM -r conftest
1905 $RM conftest*
1906 ])
1907 _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
1908 [Does compiler simultaneously support -c and -o options?])
1909 ])# _LT_COMPILER_C_O
1910
1911
1912 # _LT_COMPILER_FILE_LOCKS([TAGNAME])
1913 # ----------------------------------
1914 # Check to see if we can do hard links to lock some files if needed
1915 m4_defun([_LT_COMPILER_FILE_LOCKS],
1916 [m4_require([_LT_ENABLE_LOCK])dnl
1917 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1918 _LT_COMPILER_C_O([$1])
1919
1920 hard_links="nottested"
1921 if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
1922 # do not overwrite the value of need_locks provided by the user
1923 AC_MSG_CHECKING([if we can lock with hard links])
1924 hard_links=yes
1925 $RM conftest*
1926 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1927 touch conftest.a
1928 ln conftest.a conftest.b 2>&5 || hard_links=no
1929 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1930 AC_MSG_RESULT([$hard_links])
1931 if test "$hard_links" = no; then
1932 AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
1933 need_locks=warn
1934 fi
1935 else
1936 need_locks=no
1937 fi
1938 _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
1939 ])# _LT_COMPILER_FILE_LOCKS
1940
1941
1942 # _LT_CHECK_OBJDIR
1943 # ----------------
1944 m4_defun([_LT_CHECK_OBJDIR],
1945 [AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
1946 [rm -f .libs 2>/dev/null
1947 mkdir .libs 2>/dev/null
1948 if test -d .libs; then
1949 lt_cv_objdir=.libs
1950 else
1951 # MS-DOS does not allow filenames that begin with a dot.
1952 lt_cv_objdir=_libs
1953 fi
1954 rmdir .libs 2>/dev/null])
1955 objdir=$lt_cv_objdir
1956 _LT_DECL([], [objdir], [0],
1957 [The name of the directory that contains temporary libtool files])dnl
1958 m4_pattern_allow([LT_OBJDIR])dnl
1959 AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
1960 [Define to the sub-directory in which libtool stores uninstalled libraries.])
1961 ])# _LT_CHECK_OBJDIR
1962
1963
1964 # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
1965 # --------------------------------------
1966 # Check hardcoding attributes.
1967 m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
1968 [AC_MSG_CHECKING([how to hardcode library paths into programs])
1969 _LT_TAGVAR(hardcode_action, $1)=
1970 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
1971 test -n "$_LT_TAGVAR(runpath_var, $1)" ||
1972 test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
1973
1974 # We can hardcode non-existent directories.
1975 if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
1976 # If the only mechanism to avoid hardcoding is shlibpath_var, we
1977 # have to relink, otherwise we might link with an installed library
1978 # when we should be linking with a yet-to-be-installed one
1979 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
1980 test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
1981 # Linking always hardcodes the temporary library directory.
1982 _LT_TAGVAR(hardcode_action, $1)=relink
1983 else
1984 # We can link without hardcoding, and we can hardcode nonexisting dirs.
1985 _LT_TAGVAR(hardcode_action, $1)=immediate
1986 fi
1987 else
1988 # We cannot hardcode anything, or else we can only hardcode existing
1989 # directories.
1990 _LT_TAGVAR(hardcode_action, $1)=unsupported
1991 fi
1992 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
1993
1994 if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
1995 test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
1996 # Fast installation is not supported
1997 enable_fast_install=no
1998 elif test "$shlibpath_overrides_runpath" = yes ||
1999 test "$enable_shared" = no; then
2000 # Fast installation is not necessary
2001 enable_fast_install=needless
2002 fi
2003 _LT_TAGDECL([], [hardcode_action], [0],
2004 [How to hardcode a shared library path into an executable])
2005 ])# _LT_LINKER_HARDCODE_LIBPATH
2006
2007
2008 # _LT_CMD_STRIPLIB
2009 # ----------------
2010 m4_defun([_LT_CMD_STRIPLIB],
2011 [m4_require([_LT_DECL_EGREP])
2012 striplib=
2013 old_striplib=
2014 AC_MSG_CHECKING([whether stripping libraries is possible])
2015 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
2016 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
2017 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
2018 AC_MSG_RESULT([yes])
2019 else
2020 # FIXME - insert some real tests, host_os isn't really good enough
2021 case $host_os in
2022 darwin*)
2023 if test -n "$STRIP" ; then
2024 striplib="$STRIP -x"
2025 old_striplib="$STRIP -S"
2026 AC_MSG_RESULT([yes])
2027 else
2028 AC_MSG_RESULT([no])
2029 fi
2030 ;;
2031 *)
2032 AC_MSG_RESULT([no])
2033 ;;
2034 esac
2035 fi
2036 _LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
2037 _LT_DECL([], [striplib], [1])
2038 ])# _LT_CMD_STRIPLIB
2039
2040
2041 # _LT_SYS_DYNAMIC_LINKER([TAG])
2042 # -----------------------------
2043 # PORTME Fill in your ld.so characteristics
2044 m4_defun([_LT_SYS_DYNAMIC_LINKER],
2045 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
2046 m4_require([_LT_DECL_EGREP])dnl
2047 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
2048 m4_require([_LT_DECL_OBJDUMP])dnl
2049 m4_require([_LT_DECL_SED])dnl
2050 AC_MSG_CHECKING([dynamic linker characteristics])
2051 m4_if([$1],
2052 [], [
2053 if test "$GCC" = yes; then
2054 case $host_os in
2055 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
2056 *) lt_awk_arg="/^libraries:/" ;;
2057 esac
2058 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2059 if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
2060 # if the path contains ";" then we assume it to be the separator
2061 # otherwise default to the standard path separator (i.e. ":") - it is
2062 # assumed that no part of a normal pathname contains ";" but that should
2063 # okay in the real world where ";" in dirpaths is itself problematic.
2064 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
2065 else
2066 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2067 fi
2068 # Ok, now we have the path, separated by spaces, we can step through it
2069 # and add multilib dir if necessary.
2070 lt_tmp_lt_search_path_spec=
2071 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
2072 for lt_sys_path in $lt_search_path_spec; do
2073 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
2074 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
2075 else
2076 test -d "$lt_sys_path" && \
2077 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
2078 fi
2079 done
2080 lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
2081 BEGIN {RS=" "; FS="/|\n";} {
2082 lt_foo="";
2083 lt_count=0;
2084 for (lt_i = NF; lt_i > 0; lt_i--) {
2085 if ($lt_i != "" && $lt_i != ".") {
2086 if ($lt_i == "..") {
2087 lt_count++;
2088 } else {
2089 if (lt_count == 0) {
2090 lt_foo="/" $lt_i lt_foo;
2091 } else {
2092 lt_count--;
2093 }
2094 }
2095 }
2096 }
2097 if (lt_foo != "") { lt_freq[[lt_foo]]++; }
2098 if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
2099 }'`
2100 sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
2101 else
2102 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
2103 fi])
2104 library_names_spec=
2105 libname_spec='lib$name'
2106 soname_spec=
2107 shrext_cmds=".so"
2108 postinstall_cmds=
2109 postuninstall_cmds=
2110 finish_cmds=
2111 finish_eval=
2112 shlibpath_var=
2113 shlibpath_overrides_runpath=unknown
2114 version_type=none
2115 dynamic_linker="$host_os ld.so"
2116 sys_lib_dlsearch_path_spec="/lib /usr/lib"
2117 need_lib_prefix=unknown
2118 hardcode_into_libs=no
2119
2120 # when you set need_version to no, make sure it does not cause -set_version
2121 # flags to be left without arguments
2122 need_version=unknown
2123
2124 case $host_os in
2125 aix3*)
2126 version_type=linux
2127 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
2128 shlibpath_var=LIBPATH
2129
2130 # AIX 3 has no versioning support, so we append a major version to the name.
2131 soname_spec='${libname}${release}${shared_ext}$major'
2132 ;;
2133
2134 aix[[4-9]]*)
2135 version_type=linux
2136 need_lib_prefix=no
2137 need_version=no
2138 hardcode_into_libs=yes
2139 if test "$host_cpu" = ia64; then
2140 # AIX 5 supports IA64
2141 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
2142 shlibpath_var=LD_LIBRARY_PATH
2143 else
2144 # With GCC up to 2.95.x, collect2 would create an import file
2145 # for dependence libraries. The import file would start with
2146 # the line `#! .'. This would cause the generated library to
2147 # depend on `.', always an invalid library. This was fixed in
2148 # development snapshots of GCC prior to 3.0.
2149 case $host_os in
2150 aix4 | aix4.[[01]] | aix4.[[01]].*)
2151 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
2152 echo ' yes '
2153 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
2154 :
2155 else
2156 can_build_shared=no
2157 fi
2158 ;;
2159 esac
2160 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
2161 # soname into executable. Probably we can add versioning support to
2162 # collect2, so additional links can be useful in future.
2163 if test "$aix_use_runtimelinking" = yes; then
2164 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
2165 # instead of lib<name>.a to let people know that these are not
2166 # typical AIX shared libraries.
2167 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2168 else
2169 # We preserve .a as extension for shared libraries through AIX4.2
2170 # and later when we are not doing run time linking.
2171 library_names_spec='${libname}${release}.a $libname.a'
2172 soname_spec='${libname}${release}${shared_ext}$major'
2173 fi
2174 shlibpath_var=LIBPATH
2175 fi
2176 ;;
2177
2178 amigaos*)
2179 case $host_cpu in
2180 powerpc)
2181 # Since July 2007 AmigaOS4 officially supports .so libraries.
2182 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
2183 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2184 ;;
2185 m68k)
2186 library_names_spec='$libname.ixlibrary $libname.a'
2187 # Create ${libname}_ixlibrary.a entries in /sys/libs.
2188 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'
2189 ;;
2190 esac
2191 ;;
2192
2193 beos*)
2194 library_names_spec='${libname}${shared_ext}'
2195 dynamic_linker="$host_os ld.so"
2196 shlibpath_var=LIBRARY_PATH
2197 ;;
2198
2199 bsdi[[45]]*)
2200 version_type=linux
2201 need_version=no
2202 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2203 soname_spec='${libname}${release}${shared_ext}$major'
2204 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
2205 shlibpath_var=LD_LIBRARY_PATH
2206 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
2207 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
2208 # the default ld.so.conf also contains /usr/contrib/lib and
2209 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
2210 # libtool to hard-code these into programs
2211 ;;
2212
2213 cygwin* | mingw* | pw32* | cegcc*)
2214 version_type=windows
2215 shrext_cmds=".dll"
2216 need_version=no
2217 need_lib_prefix=no
2218
2219 case $GCC,$host_os in
2220 yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
2221 library_names_spec='$libname.dll.a'
2222 # DLL is installed to $(libdir)/../bin by postinstall_cmds
2223 postinstall_cmds='base_file=`basename \${file}`~
2224 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
2225 dldir=$destdir/`dirname \$dlpath`~
2226 test -d \$dldir || mkdir -p \$dldir~
2227 $install_prog $dir/$dlname \$dldir/$dlname~
2228 chmod a+x \$dldir/$dlname~
2229 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
2230 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
2231 fi'
2232 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
2233 dlpath=$dir/\$dldll~
2234 $RM \$dlpath'
2235 shlibpath_overrides_runpath=yes
2236
2237 case $host_os in
2238 cygwin*)
2239 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
2240 #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2241 soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
2242 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
2243 ;;
2244 mingw* | cegcc*)
2245 # MinGW DLLs use traditional 'lib' prefix
2246 #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2247 soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
2248 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2249 if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
2250 # It is most probably a Windows format PATH printed by
2251 # mingw gcc, but we are running on Cygwin. Gcc prints its search
2252 # path with ; separators, and with drive letters. We can handle the
2253 # drive letters (cygwin fileutils understands them), so leave them,
2254 # especially as we might pass files found there to a mingw objdump,
2255 # which wouldn't understand a cygwinified path. Ahh.
2256 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
2257 else
2258 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2259 fi
2260 ;;
2261 pw32*)
2262 # pw32 DLLs use 'pw' prefix rather than 'lib'
2263 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2264 ;;
2265 esac
2266 ;;
2267
2268 *)
2269 library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
2270 ;;
2271 esac
2272 dynamic_linker='Win32 ld.exe'
2273 # FIXME: first we should search . and the directory the executable is in
2274 shlibpath_var=PATH
2275 ;;
2276
2277 darwin* | rhapsody*)
2278 dynamic_linker="$host_os dyld"
2279 version_type=darwin
2280 need_lib_prefix=no
2281 need_version=no
2282 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
2283 soname_spec='${libname}${release}${major}$shared_ext'
2284 shlibpath_overrides_runpath=yes
2285 shlibpath_var=DYLD_LIBRARY_PATH
2286 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
2287 m4_if([$1], [],[
2288 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
2289 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
2290 ;;
2291
2292 dgux*)
2293 version_type=linux
2294 need_lib_prefix=no
2295 need_version=no
2296 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
2297 soname_spec='${libname}${release}${shared_ext}$major'
2298 shlibpath_var=LD_LIBRARY_PATH
2299 ;;
2300
2301 freebsd1*)
2302 dynamic_linker=no
2303 ;;
2304
2305 freebsd* | dragonfly*)
2306 # DragonFly does not have aout. When/if they implement a new
2307 # versioning mechanism, adjust this.
2308 if test -x /usr/bin/objformat; then
2309 objformat=`/usr/bin/objformat`
2310 else
2311 case $host_os in
2312 freebsd[[123]]*) objformat=aout ;;
2313 *) objformat=elf ;;
2314 esac
2315 fi
2316 version_type=freebsd-$objformat
2317 case $version_type in
2318 freebsd-elf*)
2319 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2320 need_version=no
2321 need_lib_prefix=no
2322 ;;
2323 freebsd-*)
2324 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
2325 need_version=yes
2326 ;;
2327 esac
2328 shlibpath_var=LD_LIBRARY_PATH
2329 case $host_os in
2330 freebsd2*)
2331 shlibpath_overrides_runpath=yes
2332 ;;
2333 freebsd3.[[01]]* | freebsdelf3.[[01]]*)
2334 shlibpath_overrides_runpath=yes
2335 hardcode_into_libs=yes
2336 ;;
2337 freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
2338 freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
2339 shlibpath_overrides_runpath=no
2340 hardcode_into_libs=yes
2341 ;;
2342 *) # from 4.6 on, and DragonFly
2343 shlibpath_overrides_runpath=yes
2344 hardcode_into_libs=yes
2345 ;;
2346 esac
2347 ;;
2348
2349 gnu*)
2350 version_type=linux
2351 need_lib_prefix=no
2352 need_version=no
2353 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
2354 soname_spec='${libname}${release}${shared_ext}$major'
2355 shlibpath_var=LD_LIBRARY_PATH
2356 hardcode_into_libs=yes
2357 ;;
2358
2359 hpux9* | hpux10* | hpux11*)
2360 # Give a soname corresponding to the major version so that dld.sl refuses to
2361 # link against other versions.
2362 version_type=sunos
2363 need_lib_prefix=no
2364 need_version=no
2365 case $host_cpu in
2366 ia64*)
2367 shrext_cmds='.so'
2368 hardcode_into_libs=yes
2369 dynamic_linker="$host_os dld.so"
2370 shlibpath_var=LD_LIBRARY_PATH
2371 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2372 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2373 soname_spec='${libname}${release}${shared_ext}$major'
2374 if test "X$HPUX_IA64_MODE" = X32; then
2375 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
2376 else
2377 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
2378 fi
2379 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2380 ;;
2381 hppa*64*)
2382 shrext_cmds='.sl'
2383 hardcode_into_libs=yes
2384 dynamic_linker="$host_os dld.sl"
2385 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
2386 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2387 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2388 soname_spec='${libname}${release}${shared_ext}$major'
2389 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
2390 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2391 ;;
2392 *)
2393 shrext_cmds='.sl'
2394 dynamic_linker="$host_os dld.sl"
2395 shlibpath_var=SHLIB_PATH
2396 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
2397 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2398 soname_spec='${libname}${release}${shared_ext}$major'
2399 ;;
2400 esac
2401 # HP-UX runs *really* slowly unless shared libraries are mode 555.
2402 postinstall_cmds='chmod 555 $lib'
2403 ;;
2404
2405 interix[[3-9]]*)
2406 version_type=linux
2407 need_lib_prefix=no
2408 need_version=no
2409 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2410 soname_spec='${libname}${release}${shared_ext}$major'
2411 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
2412 shlibpath_var=LD_LIBRARY_PATH
2413 shlibpath_overrides_runpath=no
2414 hardcode_into_libs=yes
2415 ;;
2416
2417 irix5* | irix6* | nonstopux*)
2418 case $host_os in
2419 nonstopux*) version_type=nonstopux ;;
2420 *)
2421 if test "$lt_cv_prog_gnu_ld" = yes; then
2422 version_type=linux
2423 else
2424 version_type=irix
2425 fi ;;
2426 esac
2427 need_lib_prefix=no
2428 need_version=no
2429 soname_spec='${libname}${release}${shared_ext}$major'
2430 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
2431 case $host_os in
2432 irix5* | nonstopux*)
2433 libsuff= shlibsuff=
2434 ;;
2435 *)
2436 case $LD in # libtool.m4 will add one of these switches to LD
2437 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
2438 libsuff= shlibsuff= libmagic=32-bit;;
2439 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
2440 libsuff=32 shlibsuff=N32 libmagic=N32;;
2441 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
2442 libsuff=64 shlibsuff=64 libmagic=64-bit;;
2443 *) libsuff= shlibsuff= libmagic=never-match;;
2444 esac
2445 ;;
2446 esac
2447 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
2448 shlibpath_overrides_runpath=no
2449 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
2450 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
2451 hardcode_into_libs=yes
2452 ;;
2453
2454 # No shared lib support for Linux oldld, aout, or coff.
2455 linux*oldld* | linux*aout* | linux*coff*)
2456 dynamic_linker=no
2457 ;;
2458
2459 # This must be Linux ELF.
2460 linux* | k*bsd*-gnu)
2461 version_type=linux
2462 need_lib_prefix=no
2463 need_version=no
2464 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2465 soname_spec='${libname}${release}${shared_ext}$major'
2466 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
2467 shlibpath_var=LD_LIBRARY_PATH
2468 shlibpath_overrides_runpath=no
2469 # Some binutils ld are patched to set DT_RUNPATH
2470 save_LDFLAGS=$LDFLAGS
2471 save_libdir=$libdir
2472 eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
2473 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
2474 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2475 [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
2476 [shlibpath_overrides_runpath=yes])])
2477 LDFLAGS=$save_LDFLAGS
2478 libdir=$save_libdir
2479
2480 # This implies no fast_install, which is unacceptable.
2481 # Some rework will be needed to allow for fast_install
2482 # before this can be enabled.
2483 hardcode_into_libs=yes
2484
2485 # Append ld.so.conf contents to the search path
2486 if test -f /etc/ld.so.conf; then
2487 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' ' '`
2488 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
2489 fi
2490
2491 # We used to test for /lib/ld.so.1 and disable shared libraries on
2492 # powerpc, because MkLinux only supported shared libraries with the
2493 # GNU dynamic linker. Since this was broken with cross compilers,
2494 # most powerpc-linux boxes support dynamic linking these days and
2495 # people can always --disable-shared, the test was removed, and we
2496 # assume the GNU/Linux dynamic linker is in use.
2497 dynamic_linker='GNU/Linux ld.so'
2498 ;;
2499
2500 netbsd*)
2501 version_type=sunos
2502 need_lib_prefix=no
2503 need_version=no
2504 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
2505 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2506 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2507 dynamic_linker='NetBSD (a.out) ld.so'
2508 else
2509 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2510 soname_spec='${libname}${release}${shared_ext}$major'
2511 dynamic_linker='NetBSD ld.elf_so'
2512 fi
2513 shlibpath_var=LD_LIBRARY_PATH
2514 shlibpath_overrides_runpath=yes
2515 hardcode_into_libs=yes
2516 ;;
2517
2518 newsos6)
2519 version_type=linux
2520 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2521 shlibpath_var=LD_LIBRARY_PATH
2522 shlibpath_overrides_runpath=yes
2523 ;;
2524
2525 *nto* | *qnx*)
2526 version_type=qnx
2527 need_lib_prefix=no
2528 need_version=no
2529 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2530 soname_spec='${libname}${release}${shared_ext}$major'
2531 shlibpath_var=LD_LIBRARY_PATH
2532 shlibpath_overrides_runpath=no
2533 hardcode_into_libs=yes
2534 dynamic_linker='ldqnx.so'
2535 ;;
2536
2537 openbsd*)
2538 version_type=sunos
2539 sys_lib_dlsearch_path_spec="/usr/lib"
2540 need_lib_prefix=no
2541 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
2542 case $host_os in
2543 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
2544 *) need_version=no ;;
2545 esac
2546 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2547 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2548 shlibpath_var=LD_LIBRARY_PATH
2549 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
2550 case $host_os in
2551 openbsd2.[[89]] | openbsd2.[[89]].*)
2552 shlibpath_overrides_runpath=no
2553 ;;
2554 *)
2555 shlibpath_overrides_runpath=yes
2556 ;;
2557 esac
2558 else
2559 shlibpath_overrides_runpath=yes
2560 fi
2561 ;;
2562
2563 os2*)
2564 libname_spec='$name'
2565 shrext_cmds=".dll"
2566 need_lib_prefix=no
2567 library_names_spec='$libname${shared_ext} $libname.a'
2568 dynamic_linker='OS/2 ld.exe'
2569 shlibpath_var=LIBPATH
2570 ;;
2571
2572 osf3* | osf4* | osf5*)
2573 version_type=osf
2574 need_lib_prefix=no
2575 need_version=no
2576 soname_spec='${libname}${release}${shared_ext}$major'
2577 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2578 shlibpath_var=LD_LIBRARY_PATH
2579 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
2580 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
2581 ;;
2582
2583 rdos*)
2584 dynamic_linker=no
2585 ;;
2586
2587 solaris*)
2588 version_type=linux
2589 need_lib_prefix=no
2590 need_version=no
2591 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2592 soname_spec='${libname}${release}${shared_ext}$major'
2593 shlibpath_var=LD_LIBRARY_PATH
2594 shlibpath_overrides_runpath=yes
2595 hardcode_into_libs=yes
2596 # ldd complains unless libraries are executable
2597 postinstall_cmds='chmod +x $lib'
2598 ;;
2599
2600 sunos4*)
2601 version_type=sunos
2602 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2603 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
2604 shlibpath_var=LD_LIBRARY_PATH
2605 shlibpath_overrides_runpath=yes
2606 if test "$with_gnu_ld" = yes; then
2607 need_lib_prefix=no
2608 fi
2609 need_version=yes
2610 ;;
2611
2612 sysv4 | sysv4.3*)
2613 version_type=linux
2614 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2615 soname_spec='${libname}${release}${shared_ext}$major'
2616 shlibpath_var=LD_LIBRARY_PATH
2617 case $host_vendor in
2618 sni)
2619 shlibpath_overrides_runpath=no
2620 need_lib_prefix=no
2621 runpath_var=LD_RUN_PATH
2622 ;;
2623 siemens)
2624 need_lib_prefix=no
2625 ;;
2626 motorola)
2627 need_lib_prefix=no
2628 need_version=no
2629 shlibpath_overrides_runpath=no
2630 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
2631 ;;
2632 esac
2633 ;;
2634
2635 sysv4*MP*)
2636 if test -d /usr/nec ;then
2637 version_type=linux
2638 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
2639 soname_spec='$libname${shared_ext}.$major'
2640 shlibpath_var=LD_LIBRARY_PATH
2641 fi
2642 ;;
2643
2644 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
2645 version_type=freebsd-elf
2646 need_lib_prefix=no
2647 need_version=no
2648 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2649 soname_spec='${libname}${release}${shared_ext}$major'
2650 shlibpath_var=LD_LIBRARY_PATH
2651 shlibpath_overrides_runpath=yes
2652 hardcode_into_libs=yes
2653 if test "$with_gnu_ld" = yes; then
2654 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
2655 else
2656 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
2657 case $host_os in
2658 sco3.2v5*)
2659 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
2660 ;;
2661 esac
2662 fi
2663 sys_lib_dlsearch_path_spec='/usr/lib'
2664 ;;
2665
2666 tpf*)
2667 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
2668 version_type=linux
2669 need_lib_prefix=no
2670 need_version=no
2671 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2672 shlibpath_var=LD_LIBRARY_PATH
2673 shlibpath_overrides_runpath=no
2674 hardcode_into_libs=yes
2675 ;;
2676
2677 uts4*)
2678 version_type=linux
2679 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2680 soname_spec='${libname}${release}${shared_ext}$major'
2681 shlibpath_var=LD_LIBRARY_PATH
2682 ;;
2683
2684 *)
2685 dynamic_linker=no
2686 ;;
2687 esac
2688 AC_MSG_RESULT([$dynamic_linker])
2689 test "$dynamic_linker" = no && can_build_shared=no
2690
2691 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
2692 if test "$GCC" = yes; then
2693 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
2694 fi
2695
2696 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
2697 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
2698 fi
2699 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
2700 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
2701 fi
2702
2703 _LT_DECL([], [variables_saved_for_relink], [1],
2704 [Variables whose values should be saved in libtool wrapper scripts and
2705 restored at link time])
2706 _LT_DECL([], [need_lib_prefix], [0],
2707 [Do we need the "lib" prefix for modules?])
2708 _LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
2709 _LT_DECL([], [version_type], [0], [Library versioning type])
2710 _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
2711 _LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
2712 _LT_DECL([], [shlibpath_overrides_runpath], [0],
2713 [Is shlibpath searched before the hard-coded library search path?])
2714 _LT_DECL([], [libname_spec], [1], [Format of library name prefix])
2715 _LT_DECL([], [library_names_spec], [1],
2716 [[List of archive names. First name is the real one, the rest are links.
2717 The last name is the one that the linker finds with -lNAME]])
2718 _LT_DECL([], [soname_spec], [1],
2719 [[The coded name of the library, if different from the real name]])
2720 _LT_DECL([], [postinstall_cmds], [2],
2721 [Command to use after installation of a shared archive])
2722 _LT_DECL([], [postuninstall_cmds], [2],
2723 [Command to use after uninstallation of a shared archive])
2724 _LT_DECL([], [finish_cmds], [2],
2725 [Commands used to finish a libtool library installation in a directory])
2726 _LT_DECL([], [finish_eval], [1],
2727 [[As "finish_cmds", except a single script fragment to be evaled but
2728 not shown]])
2729 _LT_DECL([], [hardcode_into_libs], [0],
2730 [Whether we should hardcode library paths into libraries])
2731 _LT_DECL([], [sys_lib_search_path_spec], [2],
2732 [Compile-time system search path for libraries])
2733 _LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
2734 [Run-time system search path for libraries])
2735 ])# _LT_SYS_DYNAMIC_LINKER
2736
2737
2738 # _LT_PATH_TOOL_PREFIX(TOOL)
2739 # --------------------------
2740 # find a file program which can recognize shared library
2741 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
2742 [m4_require([_LT_DECL_EGREP])dnl
2743 AC_MSG_CHECKING([for $1])
2744 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
2745 [case $MAGIC_CMD in
2746 [[\\/*] | ?:[\\/]*])
2747 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
2748 ;;
2749 *)
2750 lt_save_MAGIC_CMD="$MAGIC_CMD"
2751 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2752 dnl $ac_dummy forces splitting on constant user-supplied paths.
2753 dnl POSIX.2 word splitting is done only on the output of word expansions,
2754 dnl not every word. This closes a longstanding sh security hole.
2755 ac_dummy="m4_if([$2], , $PATH, [$2])"
2756 for ac_dir in $ac_dummy; do
2757 IFS="$lt_save_ifs"
2758 test -z "$ac_dir" && ac_dir=.
2759 if test -f $ac_dir/$1; then
2760 lt_cv_path_MAGIC_CMD="$ac_dir/$1"
2761 if test -n "$file_magic_test_file"; then
2762 case $deplibs_check_method in
2763 "file_magic "*)
2764 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
2765 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2766 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
2767 $EGREP "$file_magic_regex" > /dev/null; then
2768 :
2769 else
2770 cat <<_LT_EOF 1>&2
2771
2772 *** Warning: the command libtool uses to detect shared libraries,
2773 *** $file_magic_cmd, produces output that libtool cannot recognize.
2774 *** The result is that libtool may fail to recognize shared libraries
2775 *** as such. This will affect the creation of libtool libraries that
2776 *** depend on shared libraries, but programs linked with such libtool
2777 *** libraries will work regardless of this problem. Nevertheless, you
2778 *** may want to report the problem to your system manager and/or to
2779 *** bug-libtool@gnu.org
2780
2781 _LT_EOF
2782 fi ;;
2783 esac
2784 fi
2785 break
2786 fi
2787 done
2788 IFS="$lt_save_ifs"
2789 MAGIC_CMD="$lt_save_MAGIC_CMD"
2790 ;;
2791 esac])
2792 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2793 if test -n "$MAGIC_CMD"; then
2794 AC_MSG_RESULT($MAGIC_CMD)
2795 else
2796 AC_MSG_RESULT(no)
2797 fi
2798 _LT_DECL([], [MAGIC_CMD], [0],
2799 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
2800 ])# _LT_PATH_TOOL_PREFIX
2801
2802 # Old name:
2803 AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
2804 dnl aclocal-1.4 backwards compatibility:
2805 dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
2806
2807
2808 # _LT_PATH_MAGIC
2809 # --------------
2810 # find a file program which can recognize a shared library
2811 m4_defun([_LT_PATH_MAGIC],
2812 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
2813 if test -z "$lt_cv_path_MAGIC_CMD"; then
2814 if test -n "$ac_tool_prefix"; then
2815 _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
2816 else
2817 MAGIC_CMD=:
2818 fi
2819 fi
2820 ])# _LT_PATH_MAGIC
2821
2822
2823 # LT_PATH_LD
2824 # ----------
2825 # find the pathname to the GNU or non-GNU linker
2826 AC_DEFUN([LT_PATH_LD],
2827 [AC_REQUIRE([AC_PROG_CC])dnl
2828 AC_REQUIRE([AC_CANONICAL_HOST])dnl
2829 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
2830 m4_require([_LT_DECL_SED])dnl
2831 m4_require([_LT_DECL_EGREP])dnl
2832
2833 AC_ARG_WITH([gnu-ld],
2834 [AS_HELP_STRING([--with-gnu-ld],
2835 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
2836 [test "$withval" = no || with_gnu_ld=yes],
2837 [with_gnu_ld=no])dnl
2838
2839 ac_prog=ld
2840 if test "$GCC" = yes; then
2841 # Check if gcc -print-prog-name=ld gives a path.
2842 AC_MSG_CHECKING([for ld used by $CC])
2843 case $host in
2844 *-*-mingw*)
2845 # gcc leaves a trailing carriage return which upsets mingw
2846 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2847 *)
2848 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
2849 esac
2850 case $ac_prog in
2851 # Accept absolute paths.
2852 [[\\/]]* | ?:[[\\/]]*)
2853 re_direlt='/[[^/]][[^/]]*/\.\./'
2854 # Canonicalize the pathname of ld
2855 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
2856 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
2857 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
2858 done
2859 test -z "$LD" && LD="$ac_prog"
2860 ;;
2861 "")
2862 # If it fails, then pretend we aren't using GCC.
2863 ac_prog=ld
2864 ;;
2865 *)
2866 # If it is relative, then search for the first ld in PATH.
2867 with_gnu_ld=unknown
2868 ;;
2869 esac
2870 elif test "$with_gnu_ld" = yes; then
2871 AC_MSG_CHECKING([for GNU ld])
2872 else
2873 AC_MSG_CHECKING([for non-GNU ld])
2874 fi
2875 AC_CACHE_VAL(lt_cv_path_LD,
2876 [if test -z "$LD"; then
2877 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2878 for ac_dir in $PATH; do
2879 IFS="$lt_save_ifs"
2880 test -z "$ac_dir" && ac_dir=.
2881 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2882 lt_cv_path_LD="$ac_dir/$ac_prog"
2883 # Check to see if the program is GNU ld. I'd rather use --version,
2884 # but apparently some variants of GNU ld only accept -v.
2885 # Break only if it was the GNU/non-GNU ld that we prefer.
2886 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
2887 *GNU* | *'with BFD'*)
2888 test "$with_gnu_ld" != no && break
2889 ;;
2890 *)
2891 test "$with_gnu_ld" != yes && break
2892 ;;
2893 esac
2894 fi
2895 done
2896 IFS="$lt_save_ifs"
2897 else
2898 lt_cv_path_LD="$LD" # Let the user override the test with a path.
2899 fi])
2900 LD="$lt_cv_path_LD"
2901 if test -n "$LD"; then
2902 AC_MSG_RESULT($LD)
2903 else
2904 AC_MSG_RESULT(no)
2905 fi
2906 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
2907 _LT_PATH_LD_GNU
2908 AC_SUBST([LD])
2909
2910 _LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
2911 ])# LT_PATH_LD
2912
2913 # Old names:
2914 AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
2915 AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
2916 dnl aclocal-1.4 backwards compatibility:
2917 dnl AC_DEFUN([AM_PROG_LD], [])
2918 dnl AC_DEFUN([AC_PROG_LD], [])
2919
2920
2921 # _LT_PATH_LD_GNU
2922 #- --------------
2923 m4_defun([_LT_PATH_LD_GNU],
2924 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
2925 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
2926 case `$LD -v 2>&1 </dev/null` in
2927 *GNU* | *'with BFD'*)
2928 lt_cv_prog_gnu_ld=yes
2929 ;;
2930 *)
2931 lt_cv_prog_gnu_ld=no
2932 ;;
2933 esac])
2934 with_gnu_ld=$lt_cv_prog_gnu_ld
2935 ])# _LT_PATH_LD_GNU
2936
2937
2938 # _LT_CMD_RELOAD
2939 # --------------
2940 # find reload flag for linker
2941 # -- PORTME Some linkers may need a different reload flag.
2942 m4_defun([_LT_CMD_RELOAD],
2943 [AC_CACHE_CHECK([for $LD option to reload object files],
2944 lt_cv_ld_reload_flag,
2945 [lt_cv_ld_reload_flag='-r'])
2946 reload_flag=$lt_cv_ld_reload_flag
2947 case $reload_flag in
2948 "" | " "*) ;;
2949 *) reload_flag=" $reload_flag" ;;
2950 esac
2951 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2952 case $host_os in
2953 darwin*)
2954 if test "$GCC" = yes; then
2955 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
2956 else
2957 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2958 fi
2959 ;;
2960 esac
2961 _LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
2962 _LT_DECL([], [reload_cmds], [2])dnl
2963 ])# _LT_CMD_RELOAD
2964
2965
2966 # _LT_CHECK_MAGIC_METHOD
2967 # ----------------------
2968 # how to check for library dependencies
2969 # -- PORTME fill in with the dynamic library characteristics
2970 m4_defun([_LT_CHECK_MAGIC_METHOD],
2971 [m4_require([_LT_DECL_EGREP])
2972 m4_require([_LT_DECL_OBJDUMP])
2973 AC_CACHE_CHECK([how to recognize dependent libraries],
2974 lt_cv_deplibs_check_method,
2975 [lt_cv_file_magic_cmd='$MAGIC_CMD'
2976 lt_cv_file_magic_test_file=
2977 lt_cv_deplibs_check_method='unknown'
2978 # Need to set the preceding variable on all platforms that support
2979 # interlibrary dependencies.
2980 # 'none' -- dependencies not supported.
2981 # `unknown' -- same as none, but documents that we really don't know.
2982 # 'pass_all' -- all dependencies passed with no checks.
2983 # 'test_compile' -- check by making test program.
2984 # 'file_magic [[regex]]' -- check by looking for files in library path
2985 # which responds to the $file_magic_cmd with a given extended regex.
2986 # If you have `file' or equivalent on your system and you're not sure
2987 # whether `pass_all' will *always* work, you probably want this one.
2988
2989 case $host_os in
2990 aix[[4-9]]*)
2991 lt_cv_deplibs_check_method=pass_all
2992 ;;
2993
2994 beos*)
2995 lt_cv_deplibs_check_method=pass_all
2996 ;;
2997
2998 bsdi[[45]]*)
2999 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
3000 lt_cv_file_magic_cmd='/usr/bin/file -L'
3001 lt_cv_file_magic_test_file=/shlib/libc.so
3002 ;;
3003
3004 cygwin*)
3005 # func_win32_libid is a shell function defined in ltmain.sh
3006 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3007 lt_cv_deplibs_check_method=pass_all
3008 lt_cv_file_magic_cmd='func_win32_libid'
3009 ;;
3010
3011 mingw* | pw32*)
3012 # Base MSYS/MinGW do not provide the 'file' command needed by
3013 # func_win32_libid shell function, so use a weaker test based on 'objdump',
3014 # unless we find 'file', for example because we are cross-compiling.
3015 if ( file / ) >/dev/null 2>&1; then
3016 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3017 lt_cv_file_magic_cmd='func_win32_libid'
3018 else
3019 lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
3020 lt_cv_file_magic_cmd='$OBJDUMP -f'
3021 fi
3022 lt_cv_deplibs_check_method=pass_all
3023 ;;
3024
3025 cegcc)
3026 # use the weaker test based on 'objdump'. See mingw*.
3027 lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
3028 lt_cv_file_magic_cmd='$OBJDUMP -f'
3029 ;;
3030
3031 darwin* | rhapsody*)
3032 lt_cv_deplibs_check_method=pass_all
3033 ;;
3034
3035 freebsd* | dragonfly*)
3036 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3037 case $host_cpu in
3038 i*86 )
3039 # Not sure whether the presence of OpenBSD here was a mistake.
3040 # Let's accept both of them until this is cleared up.
3041 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
3042 lt_cv_file_magic_cmd=/usr/bin/file
3043 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
3044 ;;
3045 esac
3046 else
3047 lt_cv_deplibs_check_method=pass_all
3048 fi
3049 ;;
3050
3051 gnu*)
3052 lt_cv_deplibs_check_method=pass_all
3053 ;;
3054
3055 hpux10.20* | hpux11*)
3056 lt_cv_file_magic_cmd=/usr/bin/file
3057 case $host_cpu in
3058 ia64*)
3059 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
3060 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
3061 ;;
3062 hppa*64*)
3063 [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]']
3064 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
3065 ;;
3066 *)
3067 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
3068 lt_cv_file_magic_test_file=/usr/lib/libc.sl
3069 ;;
3070 esac
3071 ;;
3072
3073 interix[[3-9]]*)
3074 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
3075 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
3076 ;;
3077
3078 irix5* | irix6* | nonstopux*)
3079 case $LD in
3080 *-32|*"-32 ") libmagic=32-bit;;
3081 *-n32|*"-n32 ") libmagic=N32;;
3082 *-64|*"-64 ") libmagic=64-bit;;
3083 *) libmagic=never-match;;
3084 esac
3085 lt_cv_deplibs_check_method=pass_all
3086 ;;
3087
3088 # This must be Linux ELF.
3089 linux* | k*bsd*-gnu)
3090 lt_cv_deplibs_check_method=pass_all
3091 ;;
3092
3093 netbsd*)
3094 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3095 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3096 else
3097 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
3098 fi
3099 ;;
3100
3101 newos6*)
3102 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
3103 lt_cv_file_magic_cmd=/usr/bin/file
3104 lt_cv_file_magic_test_file=/usr/lib/libnls.so
3105 ;;
3106
3107 *nto* | *qnx*)
3108 lt_cv_deplibs_check_method=pass_all
3109 ;;
3110
3111 openbsd*)
3112 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
3113 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
3114 else
3115 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3116 fi
3117 ;;
3118
3119 osf3* | osf4* | osf5*)
3120 lt_cv_deplibs_check_method=pass_all
3121 ;;
3122
3123 rdos*)
3124 lt_cv_deplibs_check_method=pass_all
3125 ;;
3126
3127 solaris*)
3128 lt_cv_deplibs_check_method=pass_all
3129 ;;
3130
3131 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
3132 lt_cv_deplibs_check_method=pass_all
3133 ;;
3134
3135 sysv4 | sysv4.3*)
3136 case $host_vendor in
3137 motorola)
3138 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]]'
3139 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
3140 ;;
3141 ncr)
3142 lt_cv_deplibs_check_method=pass_all
3143 ;;
3144 sequent)
3145 lt_cv_file_magic_cmd='/bin/file'
3146 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
3147 ;;
3148 sni)
3149 lt_cv_file_magic_cmd='/bin/file'
3150 lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
3151 lt_cv_file_magic_test_file=/lib/libc.so
3152 ;;
3153 siemens)
3154 lt_cv_deplibs_check_method=pass_all
3155 ;;
3156 pc)
3157 lt_cv_deplibs_check_method=pass_all
3158 ;;
3159 esac
3160 ;;
3161
3162 tpf*)
3163 lt_cv_deplibs_check_method=pass_all
3164 ;;
3165 esac
3166 ])
3167 file_magic_cmd=$lt_cv_file_magic_cmd
3168 deplibs_check_method=$lt_cv_deplibs_check_method
3169 test -z "$deplibs_check_method" && deplibs_check_method=unknown
3170
3171 _LT_DECL([], [deplibs_check_method], [1],
3172 [Method to check whether dependent libraries are shared objects])
3173 _LT_DECL([], [file_magic_cmd], [1],
3174 [Command to use when deplibs_check_method == "file_magic"])
3175 ])# _LT_CHECK_MAGIC_METHOD
3176
3177
3178 # LT_PATH_NM
3179 # ----------
3180 # find the pathname to a BSD- or MS-compatible name lister
3181 AC_DEFUN([LT_PATH_NM],
3182 [AC_REQUIRE([AC_PROG_CC])dnl
3183 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
3184 [if test -n "$NM"; then
3185 # Let the user override the test.
3186 lt_cv_path_NM="$NM"
3187 else
3188 lt_nm_to_check="${ac_tool_prefix}nm"
3189 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
3190 lt_nm_to_check="$lt_nm_to_check nm"
3191 fi
3192 for lt_tmp_nm in $lt_nm_to_check; do
3193 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3194 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
3195 IFS="$lt_save_ifs"
3196 test -z "$ac_dir" && ac_dir=.
3197 tmp_nm="$ac_dir/$lt_tmp_nm"
3198 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
3199 # Check to see if the nm accepts a BSD-compat flag.
3200 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
3201 # nm: unknown option "B" ignored
3202 # Tru64's nm complains that /dev/null is an invalid object file
3203 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
3204 */dev/null* | *'Invalid file or object type'*)
3205 lt_cv_path_NM="$tmp_nm -B"
3206 break
3207 ;;
3208 *)
3209 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
3210 */dev/null*)
3211 lt_cv_path_NM="$tmp_nm -p"
3212 break
3213 ;;
3214 *)
3215 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
3216 continue # so that we can try to find one that supports BSD flags
3217 ;;
3218 esac
3219 ;;
3220 esac
3221 fi
3222 done
3223 IFS="$lt_save_ifs"
3224 done
3225 : ${lt_cv_path_NM=no}
3226 fi])
3227 if test "$lt_cv_path_NM" != "no"; then
3228 NM="$lt_cv_path_NM"
3229 else
3230 # Didn't find any BSD compatible name lister, look for dumpbin.
3231 AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
3232 AC_SUBST([DUMPBIN])
3233 if test "$DUMPBIN" != ":"; then
3234 NM="$DUMPBIN"
3235 fi
3236 fi
3237 test -z "$NM" && NM=nm
3238 AC_SUBST([NM])
3239 _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
3240
3241 AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
3242 [lt_cv_nm_interface="BSD nm"
3243 echo "int some_variable = 0;" > conftest.$ac_ext
3244 (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
3245 (eval "$ac_compile" 2>conftest.err)
3246 cat conftest.err >&AS_MESSAGE_LOG_FD
3247 (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
3248 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
3249 cat conftest.err >&AS_MESSAGE_LOG_FD
3250 (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
3251 cat conftest.out >&AS_MESSAGE_LOG_FD
3252 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
3253 lt_cv_nm_interface="MS dumpbin"
3254 fi
3255 rm -f conftest*])
3256 ])# LT_PATH_NM
3257
3258 # Old names:
3259 AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
3260 AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
3261 dnl aclocal-1.4 backwards compatibility:
3262 dnl AC_DEFUN([AM_PROG_NM], [])
3263 dnl AC_DEFUN([AC_PROG_NM], [])
3264
3265
3266 # LT_LIB_M
3267 # --------
3268 # check for math library
3269 AC_DEFUN([LT_LIB_M],
3270 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3271 LIBM=
3272 case $host in
3273 *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
3274 # These system don't have libm, or don't need it
3275 ;;
3276 *-ncr-sysv4.3*)
3277 AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
3278 AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
3279 ;;
3280 *)
3281 AC_CHECK_LIB(m, cos, LIBM="-lm")
3282 ;;
3283 esac
3284 AC_SUBST([LIBM])
3285 ])# LT_LIB_M
3286
3287 # Old name:
3288 AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
3289 dnl aclocal-1.4 backwards compatibility:
3290 dnl AC_DEFUN([AC_CHECK_LIBM], [])
3291
3292
3293 # _LT_COMPILER_NO_RTTI([TAGNAME])
3294 # -------------------------------
3295 m4_defun([_LT_COMPILER_NO_RTTI],
3296 [m4_require([_LT_TAG_COMPILER])dnl
3297
3298 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
3299
3300 if test "$GCC" = yes; then
3301 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
3302
3303 _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
3304 lt_cv_prog_compiler_rtti_exceptions,
3305 [-fno-rtti -fno-exceptions], [],
3306 [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
3307 fi
3308 _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
3309 [Compiler flag to turn off builtin functions])
3310 ])# _LT_COMPILER_NO_RTTI
3311
3312
3313 # _LT_CMD_GLOBAL_SYMBOLS
3314 # ----------------------
3315 m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
3316 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3317 AC_REQUIRE([AC_PROG_CC])dnl
3318 AC_REQUIRE([LT_PATH_NM])dnl
3319 AC_REQUIRE([LT_PATH_LD])dnl
3320 m4_require([_LT_DECL_SED])dnl
3321 m4_require([_LT_DECL_EGREP])dnl
3322 m4_require([_LT_TAG_COMPILER])dnl
3323
3324 # Check for command to grab the raw symbol name followed by C symbol from nm.
3325 AC_MSG_CHECKING([command to parse $NM output from $compiler object])
3326 AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
3327 [
3328 # These are sane defaults that work on at least a few old systems.
3329 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
3330
3331 # Character class describing NM global symbol codes.
3332 symcode='[[BCDEGRST]]'
3333
3334 # Regexp to match symbols that can be accessed directly from C.
3335 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
3336
3337 # Define system-specific variables.
3338 case $host_os in
3339 aix*)
3340 symcode='[[BCDT]]'
3341 ;;
3342 cygwin* | mingw* | pw32* | cegcc*)
3343 symcode='[[ABCDGISTW]]'
3344 ;;
3345 hpux*)
3346 if test "$host_cpu" = ia64; then
3347 symcode='[[ABCDEGRST]]'
3348 fi
3349 ;;
3350 irix* | nonstopux*)
3351 symcode='[[BCDEGRST]]'
3352 ;;
3353 osf*)
3354 symcode='[[BCDEGQRST]]'
3355 ;;
3356 solaris*)
3357 symcode='[[BDRT]]'
3358 ;;
3359 sco3.2v5*)
3360 symcode='[[DT]]'
3361 ;;
3362 sysv4.2uw2*)
3363 symcode='[[DT]]'
3364 ;;
3365 sysv5* | sco5v6* | unixware* | OpenUNIX*)
3366 symcode='[[ABDT]]'
3367 ;;
3368 sysv4)
3369 symcode='[[DFNSTU]]'
3370 ;;
3371 esac
3372
3373 # If we're using GNU nm, then use its standard symbol codes.
3374 case `$NM -V 2>&1` in
3375 *GNU* | *'with BFD'*)
3376 symcode='[[ABCDGIRSTW]]' ;;
3377 esac
3378
3379 # Transform an extracted symbol line into a proper C declaration.
3380 # Some systems (esp. on ia64) link data and code symbols differently,
3381 # so use this general approach.
3382 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
3383
3384 # Transform an extracted symbol line into symbol name and symbol address
3385 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
3386 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'"
3387
3388 # Handle CRLF in mingw tool chain
3389 opt_cr=
3390 case $build_os in
3391 mingw*)
3392 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
3393 ;;
3394 esac
3395
3396 # Try without a prefix underscore, then with it.
3397 for ac_symprfx in "" "_"; do
3398
3399 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
3400 symxfrm="\\1 $ac_symprfx\\2 \\2"
3401
3402 # Write the raw and C identifiers.
3403 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
3404 # Fake it for dumpbin and say T for any non-static function
3405 # and D for any global variable.
3406 # Also find C++ and __fastcall symbols from MSVC++,
3407 # which start with @ or ?.
3408 lt_cv_sys_global_symbol_pipe="$AWK ['"\
3409 " {last_section=section; section=\$ 3};"\
3410 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
3411 " \$ 0!~/External *\|/{next};"\
3412 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
3413 " {if(hide[section]) next};"\
3414 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
3415 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
3416 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
3417 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
3418 " ' prfx=^$ac_symprfx]"
3419 else
3420 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
3421 fi
3422
3423 # Check to see that the pipe works correctly.
3424 pipe_works=no
3425
3426 rm -f conftest*
3427 cat > conftest.$ac_ext <<_LT_EOF
3428 #ifdef __cplusplus
3429 extern "C" {
3430 #endif
3431 char nm_test_var;
3432 void nm_test_func(void);
3433 void nm_test_func(void){}
3434 #ifdef __cplusplus
3435 }
3436 #endif
3437 int main(){nm_test_var='a';nm_test_func();return(0);}
3438 _LT_EOF
3439
3440 if AC_TRY_EVAL(ac_compile); then
3441 # Now try to grab the symbols.
3442 nlist=conftest.nm
3443 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
3444 # Try sorting and uniquifying the output.
3445 if sort "$nlist" | uniq > "$nlist"T; then
3446 mv -f "$nlist"T "$nlist"
3447 else
3448 rm -f "$nlist"T
3449 fi
3450
3451 # Make sure that we snagged all the symbols we need.
3452 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
3453 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
3454 cat <<_LT_EOF > conftest.$ac_ext
3455 #ifdef __cplusplus
3456 extern "C" {
3457 #endif
3458
3459 _LT_EOF
3460 # Now generate the symbol file.
3461 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
3462
3463 cat <<_LT_EOF >> conftest.$ac_ext
3464
3465 /* The mapping between symbol names and symbols. */
3466 const struct {
3467 const char *name;
3468 void *address;
3469 }
3470 lt__PROGRAM__LTX_preloaded_symbols[[]] =
3471 {
3472 { "@PROGRAM@", (void *) 0 },
3473 _LT_EOF
3474 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
3475 cat <<\_LT_EOF >> conftest.$ac_ext
3476 {0, (void *) 0}
3477 };
3478
3479 /* This works around a problem in FreeBSD linker */
3480 #ifdef FREEBSD_WORKAROUND
3481 static const void *lt_preloaded_setup() {
3482 return lt__PROGRAM__LTX_preloaded_symbols;
3483 }
3484 #endif
3485
3486 #ifdef __cplusplus
3487 }
3488 #endif
3489 _LT_EOF
3490 # Now try linking the two files.
3491 mv conftest.$ac_objext conftstm.$ac_objext
3492 lt_save_LIBS="$LIBS"
3493 lt_save_CFLAGS="$CFLAGS"
3494 LIBS="conftstm.$ac_objext"
3495 CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
3496 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
3497 pipe_works=yes
3498 fi
3499 LIBS="$lt_save_LIBS"
3500 CFLAGS="$lt_save_CFLAGS"
3501 else
3502 echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
3503 fi
3504 else
3505 echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
3506 fi
3507 else
3508 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
3509 fi
3510 else
3511 echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
3512 cat conftest.$ac_ext >&5
3513 fi
3514 rm -rf conftest* conftst*
3515
3516 # Do not use the global_symbol_pipe unless it works.
3517 if test "$pipe_works" = yes; then
3518 break
3519 else
3520 lt_cv_sys_global_symbol_pipe=
3521 fi
3522 done
3523 ])
3524 if test -z "$lt_cv_sys_global_symbol_pipe"; then
3525 lt_cv_sys_global_symbol_to_cdecl=
3526 fi
3527 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
3528 AC_MSG_RESULT(failed)
3529 else
3530 AC_MSG_RESULT(ok)
3531 fi
3532
3533 _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
3534 [Take the output of nm and produce a listing of raw symbols and C names])
3535 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
3536 [Transform the output of nm in a proper C declaration])
3537 _LT_DECL([global_symbol_to_c_name_address],
3538 [lt_cv_sys_global_symbol_to_c_name_address], [1],
3539 [Transform the output of nm in a C name address pair])
3540 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
3541 [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
3542 [Transform the output of nm in a C name address pair when lib prefix is needed])
3543 ]) # _LT_CMD_GLOBAL_SYMBOLS
3544
3545
3546 # _LT_COMPILER_PIC([TAGNAME])
3547 # ---------------------------
3548 m4_defun([_LT_COMPILER_PIC],
3549 [m4_require([_LT_TAG_COMPILER])dnl
3550 _LT_TAGVAR(lt_prog_compiler_wl, $1)=
3551 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3552 _LT_TAGVAR(lt_prog_compiler_static, $1)=
3553
3554 AC_MSG_CHECKING([for $compiler option to produce PIC])
3555 m4_if([$1], [CXX], [
3556 # C++ specific cases for pic, static, wl, etc.
3557 if test "$GXX" = yes; then
3558 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3559 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3560
3561 case $host_os in
3562 aix*)
3563 # All AIX code is PIC.
3564 if test "$host_cpu" = ia64; then
3565 # AIX 5 now supports IA64 processor
3566 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3567 fi
3568 ;;
3569
3570 amigaos*)
3571 case $host_cpu in
3572 powerpc)
3573 # see comment about AmigaOS4 .so support
3574 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3575 ;;
3576 m68k)
3577 # FIXME: we need at least 68020 code to build shared libraries, but
3578 # adding the `-m68020' flag to GCC prevents building anything better,
3579 # like `-m68040'.
3580 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3581 ;;
3582 esac
3583 ;;
3584
3585 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3586 # PIC is the default for these OSes.
3587 ;;
3588 mingw* | cygwin* | os2* | pw32* | cegcc*)
3589 # This hack is so that the source file can tell whether it is being
3590 # built for inclusion in a dll (and should export symbols for example).
3591 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3592 # (--disable-auto-import) libraries
3593 m4_if([$1], [GCJ], [],
3594 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3595 ;;
3596 darwin* | rhapsody*)
3597 # PIC is the default on this platform
3598 # Common symbols not allowed in MH_DYLIB files
3599 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3600 ;;
3601 *djgpp*)
3602 # DJGPP does not support shared libraries at all
3603 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3604 ;;
3605 interix[[3-9]]*)
3606 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3607 # Instead, we relocate shared libraries at runtime.
3608 ;;
3609 sysv4*MP*)
3610 if test -d /usr/nec; then
3611 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3612 fi
3613 ;;
3614 hpux*)
3615 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
3616 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
3617 # sets the default TLS model and affects inlining.
3618 case $host_cpu in
3619 hppa*64*)
3620 ;;
3621 *)
3622 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3623 ;;
3624 esac
3625 ;;
3626 *qnx* | *nto*)
3627 # QNX uses GNU C++, but need to define -shared option too, otherwise
3628 # it will coredump.
3629 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3630 ;;
3631 *)
3632 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3633 ;;
3634 esac
3635 else
3636 case $host_os in
3637 aix[[4-9]]*)
3638 # All AIX code is PIC.
3639 if test "$host_cpu" = ia64; then
3640 # AIX 5 now supports IA64 processor
3641 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3642 else
3643 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3644 fi
3645 ;;
3646 chorus*)
3647 case $cc_basename in
3648 cxch68*)
3649 # Green Hills C++ Compiler
3650 # _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"
3651 ;;
3652 esac
3653 ;;
3654 dgux*)
3655 case $cc_basename in
3656 ec++*)
3657 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3658 ;;
3659 ghcx*)
3660 # Green Hills C++ Compiler
3661 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3662 ;;
3663 *)
3664 ;;
3665 esac
3666 ;;
3667 freebsd* | dragonfly*)
3668 # FreeBSD uses GNU C++
3669 ;;
3670 hpux9* | hpux10* | hpux11*)
3671 case $cc_basename in
3672 CC*)
3673 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3674 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3675 if test "$host_cpu" != ia64; then
3676 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3677 fi
3678 ;;
3679 aCC*)
3680 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3681 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3682 case $host_cpu in
3683 hppa*64*|ia64*)
3684 # +Z the default
3685 ;;
3686 *)
3687 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3688 ;;
3689 esac
3690 ;;
3691 *)
3692 ;;
3693 esac
3694 ;;
3695 interix*)
3696 # This is c89, which is MS Visual C++ (no shared libs)
3697 # Anyone wants to do a port?
3698 ;;
3699 irix5* | irix6* | nonstopux*)
3700 case $cc_basename in
3701 CC*)
3702 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3703 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3704 # CC pic flag -KPIC is the default.
3705 ;;
3706 *)
3707 ;;
3708 esac
3709 ;;
3710 linux* | k*bsd*-gnu)
3711 case $cc_basename in
3712 KCC*)
3713 # KAI C++ Compiler
3714 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3715 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3716 ;;
3717 ecpc* )
3718 # old Intel C++ for x86_64 which still supported -KPIC.
3719 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3720 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3721 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3722 ;;
3723 icpc* )
3724 # Intel C++, used to be incompatible with GCC.
3725 # ICC 10 doesn't accept -KPIC any more.
3726 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3727 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3728 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3729 ;;
3730 pgCC* | pgcpp*)
3731 # Portland Group C++ compiler
3732 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3733 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
3734 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3735 ;;
3736 cxx*)
3737 # Compaq C++
3738 # Make sure the PIC flag is empty. It appears that all Alpha
3739 # Linux and Compaq Tru64 Unix objects are PIC.
3740 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3741 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3742 ;;
3743 xlc* | xlC*)
3744 # IBM XL 8.0 on PPC
3745 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3746 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
3747 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
3748 ;;
3749 *)
3750 case `$CC -V 2>&1 | sed 5q` in
3751 *Sun\ C*)
3752 # Sun C++ 5.9
3753 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3754 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3755 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3756 ;;
3757 esac
3758 ;;
3759 esac
3760 ;;
3761 lynxos*)
3762 ;;
3763 m88k*)
3764 ;;
3765 mvs*)
3766 case $cc_basename in
3767 cxx*)
3768 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
3769 ;;
3770 *)
3771 ;;
3772 esac
3773 ;;
3774 netbsd*)
3775 ;;
3776 *qnx* | *nto*)
3777 # QNX uses GNU C++, but need to define -shared option too, otherwise
3778 # it will coredump.
3779 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3780 ;;
3781 osf3* | osf4* | osf5*)
3782 case $cc_basename in
3783 KCC*)
3784 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3785 ;;
3786 RCC*)
3787 # Rational C++ 2.4.1
3788 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3789 ;;
3790 cxx*)
3791 # Digital/Compaq C++
3792 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3793 # Make sure the PIC flag is empty. It appears that all Alpha
3794 # Linux and Compaq Tru64 Unix objects are PIC.
3795 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3796 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3797 ;;
3798 *)
3799 ;;
3800 esac
3801 ;;
3802 psos*)
3803 ;;
3804 solaris*)
3805 case $cc_basename in
3806 CC*)
3807 # Sun C++ 4.2, 5.x and Centerline C++
3808 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3809 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3810 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3811 ;;
3812 gcx*)
3813 # Green Hills C++ Compiler
3814 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
3815 ;;
3816 *)
3817 ;;
3818 esac
3819 ;;
3820 sunos4*)
3821 case $cc_basename in
3822 CC*)
3823 # Sun C++ 4.x
3824 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3825 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3826 ;;
3827 lcc*)
3828 # Lucid
3829 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3830 ;;
3831 *)
3832 ;;
3833 esac
3834 ;;
3835 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
3836 case $cc_basename in
3837 CC*)
3838 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3839 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3840 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3841 ;;
3842 esac
3843 ;;
3844 tandem*)
3845 case $cc_basename in
3846 NCC*)
3847 # NonStop-UX NCC 3.20
3848 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3849 ;;
3850 *)
3851 ;;
3852 esac
3853 ;;
3854 vxworks*)
3855 ;;
3856 *)
3857 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3858 ;;
3859 esac
3860 fi
3861 ],
3862 [
3863 if test "$GCC" = yes; then
3864 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3865 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3866
3867 case $host_os in
3868 aix*)
3869 # All AIX code is PIC.
3870 if test "$host_cpu" = ia64; then
3871 # AIX 5 now supports IA64 processor
3872 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3873 fi
3874 ;;
3875
3876 amigaos*)
3877 case $host_cpu in
3878 powerpc)
3879 # see comment about AmigaOS4 .so support
3880 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3881 ;;
3882 m68k)
3883 # FIXME: we need at least 68020 code to build shared libraries, but
3884 # adding the `-m68020' flag to GCC prevents building anything better,
3885 # like `-m68040'.
3886 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3887 ;;
3888 esac
3889 ;;
3890
3891 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3892 # PIC is the default for these OSes.
3893 ;;
3894
3895 mingw* | cygwin* | pw32* | os2* | cegcc*)
3896 # This hack is so that the source file can tell whether it is being
3897 # built for inclusion in a dll (and should export symbols for example).
3898 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3899 # (--disable-auto-import) libraries
3900 m4_if([$1], [GCJ], [],
3901 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3902 ;;
3903
3904 darwin* | rhapsody*)
3905 # PIC is the default on this platform
3906 # Common symbols not allowed in MH_DYLIB files
3907 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3908 ;;
3909
3910 hpux*)
3911 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
3912 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
3913 # sets the default TLS model and affects inlining.
3914 case $host_cpu in
3915 hppa*64*)
3916 # +Z the default
3917 ;;
3918 *)
3919 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3920 ;;
3921 esac
3922 ;;
3923
3924 interix[[3-9]]*)
3925 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3926 # Instead, we relocate shared libraries at runtime.
3927 ;;
3928
3929 msdosdjgpp*)
3930 # Just because we use GCC doesn't mean we suddenly get shared libraries
3931 # on systems that don't support them.
3932 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3933 enable_shared=no
3934 ;;
3935
3936 *nto* | *qnx*)
3937 # QNX uses GNU C++, but need to define -shared option too, otherwise
3938 # it will coredump.
3939 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3940 ;;
3941
3942 sysv4*MP*)
3943 if test -d /usr/nec; then
3944 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3945 fi
3946 ;;
3947
3948 *)
3949 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3950 ;;
3951 esac
3952 else
3953 # PORTME Check for flag to pass linker flags through the system compiler.
3954 case $host_os in
3955 aix*)
3956 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3957 if test "$host_cpu" = ia64; then
3958 # AIX 5 now supports IA64 processor
3959 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3960 else
3961 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3962 fi
3963 ;;
3964
3965 mingw* | cygwin* | pw32* | os2* | cegcc*)
3966 # This hack is so that the source file can tell whether it is being
3967 # built for inclusion in a dll (and should export symbols for example).
3968 m4_if([$1], [GCJ], [],
3969 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3970 ;;
3971
3972 hpux9* | hpux10* | hpux11*)
3973 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3974 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
3975 # not for PA HP-UX.
3976 case $host_cpu in
3977 hppa*64*|ia64*)
3978 # +Z the default
3979 ;;
3980 *)
3981 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3982 ;;
3983 esac
3984 # Is there a better lt_prog_compiler_static that works with the bundled CC?
3985 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3986 ;;
3987
3988 irix5* | irix6* | nonstopux*)
3989 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3990 # PIC (with -KPIC) is the default.
3991 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3992 ;;
3993
3994 linux* | k*bsd*-gnu)
3995 case $cc_basename in
3996 # old Intel for x86_64 which still supported -KPIC.
3997 ecc*)
3998 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3999 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4000 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
4001 ;;
4002 # icc used to be incompatible with GCC.
4003 # ICC 10 doesn't accept -KPIC any more.
4004 icc* | ifort*)
4005 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4006 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
4007 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
4008 ;;
4009 # Lahey Fortran 8.1.
4010 lf95*)
4011 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4012 _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
4013 _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
4014 ;;
4015 pgcc* | pgf77* | pgf90* | pgf95*)
4016 # Portland Group compilers (*not* the Pentium gcc compiler,
4017 # which looks to be a dead project)
4018 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4019 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
4020 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4021 ;;
4022 ccc*)
4023 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4024 # All Alpha code is PIC.
4025 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4026 ;;
4027 xl*)
4028 # IBM XL C 8.0/Fortran 10.1 on PPC
4029 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4030 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
4031 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
4032 ;;
4033 *)
4034 case `$CC -V 2>&1 | sed 5q` in
4035 *Sun\ C*)
4036 # Sun C 5.9
4037 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4038 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4039 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4040 ;;
4041 *Sun\ F*)
4042 # Sun Fortran 8.3 passes all unrecognized flags to the linker
4043 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4044 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4045 _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
4046 ;;
4047 esac
4048 ;;
4049 esac
4050 ;;
4051
4052 newsos6)
4053 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4054 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4055 ;;
4056
4057 *nto* | *qnx*)
4058 # QNX uses GNU C++, but need to define -shared option too, otherwise
4059 # it will coredump.
4060 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
4061 ;;
4062
4063 osf3* | osf4* | osf5*)
4064 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4065 # All OSF/1 code is PIC.
4066 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4067 ;;
4068
4069 rdos*)
4070 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4071 ;;
4072
4073 solaris*)
4074 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4075 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4076 case $cc_basename in
4077 f77* | f90* | f95*)
4078 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
4079 *)
4080 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
4081 esac
4082 ;;
4083
4084 sunos4*)
4085 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
4086 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
4087 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4088 ;;
4089
4090 sysv4 | sysv4.2uw2* | sysv4.3*)
4091 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4092 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4093 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4094 ;;
4095
4096 sysv4*MP*)
4097 if test -d /usr/nec ;then
4098 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
4099 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4100 fi
4101 ;;
4102
4103 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
4104 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4105 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4106 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4107 ;;
4108
4109 unicos*)
4110 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4111 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4112 ;;
4113
4114 uts4*)
4115 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
4116 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4117 ;;
4118
4119 *)
4120 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4121 ;;
4122 esac
4123 fi
4124 ])
4125 case $host_os in
4126 # For platforms which do not support PIC, -DPIC is meaningless:
4127 *djgpp*)
4128 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
4129 ;;
4130 *)
4131 _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
4132 ;;
4133 esac
4134 AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
4135 _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
4136 [How to pass a linker flag through the compiler])
4137
4138 #
4139 # Check to make sure the PIC flag actually works.
4140 #
4141 if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
4142 _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
4143 [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
4144 [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
4145 [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
4146 "" | " "*) ;;
4147 *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
4148 esac],
4149 [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
4150 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
4151 fi
4152 _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
4153 [Additional compiler flags for building library objects])
4154
4155 #
4156 # Check to make sure the static flag actually works.
4157 #
4158 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
4159 _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
4160 _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
4161 $lt_tmp_static_flag,
4162 [],
4163 [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
4164 _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
4165 [Compiler flag to prevent dynamic linking])
4166 ])# _LT_COMPILER_PIC
4167
4168
4169 # _LT_LINKER_SHLIBS([TAGNAME])
4170 # ----------------------------
4171 # See if the linker supports building shared libraries.
4172 m4_defun([_LT_LINKER_SHLIBS],
4173 [AC_REQUIRE([LT_PATH_LD])dnl
4174 AC_REQUIRE([LT_PATH_NM])dnl
4175 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
4176 m4_require([_LT_DECL_EGREP])dnl
4177 m4_require([_LT_DECL_SED])dnl
4178 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
4179 m4_require([_LT_TAG_COMPILER])dnl
4180 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
4181 m4_if([$1], [CXX], [
4182 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4183 case $host_os in
4184 aix[[4-9]]*)
4185 # If we're using GNU nm, then we don't want the "-C" option.
4186 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4187 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4188 _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'
4189 else
4190 _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'
4191 fi
4192 ;;
4193 pw32*)
4194 _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
4195 ;;
4196 cygwin* | mingw* | cegcc*)
4197 _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'
4198 ;;
4199 *)
4200 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4201 ;;
4202 esac
4203 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4204 ], [
4205 runpath_var=
4206 _LT_TAGVAR(allow_undefined_flag, $1)=
4207 _LT_TAGVAR(always_export_symbols, $1)=no
4208 _LT_TAGVAR(archive_cmds, $1)=
4209 _LT_TAGVAR(archive_expsym_cmds, $1)=
4210 _LT_TAGVAR(compiler_needs_object, $1)=no
4211 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
4212 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4213 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4214 _LT_TAGVAR(hardcode_automatic, $1)=no
4215 _LT_TAGVAR(hardcode_direct, $1)=no
4216 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
4217 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4218 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
4219 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4220 _LT_TAGVAR(hardcode_minus_L, $1)=no
4221 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
4222 _LT_TAGVAR(inherit_rpath, $1)=no
4223 _LT_TAGVAR(link_all_deplibs, $1)=unknown
4224 _LT_TAGVAR(module_cmds, $1)=
4225 _LT_TAGVAR(module_expsym_cmds, $1)=
4226 _LT_TAGVAR(old_archive_from_new_cmds, $1)=
4227 _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
4228 _LT_TAGVAR(thread_safe_flag_spec, $1)=
4229 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4230 # include_expsyms should be a list of space-separated symbols to be *always*
4231 # included in the symbol list
4232 _LT_TAGVAR(include_expsyms, $1)=
4233 # exclude_expsyms can be an extended regexp of symbols to exclude
4234 # it will be wrapped by ` (' and `)$', so one must not match beginning or
4235 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
4236 # as well as any symbol that contains `d'.
4237 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4238 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
4239 # platforms (ab)use it in PIC code, but their linkers get confused if
4240 # the symbol is explicitly referenced. Since portable code cannot
4241 # rely on this symbol name, it's probably fine to never include it in
4242 # preloaded symbol tables.
4243 # Exclude shared library initialization/finalization symbols.
4244 dnl Note also adjust exclude_expsyms for C++ above.
4245 extract_expsyms_cmds=
4246
4247 case $host_os in
4248 cygwin* | mingw* | pw32* | cegcc*)
4249 # FIXME: the MSVC++ port hasn't been tested in a loooong time
4250 # When not using gcc, we currently assume that we are using
4251 # Microsoft Visual C++.
4252 if test "$GCC" != yes; then
4253 with_gnu_ld=no
4254 fi
4255 ;;
4256 interix*)
4257 # we just hope/assume this is gcc and not c89 (= MSVC++)
4258 with_gnu_ld=yes
4259 ;;
4260 openbsd*)
4261 with_gnu_ld=no
4262 ;;
4263 esac
4264
4265 _LT_TAGVAR(ld_shlibs, $1)=yes
4266 if test "$with_gnu_ld" = yes; then
4267 # If archive_cmds runs LD, not CC, wlarc should be empty
4268 wlarc='${wl}'
4269
4270 # Set some defaults for GNU ld with shared library support. These
4271 # are reset later if shared libraries are not supported. Putting them
4272 # here allows them to be overridden if necessary.
4273 runpath_var=LD_RUN_PATH
4274 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4275 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
4276 # ancient GNU ld didn't support --whole-archive et. al.
4277 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
4278 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
4279 else
4280 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4281 fi
4282 supports_anon_versioning=no
4283 case `$LD -v 2>&1` in
4284 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
4285 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
4286 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
4287 *\ 2.11.*) ;; # other 2.11 versions
4288 *) supports_anon_versioning=yes ;;
4289 esac
4290
4291 # See if GNU ld supports shared libraries.
4292 case $host_os in
4293 aix[[3-9]]*)
4294 # On AIX/PPC, the GNU linker is very broken
4295 if test "$host_cpu" != ia64; then
4296 _LT_TAGVAR(ld_shlibs, $1)=no
4297 cat <<_LT_EOF 1>&2
4298
4299 *** Warning: the GNU linker, at least up to release 2.9.1, is reported
4300 *** to be unable to reliably create shared libraries on AIX.
4301 *** Therefore, libtool is disabling shared libraries support. If you
4302 *** really care for shared libraries, you may want to modify your PATH
4303 *** so that a non-GNU linker is found, and then restart.
4304
4305 _LT_EOF
4306 fi
4307 ;;
4308
4309 amigaos*)
4310 case $host_cpu in
4311 powerpc)
4312 # see comment about AmigaOS4 .so support
4313 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4314 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4315 ;;
4316 m68k)
4317 _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)'
4318 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4319 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4320 ;;
4321 esac
4322 ;;
4323
4324 beos*)
4325 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4326 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4327 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
4328 # support --undefined. This deserves some investigation. FIXME
4329 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4330 else
4331 _LT_TAGVAR(ld_shlibs, $1)=no
4332 fi
4333 ;;
4334
4335 cygwin* | mingw* | pw32* | cegcc*)
4336 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
4337 # as there is no search path for DLLs.
4338 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4339 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4340 _LT_TAGVAR(always_export_symbols, $1)=no
4341 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4342 _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'
4343
4344 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
4345 _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'
4346 # If the export-symbols file already is a .def file (1st line
4347 # is EXPORTS), use it as is; otherwise, prepend...
4348 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
4349 cp $export_symbols $output_objdir/$soname.def;
4350 else
4351 echo EXPORTS > $output_objdir/$soname.def;
4352 cat $export_symbols >> $output_objdir/$soname.def;
4353 fi~
4354 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
4355 else
4356 _LT_TAGVAR(ld_shlibs, $1)=no
4357 fi
4358 ;;
4359
4360 interix[[3-9]]*)
4361 _LT_TAGVAR(hardcode_direct, $1)=no
4362 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4363 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4364 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4365 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
4366 # Instead, shared libraries are loaded at an image base (0x10000000 by
4367 # default) and relocated if they conflict, which is a slow very memory
4368 # consuming and fragmenting process. To avoid this, we pick a random,
4369 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
4370 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
4371 _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'
4372 _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'
4373 ;;
4374
4375 gnu* | linux* | tpf* | k*bsd*-gnu)
4376 tmp_diet=no
4377 if test "$host_os" = linux-dietlibc; then
4378 case $cc_basename in
4379 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
4380 esac
4381 fi
4382 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
4383 && test "$tmp_diet" = no
4384 then
4385 tmp_addflag=
4386 tmp_sharedflag='-shared'
4387 case $cc_basename,$host_cpu in
4388 pgcc*) # Portland Group C compiler
4389 _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'
4390 tmp_addflag=' $pic_flag'
4391 ;;
4392 pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
4393 _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'
4394 tmp_addflag=' $pic_flag -Mnomain' ;;
4395 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
4396 tmp_addflag=' -i_dynamic' ;;
4397 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
4398 tmp_addflag=' -i_dynamic -nofor_main' ;;
4399 ifc* | ifort*) # Intel Fortran compiler
4400 tmp_addflag=' -nofor_main' ;;
4401 lf95*) # Lahey Fortran 8.1
4402 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4403 tmp_sharedflag='--shared' ;;
4404 xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
4405 tmp_sharedflag='-qmkshrobj'
4406 tmp_addflag= ;;
4407 esac
4408 case `$CC -V 2>&1 | sed 5q` in
4409 *Sun\ C*) # Sun C 5.9
4410 _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'
4411 _LT_TAGVAR(compiler_needs_object, $1)=yes
4412 tmp_sharedflag='-G' ;;
4413 *Sun\ F*) # Sun Fortran 8.3
4414 tmp_sharedflag='-G' ;;
4415 esac
4416 _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4417
4418 if test "x$supports_anon_versioning" = xyes; then
4419 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4420 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4421 echo "local: *; };" >> $output_objdir/$libname.ver~
4422 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
4423 fi
4424
4425 case $cc_basename in
4426 xlf*)
4427 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
4428 _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
4429 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4430 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
4431 _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
4432 if test "x$supports_anon_versioning" = xyes; then
4433 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4434 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4435 echo "local: *; };" >> $output_objdir/$libname.ver~
4436 $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
4437 fi
4438 ;;
4439 esac
4440 else
4441 _LT_TAGVAR(ld_shlibs, $1)=no
4442 fi
4443 ;;
4444
4445 netbsd*)
4446 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4447 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
4448 wlarc=
4449 else
4450 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4451 _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'
4452 fi
4453 ;;
4454
4455 solaris*)
4456 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
4457 _LT_TAGVAR(ld_shlibs, $1)=no
4458 cat <<_LT_EOF 1>&2
4459
4460 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
4461 *** create shared libraries on Solaris systems. Therefore, libtool
4462 *** is disabling shared libraries support. We urge you to upgrade GNU
4463 *** binutils to release 2.9.1 or newer. Another option is to modify
4464 *** your PATH or compiler configuration so that the native linker is
4465 *** used, and then restart.
4466
4467 _LT_EOF
4468 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4469 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4470 _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'
4471 else
4472 _LT_TAGVAR(ld_shlibs, $1)=no
4473 fi
4474 ;;
4475
4476 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
4477 case `$LD -v 2>&1` in
4478 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
4479 _LT_TAGVAR(ld_shlibs, $1)=no
4480 cat <<_LT_EOF 1>&2
4481
4482 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
4483 *** reliably create shared libraries on SCO systems. Therefore, libtool
4484 *** is disabling shared libraries support. We urge you to upgrade GNU
4485 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
4486 *** your PATH or compiler configuration so that the native linker is
4487 *** used, and then restart.
4488
4489 _LT_EOF
4490 ;;
4491 *)
4492 # For security reasons, it is highly recommended that you always
4493 # use absolute paths for naming shared libraries, and exclude the
4494 # DT_RUNPATH tag from executables and libraries. But doing so
4495 # requires that you compile everything twice, which is a pain.
4496 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4497 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4498 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4499 _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'
4500 else
4501 _LT_TAGVAR(ld_shlibs, $1)=no
4502 fi
4503 ;;
4504 esac
4505 ;;
4506
4507 sunos4*)
4508 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4509 wlarc=
4510 _LT_TAGVAR(hardcode_direct, $1)=yes
4511 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4512 ;;
4513
4514 *)
4515 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4516 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4517 _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'
4518 else
4519 _LT_TAGVAR(ld_shlibs, $1)=no
4520 fi
4521 ;;
4522 esac
4523
4524 if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
4525 runpath_var=
4526 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4527 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4528 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4529 fi
4530 else
4531 # PORTME fill in a description of your system's linker (not GNU ld)
4532 case $host_os in
4533 aix3*)
4534 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4535 _LT_TAGVAR(always_export_symbols, $1)=yes
4536 _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'
4537 # Note: this linker hardcodes the directories in LIBPATH if there
4538 # are no directories specified by -L.
4539 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4540 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
4541 # Neither direct hardcoding nor static linking is supported with a
4542 # broken collect2.
4543 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4544 fi
4545 ;;
4546
4547 aix[[4-9]]*)
4548 if test "$host_cpu" = ia64; then
4549 # On IA64, the linker does run time linking by default, so we don't
4550 # have to do anything special.
4551 aix_use_runtimelinking=no
4552 exp_sym_flag='-Bexport'
4553 no_entry_flag=""
4554 else
4555 # If we're using GNU nm, then we don't want the "-C" option.
4556 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4557 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4558 _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'
4559 else
4560 _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'
4561 fi
4562 aix_use_runtimelinking=no
4563
4564 # Test if we are trying to use run time linking or normal
4565 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
4566 # need to do runtime linking.
4567 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
4568 for ld_flag in $LDFLAGS; do
4569 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
4570 aix_use_runtimelinking=yes
4571 break
4572 fi
4573 done
4574 ;;
4575 esac
4576
4577 exp_sym_flag='-bexport'
4578 no_entry_flag='-bnoentry'
4579 fi
4580
4581 # When large executables or shared objects are built, AIX ld can
4582 # have problems creating the table of contents. If linking a library
4583 # or program results in "error TOC overflow" add -mminimal-toc to
4584 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
4585 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
4586
4587 _LT_TAGVAR(archive_cmds, $1)=''
4588 _LT_TAGVAR(hardcode_direct, $1)=yes
4589 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4590 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
4591 _LT_TAGVAR(link_all_deplibs, $1)=yes
4592 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
4593
4594 if test "$GCC" = yes; then
4595 case $host_os in aix4.[[012]]|aix4.[[012]].*)
4596 # We only want to do this on AIX 4.2 and lower, the check
4597 # below for broken collect2 doesn't work under 4.3+
4598 collect2name=`${CC} -print-prog-name=collect2`
4599 if test -f "$collect2name" &&
4600 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
4601 then
4602 # We have reworked collect2
4603 :
4604 else
4605 # We have old collect2
4606 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4607 # It fails to find uninstalled libraries when the uninstalled
4608 # path is not listed in the libpath. Setting hardcode_minus_L
4609 # to unsupported forces relinking
4610 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4611 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4612 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4613 fi
4614 ;;
4615 esac
4616 shared_flag='-shared'
4617 if test "$aix_use_runtimelinking" = yes; then
4618 shared_flag="$shared_flag "'${wl}-G'
4619 fi
4620 else
4621 # not using gcc
4622 if test "$host_cpu" = ia64; then
4623 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
4624 # chokes on -Wl,-G. The following line is correct:
4625 shared_flag='-G'
4626 else
4627 if test "$aix_use_runtimelinking" = yes; then
4628 shared_flag='${wl}-G'
4629 else
4630 shared_flag='${wl}-bM:SRE'
4631 fi
4632 fi
4633 fi
4634
4635 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
4636 # It seems that -bexpall does not export symbols beginning with
4637 # underscore (_), so it is better to generate a list of symbols to export.
4638 _LT_TAGVAR(always_export_symbols, $1)=yes
4639 if test "$aix_use_runtimelinking" = yes; then
4640 # Warning - without using the other runtime loading flags (-brtl),
4641 # -berok will link without error, but may produce a broken library.
4642 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
4643 # Determine the default libpath from the value encoded in an
4644 # empty executable.
4645 _LT_SYS_MODULE_PATH_AIX
4646 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4647 _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"
4648 else
4649 if test "$host_cpu" = ia64; then
4650 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
4651 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
4652 _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"
4653 else
4654 # Determine the default libpath from the value encoded in an
4655 # empty executable.
4656 _LT_SYS_MODULE_PATH_AIX
4657 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4658 # Warning - without using the other run time loading flags,
4659 # -berok will link without error, but may produce a broken library.
4660 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
4661 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
4662 # Exported symbols can be pulled into shared objects from archives
4663 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
4664 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
4665 # This is similar to how AIX traditionally builds its shared libraries.
4666 _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'
4667 fi
4668 fi
4669 ;;
4670
4671 amigaos*)
4672 case $host_cpu in
4673 powerpc)
4674 # see comment about AmigaOS4 .so support
4675 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4676 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4677 ;;
4678 m68k)
4679 _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)'
4680 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4681 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4682 ;;
4683 esac
4684 ;;
4685
4686 bsdi[[45]]*)
4687 _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
4688 ;;
4689
4690 cygwin* | mingw* | pw32* | cegcc*)
4691 # When not using gcc, we currently assume that we are using
4692 # Microsoft Visual C++.
4693 # hardcode_libdir_flag_spec is actually meaningless, as there is
4694 # no search path for DLLs.
4695 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
4696 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4697 # Tell ltmain to make .lib files, not .a files.
4698 libext=lib
4699 # Tell ltmain to make .dll files, not .so files.
4700 shrext_cmds=".dll"
4701 # FIXME: Setting linknames here is a bad hack.
4702 _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
4703 # The linker will automatically build a .lib file if we build a DLL.
4704 _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
4705 # FIXME: Should let the user specify the lib program.
4706 _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
4707 _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
4708 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4709 ;;
4710
4711 darwin* | rhapsody*)
4712 _LT_DARWIN_LINKER_FEATURES($1)
4713 ;;
4714
4715 dgux*)
4716 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4717 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4718 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4719 ;;
4720
4721 freebsd1*)
4722 _LT_TAGVAR(ld_shlibs, $1)=no
4723 ;;
4724
4725 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
4726 # support. Future versions do this automatically, but an explicit c++rt0.o
4727 # does not break anything, and helps significantly (at the cost of a little
4728 # extra space).
4729 freebsd2.2*)
4730 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
4731 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4732 _LT_TAGVAR(hardcode_direct, $1)=yes
4733 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4734 ;;
4735
4736 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
4737 freebsd2*)
4738 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4739 _LT_TAGVAR(hardcode_direct, $1)=yes
4740 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4741 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4742 ;;
4743
4744 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
4745 freebsd* | dragonfly*)
4746 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
4747 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4748 _LT_TAGVAR(hardcode_direct, $1)=yes
4749 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4750 ;;
4751
4752 hpux9*)
4753 if test "$GCC" = yes; then
4754 _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'
4755 else
4756 _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'
4757 fi
4758 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4759 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4760 _LT_TAGVAR(hardcode_direct, $1)=yes
4761
4762 # hardcode_minus_L: Not really in the search PATH,
4763 # but as the default location of the library.
4764 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4765 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4766 ;;
4767
4768 hpux10*)
4769 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4770 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4771 else
4772 _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
4773 fi
4774 if test "$with_gnu_ld" = no; then
4775 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4776 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
4777 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4778 _LT_TAGVAR(hardcode_direct, $1)=yes
4779 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4780 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4781 # hardcode_minus_L: Not really in the search PATH,
4782 # but as the default location of the library.
4783 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4784 fi
4785 ;;
4786
4787 hpux11*)
4788 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4789 case $host_cpu in
4790 hppa*64*)
4791 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4792 ;;
4793 ia64*)
4794 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4795 ;;
4796 *)
4797 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4798 ;;
4799 esac
4800 else
4801 case $host_cpu in
4802 hppa*64*)
4803 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4804 ;;
4805 ia64*)
4806 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4807 ;;
4808 *)
4809 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4810 ;;
4811 esac
4812 fi
4813 if test "$with_gnu_ld" = no; then
4814 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4815 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4816
4817 case $host_cpu in
4818 hppa*64*|ia64*)
4819 _LT_TAGVAR(hardcode_direct, $1)=no
4820 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4821 ;;
4822 *)
4823 _LT_TAGVAR(hardcode_direct, $1)=yes
4824 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4825 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4826
4827 # hardcode_minus_L: Not really in the search PATH,
4828 # but as the default location of the library.
4829 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4830 ;;
4831 esac
4832 fi
4833 ;;
4834
4835 irix5* | irix6* | nonstopux*)
4836 if test "$GCC" = yes; then
4837 _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'
4838 # Try to use the -exported_symbol ld option, if it does not
4839 # work, assume that -exports_file does not work either and
4840 # implicitly export all symbols.
4841 save_LDFLAGS="$LDFLAGS"
4842 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
4843 AC_LINK_IFELSE(int foo(void) {},
4844 _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'
4845 )
4846 LDFLAGS="$save_LDFLAGS"
4847 else
4848 _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'
4849 _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'
4850 fi
4851 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4852 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4853 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4854 _LT_TAGVAR(inherit_rpath, $1)=yes
4855 _LT_TAGVAR(link_all_deplibs, $1)=yes
4856 ;;
4857
4858 netbsd*)
4859 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4860 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
4861 else
4862 _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
4863 fi
4864 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4865 _LT_TAGVAR(hardcode_direct, $1)=yes
4866 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4867 ;;
4868
4869 newsos6)
4870 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4871 _LT_TAGVAR(hardcode_direct, $1)=yes
4872 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4873 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4874 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4875 ;;
4876
4877 *nto* | *qnx*)
4878 ;;
4879
4880 openbsd*)
4881 if test -f /usr/libexec/ld.so; then
4882 _LT_TAGVAR(hardcode_direct, $1)=yes
4883 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4884 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4885 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4886 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4887 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
4888 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4889 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4890 else
4891 case $host_os in
4892 openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
4893 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4894 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4895 ;;
4896 *)
4897 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4898 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4899 ;;
4900 esac
4901 fi
4902 else
4903 _LT_TAGVAR(ld_shlibs, $1)=no
4904 fi
4905 ;;
4906
4907 os2*)
4908 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4909 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4910 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4911 _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'
4912 _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
4913 ;;
4914
4915 osf3*)
4916 if test "$GCC" = yes; then
4917 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4918 _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'
4919 else
4920 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4921 _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'
4922 fi
4923 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4924 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4925 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4926 ;;
4927
4928 osf4* | osf5*) # as osf3* with the addition of -msym flag
4929 if test "$GCC" = yes; then
4930 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4931 _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'
4932 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4933 else
4934 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4935 _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'
4936 _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~
4937 $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'
4938
4939 # Both c and cxx compiler support -rpath directly
4940 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
4941 fi
4942 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4943 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4944 ;;
4945
4946 solaris*)
4947 _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
4948 if test "$GCC" = yes; then
4949 wlarc='${wl}'
4950 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4951 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4952 $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4953 else
4954 case `$CC -V 2>&1` in
4955 *"Compilers 5.0"*)
4956 wlarc=''
4957 _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
4958 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4959 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
4960 ;;
4961 *)
4962 wlarc='${wl}'
4963 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
4964 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4965 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4966 ;;
4967 esac
4968 fi
4969 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4970 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4971 case $host_os in
4972 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
4973 *)
4974 # The compiler driver will combine and reorder linker options,
4975 # but understands `-z linker_flag'. GCC discards it without `$wl',
4976 # but is careful enough not to reorder.
4977 # Supported since Solaris 2.6 (maybe 2.5.1?)
4978 if test "$GCC" = yes; then
4979 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
4980 else
4981 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
4982 fi
4983 ;;
4984 esac
4985 _LT_TAGVAR(link_all_deplibs, $1)=yes
4986 ;;
4987
4988 sunos4*)
4989 if test "x$host_vendor" = xsequent; then
4990 # Use $CC to link under sequent, because it throws in some extra .o
4991 # files that make .init and .fini sections work.
4992 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
4993 else
4994 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
4995 fi
4996 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4997 _LT_TAGVAR(hardcode_direct, $1)=yes
4998 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4999 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5000 ;;
5001
5002 sysv4)
5003 case $host_vendor in
5004 sni)
5005 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5006 _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
5007 ;;
5008 siemens)
5009 ## LD is ld it makes a PLAMLIB
5010 ## CC just makes a GrossModule.
5011 _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
5012 _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
5013 _LT_TAGVAR(hardcode_direct, $1)=no
5014 ;;
5015 motorola)
5016 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5017 _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
5018 ;;
5019 esac
5020 runpath_var='LD_RUN_PATH'
5021 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5022 ;;
5023
5024 sysv4.3*)
5025 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5026 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5027 _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
5028 ;;
5029
5030 sysv4*MP*)
5031 if test -d /usr/nec; then
5032 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5033 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5034 runpath_var=LD_RUN_PATH
5035 hardcode_runpath_var=yes
5036 _LT_TAGVAR(ld_shlibs, $1)=yes
5037 fi
5038 ;;
5039
5040 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
5041 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5042 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5043 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5044 runpath_var='LD_RUN_PATH'
5045
5046 if test "$GCC" = yes; then
5047 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5048 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5049 else
5050 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5051 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5052 fi
5053 ;;
5054
5055 sysv5* | sco3.2v5* | sco5v6*)
5056 # Note: We can NOT use -z defs as we might desire, because we do not
5057 # link with -lc, and that would cause any symbols used from libc to
5058 # always be unresolved, which means just about no library would
5059 # ever link correctly. If we're not using GNU ld we use -z text
5060 # though, which does catch some bad symbols but isn't as heavy-handed
5061 # as -z defs.
5062 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5063 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
5064 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5065 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5066 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
5067 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5068 _LT_TAGVAR(link_all_deplibs, $1)=yes
5069 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
5070 runpath_var='LD_RUN_PATH'
5071
5072 if test "$GCC" = yes; then
5073 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5074 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5075 else
5076 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5077 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5078 fi
5079 ;;
5080
5081 uts4*)
5082 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5083 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5084 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5085 ;;
5086
5087 *)
5088 _LT_TAGVAR(ld_shlibs, $1)=no
5089 ;;
5090 esac
5091
5092 if test x$host_vendor = xsni; then
5093 case $host in
5094 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
5095 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
5096 ;;
5097 esac
5098 fi
5099 fi
5100 ])
5101 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
5102 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
5103
5104 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
5105
5106 _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
5107 _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
5108 _LT_DECL([], [extract_expsyms_cmds], [2],
5109 [The commands to extract the exported symbol list from a shared archive])
5110
5111 #
5112 # Do we need to explicitly link libc?
5113 #
5114 case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
5115 x|xyes)
5116 # Assume -lc should be added
5117 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5118
5119 if test "$enable_shared" = yes && test "$GCC" = yes; then
5120 case $_LT_TAGVAR(archive_cmds, $1) in
5121 *'~'*)
5122 # FIXME: we may have to deal with multi-command sequences.
5123 ;;
5124 '$CC '*)
5125 # Test whether the compiler implicitly links with -lc since on some
5126 # systems, -lgcc has to come before -lc. If gcc already passes -lc
5127 # to ld, don't add -lc before -lgcc.
5128 AC_MSG_CHECKING([whether -lc should be explicitly linked in])
5129 $RM conftest*
5130 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
5131
5132 if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
5133 soname=conftest
5134 lib=conftest
5135 libobjs=conftest.$ac_objext
5136 deplibs=
5137 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
5138 pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
5139 compiler_flags=-v
5140 linker_flags=-v
5141 verstring=
5142 output_objdir=.
5143 libname=conftest
5144 lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
5145 _LT_TAGVAR(allow_undefined_flag, $1)=
5146 if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
5147 then
5148 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5149 else
5150 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5151 fi
5152 _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
5153 else
5154 cat conftest.err 1>&5
5155 fi
5156 $RM conftest*
5157 AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
5158 ;;
5159 esac
5160 fi
5161 ;;
5162 esac
5163
5164 _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
5165 [Whether or not to add -lc for building shared libraries])
5166 _LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
5167 [enable_shared_with_static_runtimes], [0],
5168 [Whether or not to disallow shared libs when runtime libs are static])
5169 _LT_TAGDECL([], [export_dynamic_flag_spec], [1],
5170 [Compiler flag to allow reflexive dlopens])
5171 _LT_TAGDECL([], [whole_archive_flag_spec], [1],
5172 [Compiler flag to generate shared objects directly from archives])
5173 _LT_TAGDECL([], [compiler_needs_object], [1],
5174 [Whether the compiler copes with passing no objects directly])
5175 _LT_TAGDECL([], [old_archive_from_new_cmds], [2],
5176 [Create an old-style archive from a shared archive])
5177 _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
5178 [Create a temporary old-style archive to link instead of a shared archive])
5179 _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
5180 _LT_TAGDECL([], [archive_expsym_cmds], [2])
5181 _LT_TAGDECL([], [module_cmds], [2],
5182 [Commands used to build a loadable module if different from building
5183 a shared archive.])
5184 _LT_TAGDECL([], [module_expsym_cmds], [2])
5185 _LT_TAGDECL([], [with_gnu_ld], [1],
5186 [Whether we are building with GNU ld or not])
5187 _LT_TAGDECL([], [allow_undefined_flag], [1],
5188 [Flag that allows shared libraries with undefined symbols to be built])
5189 _LT_TAGDECL([], [no_undefined_flag], [1],
5190 [Flag that enforces no undefined symbols])
5191 _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
5192 [Flag to hardcode $libdir into a binary during linking.
5193 This must work even if $libdir does not exist])
5194 _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
5195 [[If ld is used when linking, flag to hardcode $libdir into a binary
5196 during linking. This must work even if $libdir does not exist]])
5197 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
5198 [Whether we need a single "-rpath" flag with a separated argument])
5199 _LT_TAGDECL([], [hardcode_direct], [0],
5200 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5201 DIR into the resulting binary])
5202 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
5203 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5204 DIR into the resulting binary and the resulting library dependency is
5205 "absolute", i.e impossible to change by setting ${shlibpath_var} if the
5206 library is relocated])
5207 _LT_TAGDECL([], [hardcode_minus_L], [0],
5208 [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
5209 into the resulting binary])
5210 _LT_TAGDECL([], [hardcode_shlibpath_var], [0],
5211 [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
5212 into the resulting binary])
5213 _LT_TAGDECL([], [hardcode_automatic], [0],
5214 [Set to "yes" if building a shared library automatically hardcodes DIR
5215 into the library and all subsequent libraries and executables linked
5216 against it])
5217 _LT_TAGDECL([], [inherit_rpath], [0],
5218 [Set to yes if linker adds runtime paths of dependent libraries
5219 to runtime path list])
5220 _LT_TAGDECL([], [link_all_deplibs], [0],
5221 [Whether libtool must link a program against all its dependency libraries])
5222 _LT_TAGDECL([], [fix_srcfile_path], [1],
5223 [Fix the shell variable $srcfile for the compiler])
5224 _LT_TAGDECL([], [always_export_symbols], [0],
5225 [Set to "yes" if exported symbols are required])
5226 _LT_TAGDECL([], [export_symbols_cmds], [2],
5227 [The commands to list exported symbols])
5228 _LT_TAGDECL([], [exclude_expsyms], [1],
5229 [Symbols that should not be listed in the preloaded symbols])
5230 _LT_TAGDECL([], [include_expsyms], [1],
5231 [Symbols that must always be exported])
5232 _LT_TAGDECL([], [prelink_cmds], [2],
5233 [Commands necessary for linking programs (against libraries) with templates])
5234 _LT_TAGDECL([], [file_list_spec], [1],
5235 [Specify filename containing input files])
5236 dnl FIXME: Not yet implemented
5237 dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
5238 dnl [Compiler flag to generate thread safe objects])
5239 ])# _LT_LINKER_SHLIBS
5240
5241
5242 # _LT_LANG_C_CONFIG([TAG])
5243 # ------------------------
5244 # Ensure that the configuration variables for a C compiler are suitably
5245 # defined. These variables are subsequently used by _LT_CONFIG to write
5246 # the compiler configuration to `libtool'.
5247 m4_defun([_LT_LANG_C_CONFIG],
5248 [m4_require([_LT_DECL_EGREP])dnl
5249 lt_save_CC="$CC"
5250 AC_LANG_PUSH(C)
5251
5252 # Source file extension for C test sources.
5253 ac_ext=c
5254
5255 # Object file extension for compiled C test sources.
5256 objext=o
5257 _LT_TAGVAR(objext, $1)=$objext
5258
5259 # Code to be used in simple compile tests
5260 lt_simple_compile_test_code="int some_variable = 0;"
5261
5262 # Code to be used in simple link tests
5263 lt_simple_link_test_code='int main(){return(0);}'
5264
5265 _LT_TAG_COMPILER
5266 # Save the default compiler, since it gets overwritten when the other
5267 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
5268 compiler_DEFAULT=$CC
5269
5270 # save warnings/boilerplate of simple test code
5271 _LT_COMPILER_BOILERPLATE
5272 _LT_LINKER_BOILERPLATE
5273
5274 ## CAVEAT EMPTOR:
5275 ## There is no encapsulation within the following macros, do not change
5276 ## the running order or otherwise move them around unless you know exactly
5277 ## what you are doing...
5278 if test -n "$compiler"; then
5279 _LT_COMPILER_NO_RTTI($1)
5280 _LT_COMPILER_PIC($1)
5281 _LT_COMPILER_C_O($1)
5282 _LT_COMPILER_FILE_LOCKS($1)
5283 _LT_LINKER_SHLIBS($1)
5284 _LT_SYS_DYNAMIC_LINKER($1)
5285 _LT_LINKER_HARDCODE_LIBPATH($1)
5286 LT_SYS_DLOPEN_SELF
5287 _LT_CMD_STRIPLIB
5288
5289 # Report which library types will actually be built
5290 AC_MSG_CHECKING([if libtool supports shared libraries])
5291 AC_MSG_RESULT([$can_build_shared])
5292
5293 AC_MSG_CHECKING([whether to build shared libraries])
5294 test "$can_build_shared" = "no" && enable_shared=no
5295
5296 # On AIX, shared libraries and static libraries use the same namespace, and
5297 # are all built from PIC.
5298 case $host_os in
5299 aix3*)
5300 test "$enable_shared" = yes && enable_static=no
5301 if test -n "$RANLIB"; then
5302 archive_cmds="$archive_cmds~\$RANLIB \$lib"
5303 postinstall_cmds='$RANLIB $lib'
5304 fi
5305 ;;
5306
5307 aix[[4-9]]*)
5308 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
5309 test "$enable_shared" = yes && enable_static=no
5310 fi
5311 ;;
5312 esac
5313 AC_MSG_RESULT([$enable_shared])
5314
5315 AC_MSG_CHECKING([whether to build static libraries])
5316 # Make sure either enable_shared or enable_static is yes.
5317 test "$enable_shared" = yes || enable_static=yes
5318 AC_MSG_RESULT([$enable_static])
5319
5320 _LT_CONFIG($1)
5321 fi
5322 AC_LANG_POP
5323 CC="$lt_save_CC"
5324 ])# _LT_LANG_C_CONFIG
5325
5326
5327 # _LT_PROG_CXX
5328 # ------------
5329 # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
5330 # compiler, we have our own version here.
5331 m4_defun([_LT_PROG_CXX],
5332 [
5333 pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
5334 AC_PROG_CXX
5335 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
5336 ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
5337 (test "X$CXX" != "Xg++"))) ; then
5338 AC_PROG_CXXCPP
5339 else
5340 _lt_caught_CXX_error=yes
5341 fi
5342 popdef([AC_MSG_ERROR])
5343 ])# _LT_PROG_CXX
5344
5345 dnl aclocal-1.4 backwards compatibility:
5346 dnl AC_DEFUN([_LT_PROG_CXX], [])
5347
5348
5349 # _LT_LANG_CXX_CONFIG([TAG])
5350 # --------------------------
5351 # Ensure that the configuration variables for a C++ compiler are suitably
5352 # defined. These variables are subsequently used by _LT_CONFIG to write
5353 # the compiler configuration to `libtool'.
5354 m4_defun([_LT_LANG_CXX_CONFIG],
5355 [AC_REQUIRE([_LT_PROG_CXX])dnl
5356 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
5357 m4_require([_LT_DECL_EGREP])dnl
5358
5359 AC_LANG_PUSH(C++)
5360 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5361 _LT_TAGVAR(allow_undefined_flag, $1)=
5362 _LT_TAGVAR(always_export_symbols, $1)=no
5363 _LT_TAGVAR(archive_expsym_cmds, $1)=
5364 _LT_TAGVAR(compiler_needs_object, $1)=no
5365 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
5366 _LT_TAGVAR(hardcode_direct, $1)=no
5367 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
5368 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
5369 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
5370 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5371 _LT_TAGVAR(hardcode_minus_L, $1)=no
5372 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
5373 _LT_TAGVAR(hardcode_automatic, $1)=no
5374 _LT_TAGVAR(inherit_rpath, $1)=no
5375 _LT_TAGVAR(module_cmds, $1)=
5376 _LT_TAGVAR(module_expsym_cmds, $1)=
5377 _LT_TAGVAR(link_all_deplibs, $1)=unknown
5378 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
5379 _LT_TAGVAR(no_undefined_flag, $1)=
5380 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5381 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
5382
5383 # Source file extension for C++ test sources.
5384 ac_ext=cpp
5385
5386 # Object file extension for compiled C++ test sources.
5387 objext=o
5388 _LT_TAGVAR(objext, $1)=$objext
5389
5390 # No sense in running all these tests if we already determined that
5391 # the CXX compiler isn't working. Some variables (like enable_shared)
5392 # are currently assumed to apply to all compilers on this platform,
5393 # and will be corrupted by setting them based on a non-working compiler.
5394 if test "$_lt_caught_CXX_error" != yes; then
5395 # Code to be used in simple compile tests
5396 lt_simple_compile_test_code="int some_variable = 0;"
5397
5398 # Code to be used in simple link tests
5399 lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
5400
5401 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
5402 _LT_TAG_COMPILER
5403
5404 # save warnings/boilerplate of simple test code
5405 _LT_COMPILER_BOILERPLATE
5406 _LT_LINKER_BOILERPLATE
5407
5408 # Allow CC to be a program name with arguments.
5409 lt_save_CC=$CC
5410 lt_save_LD=$LD
5411 lt_save_GCC=$GCC
5412 GCC=$GXX
5413 lt_save_with_gnu_ld=$with_gnu_ld
5414 lt_save_path_LD=$lt_cv_path_LD
5415 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
5416 lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
5417 else
5418 $as_unset lt_cv_prog_gnu_ld
5419 fi
5420 if test -n "${lt_cv_path_LDCXX+set}"; then
5421 lt_cv_path_LD=$lt_cv_path_LDCXX
5422 else
5423 $as_unset lt_cv_path_LD
5424 fi
5425 test -z "${LDCXX+set}" || LD=$LDCXX
5426 CC=${CXX-"c++"}
5427 compiler=$CC
5428 _LT_TAGVAR(compiler, $1)=$CC
5429 _LT_CC_BASENAME([$compiler])
5430
5431 if test -n "$compiler"; then
5432 # We don't want -fno-exception when compiling C++ code, so set the
5433 # no_builtin_flag separately
5434 if test "$GXX" = yes; then
5435 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
5436 else
5437 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
5438 fi
5439
5440 if test "$GXX" = yes; then
5441 # Set up default GNU C++ configuration
5442
5443 LT_PATH_LD
5444
5445 # Check if GNU C++ uses GNU ld as the underlying linker, since the
5446 # archiving commands below assume that GNU ld is being used.
5447 if test "$with_gnu_ld" = yes; then
5448 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5449 _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'
5450
5451 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5452 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5453
5454 # If archive_cmds runs LD, not CC, wlarc should be empty
5455 # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
5456 # investigate it a little bit more. (MM)
5457 wlarc='${wl}'
5458
5459 # ancient GNU ld didn't support --whole-archive et. al.
5460 if eval "`$CC -print-prog-name=ld` --help 2>&1" |
5461 $GREP 'no-whole-archive' > /dev/null; then
5462 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
5463 else
5464 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5465 fi
5466 else
5467 with_gnu_ld=no
5468 wlarc=
5469
5470 # A generic and very simple default shared library creation
5471 # command for GNU C++ for the case where it uses the native
5472 # linker, instead of GNU ld. If possible, this setting should
5473 # overridden to take advantage of the native linker features on
5474 # the platform it is being used on.
5475 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
5476 fi
5477
5478 # Commands to make compiler produce verbose output that lists
5479 # what "hidden" libraries, object files and flags are used when
5480 # linking a shared library.
5481 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
5482
5483 else
5484 GXX=no
5485 with_gnu_ld=no
5486 wlarc=
5487 fi
5488
5489 # PORTME: fill in a description of your system's C++ link characteristics
5490 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
5491 _LT_TAGVAR(ld_shlibs, $1)=yes
5492 case $host_os in
5493 aix3*)
5494 # FIXME: insert proper C++ library support
5495 _LT_TAGVAR(ld_shlibs, $1)=no
5496 ;;
5497 aix[[4-9]]*)
5498 if test "$host_cpu" = ia64; then
5499 # On IA64, the linker does run time linking by default, so we don't
5500 # have to do anything special.
5501 aix_use_runtimelinking=no
5502 exp_sym_flag='-Bexport'
5503 no_entry_flag=""
5504 else
5505 aix_use_runtimelinking=no
5506
5507 # Test if we are trying to use run time linking or normal
5508 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
5509 # need to do runtime linking.
5510 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
5511 for ld_flag in $LDFLAGS; do
5512 case $ld_flag in
5513 *-brtl*)
5514 aix_use_runtimelinking=yes
5515 break
5516 ;;
5517 esac
5518 done
5519 ;;
5520 esac
5521
5522 exp_sym_flag='-bexport'
5523 no_entry_flag='-bnoentry'
5524 fi
5525
5526 # When large executables or shared objects are built, AIX ld can
5527 # have problems creating the table of contents. If linking a library
5528 # or program results in "error TOC overflow" add -mminimal-toc to
5529 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
5530 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
5531
5532 _LT_TAGVAR(archive_cmds, $1)=''
5533 _LT_TAGVAR(hardcode_direct, $1)=yes
5534 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5535 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5536 _LT_TAGVAR(link_all_deplibs, $1)=yes
5537 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
5538
5539 if test "$GXX" = yes; then
5540 case $host_os in aix4.[[012]]|aix4.[[012]].*)
5541 # We only want to do this on AIX 4.2 and lower, the check
5542 # below for broken collect2 doesn't work under 4.3+
5543 collect2name=`${CC} -print-prog-name=collect2`
5544 if test -f "$collect2name" &&
5545 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
5546 then
5547 # We have reworked collect2
5548 :
5549 else
5550 # We have old collect2
5551 _LT_TAGVAR(hardcode_direct, $1)=unsupported
5552 # It fails to find uninstalled libraries when the uninstalled
5553 # path is not listed in the libpath. Setting hardcode_minus_L
5554 # to unsupported forces relinking
5555 _LT_TAGVAR(hardcode_minus_L, $1)=yes
5556 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5557 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5558 fi
5559 esac
5560 shared_flag='-shared'
5561 if test "$aix_use_runtimelinking" = yes; then
5562 shared_flag="$shared_flag "'${wl}-G'
5563 fi
5564 else
5565 # not using gcc
5566 if test "$host_cpu" = ia64; then
5567 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
5568 # chokes on -Wl,-G. The following line is correct:
5569 shared_flag='-G'
5570 else
5571 if test "$aix_use_runtimelinking" = yes; then
5572 shared_flag='${wl}-G'
5573 else
5574 shared_flag='${wl}-bM:SRE'
5575 fi
5576 fi
5577 fi
5578
5579 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
5580 # It seems that -bexpall does not export symbols beginning with
5581 # underscore (_), so it is better to generate a list of symbols to
5582 # export.
5583 _LT_TAGVAR(always_export_symbols, $1)=yes
5584 if test "$aix_use_runtimelinking" = yes; then
5585 # Warning - without using the other runtime loading flags (-brtl),
5586 # -berok will link without error, but may produce a broken library.
5587 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
5588 # Determine the default libpath from the value encoded in an empty
5589 # executable.
5590 _LT_SYS_MODULE_PATH_AIX
5591 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5592
5593 _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"
5594 else
5595 if test "$host_cpu" = ia64; then
5596 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
5597 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
5598 _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"
5599 else
5600 # Determine the default libpath from the value encoded in an
5601 # empty executable.
5602 _LT_SYS_MODULE_PATH_AIX
5603 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5604 # Warning - without using the other run time loading flags,
5605 # -berok will link without error, but may produce a broken library.
5606 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
5607 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
5608 # Exported symbols can be pulled into shared objects from archives
5609 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
5610 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5611 # This is similar to how AIX traditionally builds its shared
5612 # libraries.
5613 _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'
5614 fi
5615 fi
5616 ;;
5617
5618 beos*)
5619 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
5620 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5621 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
5622 # support --undefined. This deserves some investigation. FIXME
5623 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5624 else
5625 _LT_TAGVAR(ld_shlibs, $1)=no
5626 fi
5627 ;;
5628
5629 chorus*)
5630 case $cc_basename in
5631 *)
5632 # FIXME: insert proper C++ library support
5633 _LT_TAGVAR(ld_shlibs, $1)=no
5634 ;;
5635 esac
5636 ;;
5637
5638 cygwin* | mingw* | pw32* | cegcc*)
5639 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
5640 # as there is no search path for DLLs.
5641 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5642 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5643 _LT_TAGVAR(always_export_symbols, $1)=no
5644 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
5645
5646 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
5647 _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'
5648 # If the export-symbols file already is a .def file (1st line
5649 # is EXPORTS), use it as is; otherwise, prepend...
5650 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
5651 cp $export_symbols $output_objdir/$soname.def;
5652 else
5653 echo EXPORTS > $output_objdir/$soname.def;
5654 cat $export_symbols >> $output_objdir/$soname.def;
5655 fi~
5656 $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'
5657 else
5658 _LT_TAGVAR(ld_shlibs, $1)=no
5659 fi
5660 ;;
5661 darwin* | rhapsody*)
5662 _LT_DARWIN_LINKER_FEATURES($1)
5663 ;;
5664
5665 dgux*)
5666 case $cc_basename in
5667 ec++*)
5668 # FIXME: insert proper C++ library support
5669 _LT_TAGVAR(ld_shlibs, $1)=no
5670 ;;
5671 ghcx*)
5672 # Green Hills C++ Compiler
5673 # FIXME: insert proper C++ library support
5674 _LT_TAGVAR(ld_shlibs, $1)=no
5675 ;;
5676 *)
5677 # FIXME: insert proper C++ library support
5678 _LT_TAGVAR(ld_shlibs, $1)=no
5679 ;;
5680 esac
5681 ;;
5682
5683 freebsd[[12]]*)
5684 # C++ shared libraries reported to be fairly broken before
5685 # switch to ELF
5686 _LT_TAGVAR(ld_shlibs, $1)=no
5687 ;;
5688
5689 freebsd-elf*)
5690 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5691 ;;
5692
5693 freebsd* | dragonfly*)
5694 # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
5695 # conventions
5696 _LT_TAGVAR(ld_shlibs, $1)=yes
5697 ;;
5698
5699 gnu*)
5700 ;;
5701
5702 hpux9*)
5703 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5704 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5705 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5706 _LT_TAGVAR(hardcode_direct, $1)=yes
5707 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5708 # but as the default
5709 # location of the library.
5710
5711 case $cc_basename in
5712 CC*)
5713 # FIXME: insert proper C++ library support
5714 _LT_TAGVAR(ld_shlibs, $1)=no
5715 ;;
5716 aCC*)
5717 _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'
5718 # Commands to make compiler produce verbose output that lists
5719 # what "hidden" libraries, object files and flags are used when
5720 # linking a shared library.
5721 #
5722 # There doesn't appear to be a way to prevent this compiler from
5723 # explicitly linking system object files so we need to strip them
5724 # from the output so that they don't get included in the library
5725 # dependencies.
5726 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'
5727 ;;
5728 *)
5729 if test "$GXX" = yes; then
5730 _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'
5731 else
5732 # FIXME: insert proper C++ library support
5733 _LT_TAGVAR(ld_shlibs, $1)=no
5734 fi
5735 ;;
5736 esac
5737 ;;
5738
5739 hpux10*|hpux11*)
5740 if test $with_gnu_ld = no; then
5741 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5742 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5743
5744 case $host_cpu in
5745 hppa*64*|ia64*)
5746 ;;
5747 *)
5748 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5749 ;;
5750 esac
5751 fi
5752 case $host_cpu in
5753 hppa*64*|ia64*)
5754 _LT_TAGVAR(hardcode_direct, $1)=no
5755 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5756 ;;
5757 *)
5758 _LT_TAGVAR(hardcode_direct, $1)=yes
5759 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5760 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5761 # but as the default
5762 # location of the library.
5763 ;;
5764 esac
5765
5766 case $cc_basename in
5767 CC*)
5768 # FIXME: insert proper C++ library support
5769 _LT_TAGVAR(ld_shlibs, $1)=no
5770 ;;
5771 aCC*)
5772 case $host_cpu in
5773 hppa*64*)
5774 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5775 ;;
5776 ia64*)
5777 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5778 ;;
5779 *)
5780 _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'
5781 ;;
5782 esac
5783 # Commands to make compiler produce verbose output that lists
5784 # what "hidden" libraries, object files and flags are used when
5785 # linking a shared library.
5786 #
5787 # There doesn't appear to be a way to prevent this compiler from
5788 # explicitly linking system object files so we need to strip them
5789 # from the output so that they don't get included in the library
5790 # dependencies.
5791 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'
5792 ;;
5793 *)
5794 if test "$GXX" = yes; then
5795 if test $with_gnu_ld = no; then
5796 case $host_cpu in
5797 hppa*64*)
5798 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5799 ;;
5800 ia64*)
5801 _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'
5802 ;;
5803 *)
5804 _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'
5805 ;;
5806 esac
5807 fi
5808 else
5809 # FIXME: insert proper C++ library support
5810 _LT_TAGVAR(ld_shlibs, $1)=no
5811 fi
5812 ;;
5813 esac
5814 ;;
5815
5816 interix[[3-9]]*)
5817 _LT_TAGVAR(hardcode_direct, $1)=no
5818 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5819 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5820 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5821 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
5822 # Instead, shared libraries are loaded at an image base (0x10000000 by
5823 # default) and relocated if they conflict, which is a slow very memory
5824 # consuming and fragmenting process. To avoid this, we pick a random,
5825 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
5826 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
5827 _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'
5828 _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'
5829 ;;
5830 irix5* | irix6*)
5831 case $cc_basename in
5832 CC*)
5833 # SGI C++
5834 _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'
5835
5836 # Archives containing C++ object files must be created using
5837 # "CC -ar", where "CC" is the IRIX C++ compiler. This is
5838 # necessary to make sure instantiated templates are included
5839 # in the archive.
5840 _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
5841 ;;
5842 *)
5843 if test "$GXX" = yes; then
5844 if test "$with_gnu_ld" = no; then
5845 _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'
5846 else
5847 _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'
5848 fi
5849 fi
5850 _LT_TAGVAR(link_all_deplibs, $1)=yes
5851 ;;
5852 esac
5853 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5854 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5855 _LT_TAGVAR(inherit_rpath, $1)=yes
5856 ;;
5857
5858 linux* | k*bsd*-gnu)
5859 case $cc_basename in
5860 KCC*)
5861 # Kuck and Associates, Inc. (KAI) C++ Compiler
5862
5863 # KCC will only create a shared library if the output file
5864 # ends with ".so" (or ".sl" for HP-UX), so rename the library
5865 # to its proper name (with version) after linking.
5866 _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'
5867 _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'
5868 # Commands to make compiler produce verbose output that lists
5869 # what "hidden" libraries, object files and flags are used when
5870 # linking a shared library.
5871 #
5872 # There doesn't appear to be a way to prevent this compiler from
5873 # explicitly linking system object files so we need to strip them
5874 # from the output so that they don't get included in the library
5875 # dependencies.
5876 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'
5877
5878 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5879 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5880
5881 # Archives containing C++ object files must be created using
5882 # "CC -Bstatic", where "CC" is the KAI C++ compiler.
5883 _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
5884 ;;
5885 icpc* | ecpc* )
5886 # Intel C++
5887 with_gnu_ld=yes
5888 # version 8.0 and above of icpc choke on multiply defined symbols
5889 # if we add $predep_objects and $postdep_objects, however 7.1 and
5890 # earlier do not add the objects themselves.
5891 case `$CC -V 2>&1` in
5892 *"Version 7."*)
5893 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5894 _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'
5895 ;;
5896 *) # Version 8.0 or newer
5897 tmp_idyn=
5898 case $host_cpu in
5899 ia64*) tmp_idyn=' -i_dynamic';;
5900 esac
5901 _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5902 _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'
5903 ;;
5904 esac
5905 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5906 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5907 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5908 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
5909 ;;
5910 pgCC* | pgcpp*)
5911 # Portland Group C++ compiler
5912 case `$CC -V` in
5913 *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
5914 _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
5915 rm -rf $tpldir~
5916 $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
5917 compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
5918 _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
5919 rm -rf $tpldir~
5920 $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
5921 $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
5922 $RANLIB $oldlib'
5923 _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
5924 rm -rf $tpldir~
5925 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5926 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5927 _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
5928 rm -rf $tpldir~
5929 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5930 $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'
5931 ;;
5932 *) # Version 6 will use weak symbols
5933 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5934 _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'
5935 ;;
5936 esac
5937
5938 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
5939 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5940 _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'
5941 ;;
5942 cxx*)
5943 # Compaq C++
5944 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5945 _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'
5946
5947 runpath_var=LD_RUN_PATH
5948 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
5949 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5950
5951 # Commands to make compiler produce verbose output that lists
5952 # what "hidden" libraries, object files and flags are used when
5953 # linking a shared library.
5954 #
5955 # There doesn't appear to be a way to prevent this compiler from
5956 # explicitly linking system object files so we need to strip them
5957 # from the output so that they don't get included in the library
5958 # dependencies.
5959 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'
5960 ;;
5961 xl*)
5962 # IBM XL 8.0 on PPC, with GNU ld
5963 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5964 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5965 _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5966 if test "x$supports_anon_versioning" = xyes; then
5967 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
5968 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
5969 echo "local: *; };" >> $output_objdir/$libname.ver~
5970 $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
5971 fi
5972 ;;
5973 *)
5974 case `$CC -V 2>&1 | sed 5q` in
5975 *Sun\ C*)
5976 # Sun C++ 5.9
5977 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
5978 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5979 _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'
5980 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
5981 _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'
5982 _LT_TAGVAR(compiler_needs_object, $1)=yes
5983
5984 # Not sure whether something based on
5985 # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
5986 # would be better.
5987 output_verbose_link_cmd='echo'
5988
5989 # Archives containing C++ object files must be created using
5990 # "CC -xar", where "CC" is the Sun C++ compiler. This is
5991 # necessary to make sure instantiated templates are included
5992 # in the archive.
5993 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
5994 ;;
5995 esac
5996 ;;
5997 esac
5998 ;;
5999
6000 lynxos*)
6001 # FIXME: insert proper C++ library support
6002 _LT_TAGVAR(ld_shlibs, $1)=no
6003 ;;
6004
6005 m88k*)
6006 # FIXME: insert proper C++ library support
6007 _LT_TAGVAR(ld_shlibs, $1)=no
6008 ;;
6009
6010 mvs*)
6011 case $cc_basename in
6012 cxx*)
6013 # FIXME: insert proper C++ library support
6014 _LT_TAGVAR(ld_shlibs, $1)=no
6015 ;;
6016 *)
6017 # FIXME: insert proper C++ library support
6018 _LT_TAGVAR(ld_shlibs, $1)=no
6019 ;;
6020 esac
6021 ;;
6022
6023 netbsd*)
6024 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
6025 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
6026 wlarc=
6027 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
6028 _LT_TAGVAR(hardcode_direct, $1)=yes
6029 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6030 fi
6031 # Workaround some broken pre-1.5 toolchains
6032 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
6033 ;;
6034
6035 *nto* | *qnx*)
6036 _LT_TAGVAR(ld_shlibs, $1)=yes
6037 ;;
6038
6039 openbsd2*)
6040 # C++ shared libraries are fairly broken
6041 _LT_TAGVAR(ld_shlibs, $1)=no
6042 ;;
6043
6044 openbsd*)
6045 if test -f /usr/libexec/ld.so; then
6046 _LT_TAGVAR(hardcode_direct, $1)=yes
6047 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6048 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
6049 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
6050 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6051 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
6052 _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'
6053 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
6054 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
6055 fi
6056 output_verbose_link_cmd=echo
6057 else
6058 _LT_TAGVAR(ld_shlibs, $1)=no
6059 fi
6060 ;;
6061
6062 osf3* | osf4* | osf5*)
6063 case $cc_basename in
6064 KCC*)
6065 # Kuck and Associates, Inc. (KAI) C++ Compiler
6066
6067 # KCC will only create a shared library if the output file
6068 # ends with ".so" (or ".sl" for HP-UX), so rename the library
6069 # to its proper name (with version) after linking.
6070 _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'
6071
6072 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6073 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6074
6075 # Archives containing C++ object files must be created using
6076 # the KAI C++ compiler.
6077 case $host in
6078 osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
6079 *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
6080 esac
6081 ;;
6082 RCC*)
6083 # Rational C++ 2.4.1
6084 # FIXME: insert proper C++ library support
6085 _LT_TAGVAR(ld_shlibs, $1)=no
6086 ;;
6087 cxx*)
6088 case $host in
6089 osf3*)
6090 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6091 _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'
6092 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6093 ;;
6094 *)
6095 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
6096 _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'
6097 _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
6098 echo "-hidden">> $lib.exp~
6099 $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~
6100 $RM $lib.exp'
6101 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
6102 ;;
6103 esac
6104
6105 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6106
6107 # Commands to make compiler produce verbose output that lists
6108 # what "hidden" libraries, object files and flags are used when
6109 # linking a shared library.
6110 #
6111 # There doesn't appear to be a way to prevent this compiler from
6112 # explicitly linking system object files so we need to strip them
6113 # from the output so that they don't get included in the library
6114 # dependencies.
6115 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'
6116 ;;
6117 *)
6118 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6119 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6120 case $host in
6121 osf3*)
6122 _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'
6123 ;;
6124 *)
6125 _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'
6126 ;;
6127 esac
6128
6129 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6130 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6131
6132 # Commands to make compiler produce verbose output that lists
6133 # what "hidden" libraries, object files and flags are used when
6134 # linking a shared library.
6135 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6136
6137 else
6138 # FIXME: insert proper C++ library support
6139 _LT_TAGVAR(ld_shlibs, $1)=no
6140 fi
6141 ;;
6142 esac
6143 ;;
6144
6145 psos*)
6146 # FIXME: insert proper C++ library support
6147 _LT_TAGVAR(ld_shlibs, $1)=no
6148 ;;
6149
6150 sunos4*)
6151 case $cc_basename in
6152 CC*)
6153 # Sun C++ 4.x
6154 # FIXME: insert proper C++ library support
6155 _LT_TAGVAR(ld_shlibs, $1)=no
6156 ;;
6157 lcc*)
6158 # Lucid
6159 # FIXME: insert proper C++ library support
6160 _LT_TAGVAR(ld_shlibs, $1)=no
6161 ;;
6162 *)
6163 # FIXME: insert proper C++ library support
6164 _LT_TAGVAR(ld_shlibs, $1)=no
6165 ;;
6166 esac
6167 ;;
6168
6169 solaris*)
6170 case $cc_basename in
6171 CC*)
6172 # Sun C++ 4.2, 5.x and Centerline C++
6173 _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
6174 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
6175 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
6176 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6177 $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'
6178
6179 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
6180 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6181 case $host_os in
6182 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6183 *)
6184 # The compiler driver will combine and reorder linker options,
6185 # but understands `-z linker_flag'.
6186 # Supported since Solaris 2.6 (maybe 2.5.1?)
6187 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
6188 ;;
6189 esac
6190 _LT_TAGVAR(link_all_deplibs, $1)=yes
6191
6192 output_verbose_link_cmd='echo'
6193
6194 # Archives containing C++ object files must be created using
6195 # "CC -xar", where "CC" is the Sun C++ compiler. This is
6196 # necessary to make sure instantiated templates are included
6197 # in the archive.
6198 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
6199 ;;
6200 gcx*)
6201 # Green Hills C++ Compiler
6202 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6203
6204 # The C++ compiler must be used to create the archive.
6205 _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
6206 ;;
6207 *)
6208 # GNU C++ compiler with Solaris linker
6209 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6210 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
6211 if $CC --version | $GREP -v '^2\.7' > /dev/null; then
6212 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6213 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6214 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6215
6216 # Commands to make compiler produce verbose output that lists
6217 # what "hidden" libraries, object files and flags are used when
6218 # linking a shared library.
6219 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6220 else
6221 # g++ 2.7 appears to require `-G' NOT `-shared' on this
6222 # platform.
6223 _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6224 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6225 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6226
6227 # Commands to make compiler produce verbose output that lists
6228 # what "hidden" libraries, object files and flags are used when
6229 # linking a shared library.
6230 output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6231 fi
6232
6233 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
6234 case $host_os in
6235 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6236 *)
6237 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
6238 ;;
6239 esac
6240 fi
6241 ;;
6242 esac
6243 ;;
6244
6245 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
6246 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6247 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6248 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6249 runpath_var='LD_RUN_PATH'
6250
6251 case $cc_basename in
6252 CC*)
6253 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6254 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6255 ;;
6256 *)
6257 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6258 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6259 ;;
6260 esac
6261 ;;
6262
6263 sysv5* | sco3.2v5* | sco5v6*)
6264 # Note: We can NOT use -z defs as we might desire, because we do not
6265 # link with -lc, and that would cause any symbols used from libc to
6266 # always be unresolved, which means just about no library would
6267 # ever link correctly. If we're not using GNU ld we use -z text
6268 # though, which does catch some bad symbols but isn't as heavy-handed
6269 # as -z defs.
6270 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6271 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
6272 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6273 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6274 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
6275 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
6276 _LT_TAGVAR(link_all_deplibs, $1)=yes
6277 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
6278 runpath_var='LD_RUN_PATH'
6279
6280 case $cc_basename in
6281 CC*)
6282 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6283 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6284 ;;
6285 *)
6286 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6287 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6288 ;;
6289 esac
6290 ;;
6291
6292 tandem*)
6293 case $cc_basename in
6294 NCC*)
6295 # NonStop-UX NCC 3.20
6296 # FIXME: insert proper C++ library support
6297 _LT_TAGVAR(ld_shlibs, $1)=no
6298 ;;
6299 *)
6300 # FIXME: insert proper C++ library support
6301 _LT_TAGVAR(ld_shlibs, $1)=no
6302 ;;
6303 esac
6304 ;;
6305
6306 vxworks*)
6307 # FIXME: insert proper C++ library support
6308 _LT_TAGVAR(ld_shlibs, $1)=no
6309 ;;
6310
6311 *)
6312 # FIXME: insert proper C++ library support
6313 _LT_TAGVAR(ld_shlibs, $1)=no
6314 ;;
6315 esac
6316
6317 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
6318 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
6319
6320 _LT_TAGVAR(GCC, $1)="$GXX"
6321 _LT_TAGVAR(LD, $1)="$LD"
6322
6323 ## CAVEAT EMPTOR:
6324 ## There is no encapsulation within the following macros, do not change
6325 ## the running order or otherwise move them around unless you know exactly
6326 ## what you are doing...
6327 _LT_SYS_HIDDEN_LIBDEPS($1)
6328 _LT_COMPILER_PIC($1)
6329 _LT_COMPILER_C_O($1)
6330 _LT_COMPILER_FILE_LOCKS($1)
6331 _LT_LINKER_SHLIBS($1)
6332 _LT_SYS_DYNAMIC_LINKER($1)
6333 _LT_LINKER_HARDCODE_LIBPATH($1)
6334
6335 _LT_CONFIG($1)
6336 fi # test -n "$compiler"
6337
6338 CC=$lt_save_CC
6339 LDCXX=$LD
6340 LD=$lt_save_LD
6341 GCC=$lt_save_GCC
6342 with_gnu_ld=$lt_save_with_gnu_ld
6343 lt_cv_path_LDCXX=$lt_cv_path_LD
6344 lt_cv_path_LD=$lt_save_path_LD
6345 lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
6346 lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
6347 fi # test "$_lt_caught_CXX_error" != yes
6348
6349 AC_LANG_POP
6350 ])# _LT_LANG_CXX_CONFIG
6351
6352
6353 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
6354 # ---------------------------------
6355 # Figure out "hidden" library dependencies from verbose
6356 # compiler output when linking a shared library.
6357 # Parse the compiler output and extract the necessary
6358 # objects, libraries and library flags.
6359 m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
6360 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
6361 # Dependencies to place before and after the object being linked:
6362 _LT_TAGVAR(predep_objects, $1)=
6363 _LT_TAGVAR(postdep_objects, $1)=
6364 _LT_TAGVAR(predeps, $1)=
6365 _LT_TAGVAR(postdeps, $1)=
6366 _LT_TAGVAR(compiler_lib_search_path, $1)=
6367
6368 dnl we can't use the lt_simple_compile_test_code here,
6369 dnl because it contains code intended for an executable,
6370 dnl not a library. It's possible we should let each
6371 dnl tag define a new lt_????_link_test_code variable,
6372 dnl but it's only used here...
6373 m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
6374 int a;
6375 void foo (void) { a = 0; }
6376 _LT_EOF
6377 ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
6378 class Foo
6379 {
6380 public:
6381 Foo (void) { a = 0; }
6382 private:
6383 int a;
6384 };
6385 _LT_EOF
6386 ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
6387 subroutine foo
6388 implicit none
6389 integer*4 a
6390 a=0
6391 return
6392 end
6393 _LT_EOF
6394 ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
6395 subroutine foo
6396 implicit none
6397 integer a
6398 a=0
6399 return
6400 end
6401 _LT_EOF
6402 ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
6403 public class foo {
6404 private int a;
6405 public void bar (void) {
6406 a = 0;
6407 }
6408 };
6409 _LT_EOF
6410 ])
6411 dnl Parse the compiler output and extract the necessary
6412 dnl objects, libraries and library flags.
6413 if AC_TRY_EVAL(ac_compile); then
6414 # Parse the compiler output and extract the necessary
6415 # objects, libraries and library flags.
6416
6417 # Sentinel used to keep track of whether or not we are before
6418 # the conftest object file.
6419 pre_test_object_deps_done=no
6420
6421 for p in `eval "$output_verbose_link_cmd"`; do
6422 case $p in
6423
6424 -L* | -R* | -l*)
6425 # Some compilers place space between "-{L,R}" and the path.
6426 # Remove the space.
6427 if test $p = "-L" ||
6428 test $p = "-R"; then
6429 prev=$p
6430 continue
6431 else
6432 prev=
6433 fi
6434
6435 if test "$pre_test_object_deps_done" = no; then
6436 case $p in
6437 -L* | -R*)
6438 # Internal compiler library paths should come after those
6439 # provided the user. The postdeps already come after the
6440 # user supplied libs so there is no need to process them.
6441 if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
6442 _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
6443 else
6444 _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
6445 fi
6446 ;;
6447 # The "-l" case would never come before the object being
6448 # linked, so don't bother handling this case.
6449 esac
6450 else
6451 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
6452 _LT_TAGVAR(postdeps, $1)="${prev}${p}"
6453 else
6454 _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
6455 fi
6456 fi
6457 ;;
6458
6459 *.$objext)
6460 # This assumes that the test object file only shows up
6461 # once in the compiler output.
6462 if test "$p" = "conftest.$objext"; then
6463 pre_test_object_deps_done=yes
6464 continue
6465 fi
6466
6467 if test "$pre_test_object_deps_done" = no; then
6468 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
6469 _LT_TAGVAR(predep_objects, $1)="$p"
6470 else
6471 _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
6472 fi
6473 else
6474 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
6475 _LT_TAGVAR(postdep_objects, $1)="$p"
6476 else
6477 _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
6478 fi
6479 fi
6480 ;;
6481
6482 *) ;; # Ignore the rest.
6483
6484 esac
6485 done
6486
6487 # Clean up.
6488 rm -f a.out a.exe
6489 else
6490 echo "libtool.m4: error: problem compiling $1 test program"
6491 fi
6492
6493 $RM -f confest.$objext
6494
6495 # PORTME: override above test on systems where it is broken
6496 m4_if([$1], [CXX],
6497 [case $host_os in
6498 interix[[3-9]]*)
6499 # Interix 3.5 installs completely hosed .la files for C++, so rather than
6500 # hack all around it, let's just trust "g++" to DTRT.
6501 _LT_TAGVAR(predep_objects,$1)=
6502 _LT_TAGVAR(postdep_objects,$1)=
6503 _LT_TAGVAR(postdeps,$1)=
6504 ;;
6505
6506 linux*)
6507 case `$CC -V 2>&1 | sed 5q` in
6508 *Sun\ C*)
6509 # Sun C++ 5.9
6510
6511 # The more standards-conforming stlport4 library is
6512 # incompatible with the Cstd library. Avoid specifying
6513 # it if it's in CXXFLAGS. Ignore libCrun as
6514 # -library=stlport4 depends on it.
6515 case " $CXX $CXXFLAGS " in
6516 *" -library=stlport4 "*)
6517 solaris_use_stlport4=yes
6518 ;;
6519 esac
6520
6521 if test "$solaris_use_stlport4" != yes; then
6522 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6523 fi
6524 ;;
6525 esac
6526 ;;
6527
6528 solaris*)
6529 case $cc_basename in
6530 CC*)
6531 # The more standards-conforming stlport4 library is
6532 # incompatible with the Cstd library. Avoid specifying
6533 # it if it's in CXXFLAGS. Ignore libCrun as
6534 # -library=stlport4 depends on it.
6535 case " $CXX $CXXFLAGS " in
6536 *" -library=stlport4 "*)
6537 solaris_use_stlport4=yes
6538 ;;
6539 esac
6540
6541 # Adding this requires a known-good setup of shared libraries for
6542 # Sun compiler versions before 5.6, else PIC objects from an old
6543 # archive will be linked into the output, leading to subtle bugs.
6544 if test "$solaris_use_stlport4" != yes; then
6545 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6546 fi
6547 ;;
6548 esac
6549 ;;
6550 esac
6551 ])
6552
6553 case " $_LT_TAGVAR(postdeps, $1) " in
6554 *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
6555 esac
6556 _LT_TAGVAR(compiler_lib_search_dirs, $1)=
6557 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
6558 _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
6559 fi
6560 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
6561 [The directories searched by this compiler when creating a shared library])
6562 _LT_TAGDECL([], [predep_objects], [1],
6563 [Dependencies to place before and after the objects being linked to
6564 create a shared library])
6565 _LT_TAGDECL([], [postdep_objects], [1])
6566 _LT_TAGDECL([], [predeps], [1])
6567 _LT_TAGDECL([], [postdeps], [1])
6568 _LT_TAGDECL([], [compiler_lib_search_path], [1],
6569 [The library search path used internally by the compiler when linking
6570 a shared library])
6571 ])# _LT_SYS_HIDDEN_LIBDEPS
6572
6573
6574 # _LT_PROG_F77
6575 # ------------
6576 # Since AC_PROG_F77 is broken, in that it returns the empty string
6577 # if there is no fortran compiler, we have our own version here.
6578 m4_defun([_LT_PROG_F77],
6579 [
6580 pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
6581 AC_PROG_F77
6582 if test -z "$F77" || test "X$F77" = "Xno"; then
6583 _lt_disable_F77=yes
6584 fi
6585 popdef([AC_MSG_ERROR])
6586 ])# _LT_PROG_F77
6587
6588 dnl aclocal-1.4 backwards compatibility:
6589 dnl AC_DEFUN([_LT_PROG_F77], [])
6590
6591
6592 # _LT_LANG_F77_CONFIG([TAG])
6593 # --------------------------
6594 # Ensure that the configuration variables for a Fortran 77 compiler are
6595 # suitably defined. These variables are subsequently used by _LT_CONFIG
6596 # to write the compiler configuration to `libtool'.
6597 m4_defun([_LT_LANG_F77_CONFIG],
6598 [AC_REQUIRE([_LT_PROG_F77])dnl
6599 AC_LANG_PUSH(Fortran 77)
6600
6601 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6602 _LT_TAGVAR(allow_undefined_flag, $1)=
6603 _LT_TAGVAR(always_export_symbols, $1)=no
6604 _LT_TAGVAR(archive_expsym_cmds, $1)=
6605 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6606 _LT_TAGVAR(hardcode_direct, $1)=no
6607 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6608 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6609 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6610 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6611 _LT_TAGVAR(hardcode_minus_L, $1)=no
6612 _LT_TAGVAR(hardcode_automatic, $1)=no
6613 _LT_TAGVAR(inherit_rpath, $1)=no
6614 _LT_TAGVAR(module_cmds, $1)=
6615 _LT_TAGVAR(module_expsym_cmds, $1)=
6616 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6617 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6618 _LT_TAGVAR(no_undefined_flag, $1)=
6619 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6620 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6621
6622 # Source file extension for f77 test sources.
6623 ac_ext=f
6624
6625 # Object file extension for compiled f77 test sources.
6626 objext=o
6627 _LT_TAGVAR(objext, $1)=$objext
6628
6629 # No sense in running all these tests if we already determined that
6630 # the F77 compiler isn't working. Some variables (like enable_shared)
6631 # are currently assumed to apply to all compilers on this platform,
6632 # and will be corrupted by setting them based on a non-working compiler.
6633 if test "$_lt_disable_F77" != yes; then
6634 # Code to be used in simple compile tests
6635 lt_simple_compile_test_code="\
6636 subroutine t
6637 return
6638 end
6639 "
6640
6641 # Code to be used in simple link tests
6642 lt_simple_link_test_code="\
6643 program t
6644 end
6645 "
6646
6647 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6648 _LT_TAG_COMPILER
6649
6650 # save warnings/boilerplate of simple test code
6651 _LT_COMPILER_BOILERPLATE
6652 _LT_LINKER_BOILERPLATE
6653
6654 # Allow CC to be a program name with arguments.
6655 lt_save_CC="$CC"
6656 lt_save_GCC=$GCC
6657 CC=${F77-"f77"}
6658 compiler=$CC
6659 _LT_TAGVAR(compiler, $1)=$CC
6660 _LT_CC_BASENAME([$compiler])
6661 GCC=$G77
6662 if test -n "$compiler"; then
6663 AC_MSG_CHECKING([if libtool supports shared libraries])
6664 AC_MSG_RESULT([$can_build_shared])
6665
6666 AC_MSG_CHECKING([whether to build shared libraries])
6667 test "$can_build_shared" = "no" && enable_shared=no
6668
6669 # On AIX, shared libraries and static libraries use the same namespace, and
6670 # are all built from PIC.
6671 case $host_os in
6672 aix3*)
6673 test "$enable_shared" = yes && enable_static=no
6674 if test -n "$RANLIB"; then
6675 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6676 postinstall_cmds='$RANLIB $lib'
6677 fi
6678 ;;
6679 aix[[4-9]]*)
6680 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6681 test "$enable_shared" = yes && enable_static=no
6682 fi
6683 ;;
6684 esac
6685 AC_MSG_RESULT([$enable_shared])
6686
6687 AC_MSG_CHECKING([whether to build static libraries])
6688 # Make sure either enable_shared or enable_static is yes.
6689 test "$enable_shared" = yes || enable_static=yes
6690 AC_MSG_RESULT([$enable_static])
6691
6692 _LT_TAGVAR(GCC, $1)="$G77"
6693 _LT_TAGVAR(LD, $1)="$LD"
6694
6695 ## CAVEAT EMPTOR:
6696 ## There is no encapsulation within the following macros, do not change
6697 ## the running order or otherwise move them around unless you know exactly
6698 ## what you are doing...
6699 _LT_COMPILER_PIC($1)
6700 _LT_COMPILER_C_O($1)
6701 _LT_COMPILER_FILE_LOCKS($1)
6702 _LT_LINKER_SHLIBS($1)
6703 _LT_SYS_DYNAMIC_LINKER($1)
6704 _LT_LINKER_HARDCODE_LIBPATH($1)
6705
6706 _LT_CONFIG($1)
6707 fi # test -n "$compiler"
6708
6709 GCC=$lt_save_GCC
6710 CC="$lt_save_CC"
6711 fi # test "$_lt_disable_F77" != yes
6712
6713 AC_LANG_POP
6714 ])# _LT_LANG_F77_CONFIG
6715
6716
6717 # _LT_PROG_FC
6718 # -----------
6719 # Since AC_PROG_FC is broken, in that it returns the empty string
6720 # if there is no fortran compiler, we have our own version here.
6721 m4_defun([_LT_PROG_FC],
6722 [
6723 pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
6724 AC_PROG_FC
6725 if test -z "$FC" || test "X$FC" = "Xno"; then
6726 _lt_disable_FC=yes
6727 fi
6728 popdef([AC_MSG_ERROR])
6729 ])# _LT_PROG_FC
6730
6731 dnl aclocal-1.4 backwards compatibility:
6732 dnl AC_DEFUN([_LT_PROG_FC], [])
6733
6734
6735 # _LT_LANG_FC_CONFIG([TAG])
6736 # -------------------------
6737 # Ensure that the configuration variables for a Fortran compiler are
6738 # suitably defined. These variables are subsequently used by _LT_CONFIG
6739 # to write the compiler configuration to `libtool'.
6740 m4_defun([_LT_LANG_FC_CONFIG],
6741 [AC_REQUIRE([_LT_PROG_FC])dnl
6742 AC_LANG_PUSH(Fortran)
6743
6744 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6745 _LT_TAGVAR(allow_undefined_flag, $1)=
6746 _LT_TAGVAR(always_export_symbols, $1)=no
6747 _LT_TAGVAR(archive_expsym_cmds, $1)=
6748 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6749 _LT_TAGVAR(hardcode_direct, $1)=no
6750 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6751 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6752 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6753 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6754 _LT_TAGVAR(hardcode_minus_L, $1)=no
6755 _LT_TAGVAR(hardcode_automatic, $1)=no
6756 _LT_TAGVAR(inherit_rpath, $1)=no
6757 _LT_TAGVAR(module_cmds, $1)=
6758 _LT_TAGVAR(module_expsym_cmds, $1)=
6759 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6760 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6761 _LT_TAGVAR(no_undefined_flag, $1)=
6762 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6763 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6764
6765 # Source file extension for fc test sources.
6766 ac_ext=${ac_fc_srcext-f}
6767
6768 # Object file extension for compiled fc test sources.
6769 objext=o
6770 _LT_TAGVAR(objext, $1)=$objext
6771
6772 # No sense in running all these tests if we already determined that
6773 # the FC compiler isn't working. Some variables (like enable_shared)
6774 # are currently assumed to apply to all compilers on this platform,
6775 # and will be corrupted by setting them based on a non-working compiler.
6776 if test "$_lt_disable_FC" != yes; then
6777 # Code to be used in simple compile tests
6778 lt_simple_compile_test_code="\
6779 subroutine t
6780 return
6781 end
6782 "
6783
6784 # Code to be used in simple link tests
6785 lt_simple_link_test_code="\
6786 program t
6787 end
6788 "
6789
6790 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6791 _LT_TAG_COMPILER
6792
6793 # save warnings/boilerplate of simple test code
6794 _LT_COMPILER_BOILERPLATE
6795 _LT_LINKER_BOILERPLATE
6796
6797 # Allow CC to be a program name with arguments.
6798 lt_save_CC="$CC"
6799 lt_save_GCC=$GCC
6800 CC=${FC-"f95"}
6801 compiler=$CC
6802 GCC=$ac_cv_fc_compiler_gnu
6803
6804 _LT_TAGVAR(compiler, $1)=$CC
6805 _LT_CC_BASENAME([$compiler])
6806
6807 if test -n "$compiler"; then
6808 AC_MSG_CHECKING([if libtool supports shared libraries])
6809 AC_MSG_RESULT([$can_build_shared])
6810
6811 AC_MSG_CHECKING([whether to build shared libraries])
6812 test "$can_build_shared" = "no" && enable_shared=no
6813
6814 # On AIX, shared libraries and static libraries use the same namespace, and
6815 # are all built from PIC.
6816 case $host_os in
6817 aix3*)
6818 test "$enable_shared" = yes && enable_static=no
6819 if test -n "$RANLIB"; then
6820 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6821 postinstall_cmds='$RANLIB $lib'
6822 fi
6823 ;;
6824 aix[[4-9]]*)
6825 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6826 test "$enable_shared" = yes && enable_static=no
6827 fi
6828 ;;
6829 esac
6830 AC_MSG_RESULT([$enable_shared])
6831
6832 AC_MSG_CHECKING([whether to build static libraries])
6833 # Make sure either enable_shared or enable_static is yes.
6834 test "$enable_shared" = yes || enable_static=yes
6835 AC_MSG_RESULT([$enable_static])
6836
6837 _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
6838 _LT_TAGVAR(LD, $1)="$LD"
6839
6840 ## CAVEAT EMPTOR:
6841 ## There is no encapsulation within the following macros, do not change
6842 ## the running order or otherwise move them around unless you know exactly
6843 ## what you are doing...
6844 _LT_SYS_HIDDEN_LIBDEPS($1)
6845 _LT_COMPILER_PIC($1)
6846 _LT_COMPILER_C_O($1)
6847 _LT_COMPILER_FILE_LOCKS($1)
6848 _LT_LINKER_SHLIBS($1)
6849 _LT_SYS_DYNAMIC_LINKER($1)
6850 _LT_LINKER_HARDCODE_LIBPATH($1)
6851
6852 _LT_CONFIG($1)
6853 fi # test -n "$compiler"
6854
6855 GCC=$lt_save_GCC
6856 CC="$lt_save_CC"
6857 fi # test "$_lt_disable_FC" != yes
6858
6859 AC_LANG_POP
6860 ])# _LT_LANG_FC_CONFIG
6861
6862
6863 # _LT_LANG_GCJ_CONFIG([TAG])
6864 # --------------------------
6865 # Ensure that the configuration variables for the GNU Java Compiler compiler
6866 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6867 # to write the compiler configuration to `libtool'.
6868 m4_defun([_LT_LANG_GCJ_CONFIG],
6869 [AC_REQUIRE([LT_PROG_GCJ])dnl
6870 AC_LANG_SAVE
6871
6872 # Source file extension for Java test sources.
6873 ac_ext=java
6874
6875 # Object file extension for compiled Java test sources.
6876 objext=o
6877 _LT_TAGVAR(objext, $1)=$objext
6878
6879 # Code to be used in simple compile tests
6880 lt_simple_compile_test_code="class foo {}"
6881
6882 # Code to be used in simple link tests
6883 lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
6884
6885 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6886 _LT_TAG_COMPILER
6887
6888 # save warnings/boilerplate of simple test code
6889 _LT_COMPILER_BOILERPLATE
6890 _LT_LINKER_BOILERPLATE
6891
6892 # Allow CC to be a program name with arguments.
6893 lt_save_CC="$CC"
6894 lt_save_GCC=$GCC
6895 GCC=yes
6896 CC=${GCJ-"gcj"}
6897 compiler=$CC
6898 _LT_TAGVAR(compiler, $1)=$CC
6899 _LT_TAGVAR(LD, $1)="$LD"
6900 _LT_CC_BASENAME([$compiler])
6901
6902 # GCJ did not exist at the time GCC didn't implicitly link libc in.
6903 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6904
6905 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6906
6907 ## CAVEAT EMPTOR:
6908 ## There is no encapsulation within the following macros, do not change
6909 ## the running order or otherwise move them around unless you know exactly
6910 ## what you are doing...
6911 if test -n "$compiler"; then
6912 _LT_COMPILER_NO_RTTI($1)
6913 _LT_COMPILER_PIC($1)
6914 _LT_COMPILER_C_O($1)
6915 _LT_COMPILER_FILE_LOCKS($1)
6916 _LT_LINKER_SHLIBS($1)
6917 _LT_LINKER_HARDCODE_LIBPATH($1)
6918
6919 _LT_CONFIG($1)
6920 fi
6921
6922 AC_LANG_RESTORE
6923
6924 GCC=$lt_save_GCC
6925 CC="$lt_save_CC"
6926 ])# _LT_LANG_GCJ_CONFIG
6927
6928
6929 # _LT_LANG_RC_CONFIG([TAG])
6930 # -------------------------
6931 # Ensure that the configuration variables for the Windows resource compiler
6932 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6933 # to write the compiler configuration to `libtool'.
6934 m4_defun([_LT_LANG_RC_CONFIG],
6935 [AC_REQUIRE([LT_PROG_RC])dnl
6936 AC_LANG_SAVE
6937
6938 # Source file extension for RC test sources.
6939 ac_ext=rc
6940
6941 # Object file extension for compiled RC test sources.
6942 objext=o
6943 _LT_TAGVAR(objext, $1)=$objext
6944
6945 # Code to be used in simple compile tests
6946 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
6947
6948 # Code to be used in simple link tests
6949 lt_simple_link_test_code="$lt_simple_compile_test_code"
6950
6951 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6952 _LT_TAG_COMPILER
6953
6954 # save warnings/boilerplate of simple test code
6955 _LT_COMPILER_BOILERPLATE
6956 _LT_LINKER_BOILERPLATE
6957
6958 # Allow CC to be a program name with arguments.
6959 lt_save_CC="$CC"
6960 lt_save_GCC=$GCC
6961 GCC=
6962 CC=${RC-"windres"}
6963 compiler=$CC
6964 _LT_TAGVAR(compiler, $1)=$CC
6965 _LT_CC_BASENAME([$compiler])
6966 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
6967
6968 if test -n "$compiler"; then
6969 :
6970 _LT_CONFIG($1)
6971 fi
6972
6973 GCC=$lt_save_GCC
6974 AC_LANG_RESTORE
6975 CC="$lt_save_CC"
6976 ])# _LT_LANG_RC_CONFIG
6977
6978
6979 # LT_PROG_GCJ
6980 # -----------
6981 AC_DEFUN([LT_PROG_GCJ],
6982 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
6983 [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
6984 [AC_CHECK_TOOL(GCJ, gcj,)
6985 test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
6986 AC_SUBST(GCJFLAGS)])])[]dnl
6987 ])
6988
6989 # Old name:
6990 AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
6991 dnl aclocal-1.4 backwards compatibility:
6992 dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
6993
6994
6995 # LT_PROG_RC
6996 # ----------
6997 AC_DEFUN([LT_PROG_RC],
6998 [AC_CHECK_TOOL(RC, windres,)
6999 ])
7000
7001 # Old name:
7002 AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
7003 dnl aclocal-1.4 backwards compatibility:
7004 dnl AC_DEFUN([LT_AC_PROG_RC], [])
7005
7006
7007 # _LT_DECL_EGREP
7008 # --------------
7009 # If we don't have a new enough Autoconf to choose the best grep
7010 # available, choose the one first in the user's PATH.
7011 m4_defun([_LT_DECL_EGREP],
7012 [AC_REQUIRE([AC_PROG_EGREP])dnl
7013 AC_REQUIRE([AC_PROG_FGREP])dnl
7014 test -z "$GREP" && GREP=grep
7015 _LT_DECL([], [GREP], [1], [A grep program that handles long lines])
7016 _LT_DECL([], [EGREP], [1], [An ERE matcher])
7017 _LT_DECL([], [FGREP], [1], [A literal string matcher])
7018 dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
7019 AC_SUBST([GREP])
7020 ])
7021
7022
7023 # _LT_DECL_OBJDUMP
7024 # --------------
7025 # If we don't have a new enough Autoconf to choose the best objdump
7026 # available, choose the one first in the user's PATH.
7027 m4_defun([_LT_DECL_OBJDUMP],
7028 [AC_CHECK_TOOL(OBJDUMP, objdump, false)
7029 test -z "$OBJDUMP" && OBJDUMP=objdump
7030 _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
7031 AC_SUBST([OBJDUMP])
7032 ])
7033
7034
7035 # _LT_DECL_SED
7036 # ------------
7037 # Check for a fully-functional sed program, that truncates
7038 # as few characters as possible. Prefer GNU sed if found.
7039 m4_defun([_LT_DECL_SED],
7040 [AC_PROG_SED
7041 test -z "$SED" && SED=sed
7042 Xsed="$SED -e 1s/^X//"
7043 _LT_DECL([], [SED], [1], [A sed program that does not truncate output])
7044 _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
7045 [Sed that helps us avoid accidentally triggering echo(1) options like -n])
7046 ])# _LT_DECL_SED
7047
7048 m4_ifndef([AC_PROG_SED], [
7049 ############################################################
7050 # NOTE: This macro has been submitted for inclusion into #
7051 # GNU Autoconf as AC_PROG_SED. When it is available in #
7052 # a released version of Autoconf we should remove this #
7053 # macro and use it instead. #
7054 ############################################################
7055
7056 m4_defun([AC_PROG_SED],
7057 [AC_MSG_CHECKING([for a sed that does not truncate output])
7058 AC_CACHE_VAL(lt_cv_path_SED,
7059 [# Loop through the user's path and test for sed and gsed.
7060 # Then use that list of sed's as ones to test for truncation.
7061 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7062 for as_dir in $PATH
7063 do
7064 IFS=$as_save_IFS
7065 test -z "$as_dir" && as_dir=.
7066 for lt_ac_prog in sed gsed; do
7067 for ac_exec_ext in '' $ac_executable_extensions; do
7068 if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
7069 lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
7070 fi
7071 done
7072 done
7073 done
7074 IFS=$as_save_IFS
7075 lt_ac_max=0
7076 lt_ac_count=0
7077 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
7078 # along with /bin/sed that truncates output.
7079 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
7080 test ! -f $lt_ac_sed && continue
7081 cat /dev/null > conftest.in
7082 lt_ac_count=0
7083 echo $ECHO_N "0123456789$ECHO_C" >conftest.in
7084 # Check for GNU sed and select it if it is found.
7085 if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
7086 lt_cv_path_SED=$lt_ac_sed
7087 break
7088 fi
7089 while true; do
7090 cat conftest.in conftest.in >conftest.tmp
7091 mv conftest.tmp conftest.in
7092 cp conftest.in conftest.nl
7093 echo >>conftest.nl
7094 $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
7095 cmp -s conftest.out conftest.nl || break
7096 # 10000 chars as input seems more than enough
7097 test $lt_ac_count -gt 10 && break
7098 lt_ac_count=`expr $lt_ac_count + 1`
7099 if test $lt_ac_count -gt $lt_ac_max; then
7100 lt_ac_max=$lt_ac_count
7101 lt_cv_path_SED=$lt_ac_sed
7102 fi
7103 done
7104 done
7105 ])
7106 SED=$lt_cv_path_SED
7107 AC_SUBST([SED])
7108 AC_MSG_RESULT([$SED])
7109 ])#AC_PROG_SED
7110 ])#m4_ifndef
7111
7112 # Old name:
7113 AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
7114 dnl aclocal-1.4 backwards compatibility:
7115 dnl AC_DEFUN([LT_AC_PROG_SED], [])
7116
7117
7118 # _LT_CHECK_SHELL_FEATURES
7119 # ------------------------
7120 # Find out whether the shell is Bourne or XSI compatible,
7121 # or has some other useful features.
7122 m4_defun([_LT_CHECK_SHELL_FEATURES],
7123 [AC_MSG_CHECKING([whether the shell understands some XSI constructs])
7124 # Try some XSI features
7125 xsi_shell=no
7126 ( _lt_dummy="a/b/c"
7127 test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
7128 = c,a/b,, \
7129 && eval 'test $(( 1 + 1 )) -eq 2 \
7130 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
7131 && xsi_shell=yes
7132 AC_MSG_RESULT([$xsi_shell])
7133 _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
7134
7135 AC_MSG_CHECKING([whether the shell understands "+="])
7136 lt_shell_append=no
7137 ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
7138 >/dev/null 2>&1 \
7139 && lt_shell_append=yes
7140 AC_MSG_RESULT([$lt_shell_append])
7141 _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
7142
7143 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
7144 lt_unset=unset
7145 else
7146 lt_unset=false
7147 fi
7148 _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
7149
7150 # test EBCDIC or ASCII
7151 case `echo X|tr X '\101'` in
7152 A) # ASCII based system
7153 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
7154 lt_SP2NL='tr \040 \012'
7155 lt_NL2SP='tr \015\012 \040\040'
7156 ;;
7157 *) # EBCDIC based system
7158 lt_SP2NL='tr \100 \n'
7159 lt_NL2SP='tr \r\n \100\100'
7160 ;;
7161 esac
7162 _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
7163 _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
7164 ])# _LT_CHECK_SHELL_FEATURES
7165
7166
7167 # _LT_PROG_XSI_SHELLFNS
7168 # ---------------------
7169 # Bourne and XSI compatible variants of some useful shell functions.
7170 m4_defun([_LT_PROG_XSI_SHELLFNS],
7171 [case $xsi_shell in
7172 yes)
7173 cat << \_LT_EOF >> "$cfgfile"
7174
7175 # func_dirname file append nondir_replacement
7176 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7177 # otherwise set result to NONDIR_REPLACEMENT.
7178 func_dirname ()
7179 {
7180 case ${1} in
7181 */*) func_dirname_result="${1%/*}${2}" ;;
7182 * ) func_dirname_result="${3}" ;;
7183 esac
7184 }
7185
7186 # func_basename file
7187 func_basename ()
7188 {
7189 func_basename_result="${1##*/}"
7190 }
7191
7192 # func_dirname_and_basename file append nondir_replacement
7193 # perform func_basename and func_dirname in a single function
7194 # call:
7195 # dirname: Compute the dirname of FILE. If nonempty,
7196 # add APPEND to the result, otherwise set result
7197 # to NONDIR_REPLACEMENT.
7198 # value returned in "$func_dirname_result"
7199 # basename: Compute filename of FILE.
7200 # value retuned in "$func_basename_result"
7201 # Implementation must be kept synchronized with func_dirname
7202 # and func_basename. For efficiency, we do not delegate to
7203 # those functions but instead duplicate the functionality here.
7204 func_dirname_and_basename ()
7205 {
7206 case ${1} in
7207 */*) func_dirname_result="${1%/*}${2}" ;;
7208 * ) func_dirname_result="${3}" ;;
7209 esac
7210 func_basename_result="${1##*/}"
7211 }
7212
7213 # func_stripname prefix suffix name
7214 # strip PREFIX and SUFFIX off of NAME.
7215 # PREFIX and SUFFIX must not contain globbing or regex special
7216 # characters, hashes, percent signs, but SUFFIX may contain a leading
7217 # dot (in which case that matches only a dot).
7218 func_stripname ()
7219 {
7220 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
7221 # positional parameters, so assign one to ordinary parameter first.
7222 func_stripname_result=${3}
7223 func_stripname_result=${func_stripname_result#"${1}"}
7224 func_stripname_result=${func_stripname_result%"${2}"}
7225 }
7226
7227 # func_opt_split
7228 func_opt_split ()
7229 {
7230 func_opt_split_opt=${1%%=*}
7231 func_opt_split_arg=${1#*=}
7232 }
7233
7234 # func_lo2o object
7235 func_lo2o ()
7236 {
7237 case ${1} in
7238 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
7239 *) func_lo2o_result=${1} ;;
7240 esac
7241 }
7242
7243 # func_xform libobj-or-source
7244 func_xform ()
7245 {
7246 func_xform_result=${1%.*}.lo
7247 }
7248
7249 # func_arith arithmetic-term...
7250 func_arith ()
7251 {
7252 func_arith_result=$(( $[*] ))
7253 }
7254
7255 # func_len string
7256 # STRING may not start with a hyphen.
7257 func_len ()
7258 {
7259 func_len_result=${#1}
7260 }
7261
7262 _LT_EOF
7263 ;;
7264 *) # Bourne compatible functions.
7265 cat << \_LT_EOF >> "$cfgfile"
7266
7267 # func_dirname file append nondir_replacement
7268 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7269 # otherwise set result to NONDIR_REPLACEMENT.
7270 func_dirname ()
7271 {
7272 # Extract subdirectory from the argument.
7273 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
7274 if test "X$func_dirname_result" = "X${1}"; then
7275 func_dirname_result="${3}"
7276 else
7277 func_dirname_result="$func_dirname_result${2}"
7278 fi
7279 }
7280
7281 # func_basename file
7282 func_basename ()
7283 {
7284 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
7285 }
7286
7287 dnl func_dirname_and_basename
7288 dnl A portable version of this function is already defined in general.m4sh
7289 dnl so there is no need for it here.
7290
7291 # func_stripname prefix suffix name
7292 # strip PREFIX and SUFFIX off of NAME.
7293 # PREFIX and SUFFIX must not contain globbing or regex special
7294 # characters, hashes, percent signs, but SUFFIX may contain a leading
7295 # dot (in which case that matches only a dot).
7296 # func_strip_suffix prefix name
7297 func_stripname ()
7298 {
7299 case ${2} in
7300 .*) func_stripname_result=`$ECHO "X${3}" \
7301 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
7302 *) func_stripname_result=`$ECHO "X${3}" \
7303 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
7304 esac
7305 }
7306
7307 # sed scripts:
7308 my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
7309 my_sed_long_arg='1s/^-[[^=]]*=//'
7310
7311 # func_opt_split
7312 func_opt_split ()
7313 {
7314 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
7315 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
7316 }
7317
7318 # func_lo2o object
7319 func_lo2o ()
7320 {
7321 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
7322 }
7323
7324 # func_xform libobj-or-source
7325 func_xform ()
7326 {
7327 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
7328 }
7329
7330 # func_arith arithmetic-term...
7331 func_arith ()
7332 {
7333 func_arith_result=`expr "$[@]"`
7334 }
7335
7336 # func_len string
7337 # STRING may not start with a hyphen.
7338 func_len ()
7339 {
7340 func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
7341 }
7342
7343 _LT_EOF
7344 esac
7345
7346 case $lt_shell_append in
7347 yes)
7348 cat << \_LT_EOF >> "$cfgfile"
7349
7350 # func_append var value
7351 # Append VALUE to the end of shell variable VAR.
7352 func_append ()
7353 {
7354 eval "$[1]+=\$[2]"
7355 }
7356 _LT_EOF
7357 ;;
7358 *)
7359 cat << \_LT_EOF >> "$cfgfile"
7360
7361 # func_append var value
7362 # Append VALUE to the end of shell variable VAR.
7363 func_append ()
7364 {
7365 eval "$[1]=\$$[1]\$[2]"
7366 }
7367
7368 _LT_EOF
7369 ;;
7370 esac
7371 ])
7372
7373 ##############################################################################
7374 # Helper functions for option handling. -*- Autoconf -*-
7375 #
7376 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
7377 # Written by Gary V. Vaughan, 2004
7378 #
7379 # This file is free software; the Free Software Foundation gives
7380 # unlimited permission to copy and/or distribute it, with or without
7381 # modifications, as long as this notice is preserved.
7382
7383 # serial 6 ltoptions.m4
7384
7385 # This is to help aclocal find these macros, as it can't see m4_define.
7386 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
7387
7388
7389 # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
7390 # ------------------------------------------
7391 m4_define([_LT_MANGLE_OPTION],
7392 [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
7393
7394
7395 # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
7396 # ---------------------------------------
7397 # Set option OPTION-NAME for macro MACRO-NAME, and if there is a
7398 # matching handler defined, dispatch to it. Other OPTION-NAMEs are
7399 # saved as a flag.
7400 m4_define([_LT_SET_OPTION],
7401 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
7402 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
7403 _LT_MANGLE_DEFUN([$1], [$2]),
7404 [m4_warning([Unknown $1 option `$2'])])[]dnl
7405 ])
7406
7407
7408 # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
7409 # ------------------------------------------------------------
7410 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
7411 m4_define([_LT_IF_OPTION],
7412 [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
7413
7414
7415 # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
7416 # -------------------------------------------------------
7417 # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
7418 # are set.
7419 m4_define([_LT_UNLESS_OPTIONS],
7420 [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
7421 [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
7422 [m4_define([$0_found])])])[]dnl
7423 m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
7424 ])[]dnl
7425 ])
7426
7427
7428 # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
7429 # ----------------------------------------
7430 # OPTION-LIST is a space-separated list of Libtool options associated
7431 # with MACRO-NAME. If any OPTION has a matching handler declared with
7432 # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
7433 # the unknown option and exit.
7434 m4_defun([_LT_SET_OPTIONS],
7435 [# Set options
7436 m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
7437 [_LT_SET_OPTION([$1], _LT_Option)])
7438
7439 m4_if([$1],[LT_INIT],[
7440 dnl
7441 dnl Simply set some default values (i.e off) if boolean options were not
7442 dnl specified:
7443 _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
7444 ])
7445 _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
7446 ])
7447 dnl
7448 dnl If no reference was made to various pairs of opposing options, then
7449 dnl we run the default mode handler for the pair. For example, if neither
7450 dnl `shared' nor `disable-shared' was passed, we enable building of shared
7451 dnl archives by default:
7452 _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
7453 _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
7454 _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
7455 _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
7456 [_LT_ENABLE_FAST_INSTALL])
7457 ])
7458 ])# _LT_SET_OPTIONS
7459
7460
7461 ## --------------------------------- ##
7462 ## Macros to handle LT_INIT options. ##
7463 ## --------------------------------- ##
7464
7465 # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
7466 # -----------------------------------------
7467 m4_define([_LT_MANGLE_DEFUN],
7468 [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
7469
7470
7471 # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
7472 # -----------------------------------------------
7473 m4_define([LT_OPTION_DEFINE],
7474 [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
7475 ])# LT_OPTION_DEFINE
7476
7477
7478 # dlopen
7479 # ------
7480 LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
7481 ])
7482
7483 AU_DEFUN([AC_LIBTOOL_DLOPEN],
7484 [_LT_SET_OPTION([LT_INIT], [dlopen])
7485 AC_DIAGNOSE([obsolete],
7486 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7487 put the `dlopen' option into LT_INIT's first parameter.])
7488 ])
7489
7490 dnl aclocal-1.4 backwards compatibility:
7491 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
7492
7493
7494 # win32-dll
7495 # ---------
7496 # Declare package support for building win32 dll's.
7497 LT_OPTION_DEFINE([LT_INIT], [win32-dll],
7498 [enable_win32_dll=yes
7499
7500 case $host in
7501 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
7502 AC_CHECK_TOOL(AS, as, false)
7503 AC_CHECK_TOOL(DLLTOOL, dlltool, false)
7504 AC_CHECK_TOOL(OBJDUMP, objdump, false)
7505 ;;
7506 esac
7507
7508 test -z "$AS" && AS=as
7509 _LT_DECL([], [AS], [0], [Assembler program])dnl
7510
7511 test -z "$DLLTOOL" && DLLTOOL=dlltool
7512 _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
7513
7514 test -z "$OBJDUMP" && OBJDUMP=objdump
7515 _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
7516 ])# win32-dll
7517
7518 AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
7519 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
7520 _LT_SET_OPTION([LT_INIT], [win32-dll])
7521 AC_DIAGNOSE([obsolete],
7522 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7523 put the `win32-dll' option into LT_INIT's first parameter.])
7524 ])
7525
7526 dnl aclocal-1.4 backwards compatibility:
7527 dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
7528
7529
7530 # _LT_ENABLE_SHARED([DEFAULT])
7531 # ----------------------------
7532 # implement the --enable-shared flag, and supports the `shared' and
7533 # `disable-shared' LT_INIT options.
7534 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7535 m4_define([_LT_ENABLE_SHARED],
7536 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
7537 AC_ARG_ENABLE([shared],
7538 [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
7539 [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
7540 [p=${PACKAGE-default}
7541 case $enableval in
7542 yes) enable_shared=yes ;;
7543 no) enable_shared=no ;;
7544 *)
7545 enable_shared=no
7546 # Look at the argument we got. We use all the common list separators.
7547 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7548 for pkg in $enableval; do
7549 IFS="$lt_save_ifs"
7550 if test "X$pkg" = "X$p"; then
7551 enable_shared=yes
7552 fi
7553 done
7554 IFS="$lt_save_ifs"
7555 ;;
7556 esac],
7557 [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
7558
7559 _LT_DECL([build_libtool_libs], [enable_shared], [0],
7560 [Whether or not to build shared libraries])
7561 ])# _LT_ENABLE_SHARED
7562
7563 LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
7564 LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
7565
7566 # Old names:
7567 AC_DEFUN([AC_ENABLE_SHARED],
7568 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
7569 ])
7570
7571 AC_DEFUN([AC_DISABLE_SHARED],
7572 [_LT_SET_OPTION([LT_INIT], [disable-shared])
7573 ])
7574
7575 AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
7576 AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
7577
7578 dnl aclocal-1.4 backwards compatibility:
7579 dnl AC_DEFUN([AM_ENABLE_SHARED], [])
7580 dnl AC_DEFUN([AM_DISABLE_SHARED], [])
7581
7582
7583
7584 # _LT_ENABLE_STATIC([DEFAULT])
7585 # ----------------------------
7586 # implement the --enable-static flag, and support the `static' and
7587 # `disable-static' LT_INIT options.
7588 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7589 m4_define([_LT_ENABLE_STATIC],
7590 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
7591 AC_ARG_ENABLE([static],
7592 [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
7593 [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
7594 [p=${PACKAGE-default}
7595 case $enableval in
7596 yes) enable_static=yes ;;
7597 no) enable_static=no ;;
7598 *)
7599 enable_static=no
7600 # Look at the argument we got. We use all the common list separators.
7601 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7602 for pkg in $enableval; do
7603 IFS="$lt_save_ifs"
7604 if test "X$pkg" = "X$p"; then
7605 enable_static=yes
7606 fi
7607 done
7608 IFS="$lt_save_ifs"
7609 ;;
7610 esac],
7611 [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
7612
7613 _LT_DECL([build_old_libs], [enable_static], [0],
7614 [Whether or not to build static libraries])
7615 ])# _LT_ENABLE_STATIC
7616
7617 LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
7618 LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
7619
7620 # Old names:
7621 AC_DEFUN([AC_ENABLE_STATIC],
7622 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
7623 ])
7624
7625 AC_DEFUN([AC_DISABLE_STATIC],
7626 [_LT_SET_OPTION([LT_INIT], [disable-static])
7627 ])
7628
7629 AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
7630 AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
7631
7632 dnl aclocal-1.4 backwards compatibility:
7633 dnl AC_DEFUN([AM_ENABLE_STATIC], [])
7634 dnl AC_DEFUN([AM_DISABLE_STATIC], [])
7635
7636
7637
7638 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
7639 # ----------------------------------
7640 # implement the --enable-fast-install flag, and support the `fast-install'
7641 # and `disable-fast-install' LT_INIT options.
7642 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7643 m4_define([_LT_ENABLE_FAST_INSTALL],
7644 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
7645 AC_ARG_ENABLE([fast-install],
7646 [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
7647 [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
7648 [p=${PACKAGE-default}
7649 case $enableval in
7650 yes) enable_fast_install=yes ;;
7651 no) enable_fast_install=no ;;
7652 *)
7653 enable_fast_install=no
7654 # Look at the argument we got. We use all the common list separators.
7655 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7656 for pkg in $enableval; do
7657 IFS="$lt_save_ifs"
7658 if test "X$pkg" = "X$p"; then
7659 enable_fast_install=yes
7660 fi
7661 done
7662 IFS="$lt_save_ifs"
7663 ;;
7664 esac],
7665 [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
7666
7667 _LT_DECL([fast_install], [enable_fast_install], [0],
7668 [Whether or not to optimize for fast installation])dnl
7669 ])# _LT_ENABLE_FAST_INSTALL
7670
7671 LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
7672 LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
7673
7674 # Old names:
7675 AU_DEFUN([AC_ENABLE_FAST_INSTALL],
7676 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
7677 AC_DIAGNOSE([obsolete],
7678 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
7679 the `fast-install' option into LT_INIT's first parameter.])
7680 ])
7681
7682 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
7683 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
7684 AC_DIAGNOSE([obsolete],
7685 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
7686 the `disable-fast-install' option into LT_INIT's first parameter.])
7687 ])
7688
7689 dnl aclocal-1.4 backwards compatibility:
7690 dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
7691 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
7692
7693
7694 # _LT_WITH_PIC([MODE])
7695 # --------------------
7696 # implement the --with-pic flag, and support the `pic-only' and `no-pic'
7697 # LT_INIT options.
7698 # MODE is either `yes' or `no'. If omitted, it defaults to `both'.
7699 m4_define([_LT_WITH_PIC],
7700 [AC_ARG_WITH([pic],
7701 [AS_HELP_STRING([--with-pic],
7702 [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
7703 [pic_mode="$withval"],
7704 [pic_mode=default])
7705
7706 test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
7707
7708 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
7709 ])# _LT_WITH_PIC
7710
7711 LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
7712 LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
7713
7714 # Old name:
7715 AU_DEFUN([AC_LIBTOOL_PICMODE],
7716 [_LT_SET_OPTION([LT_INIT], [pic-only])
7717 AC_DIAGNOSE([obsolete],
7718 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7719 put the `pic-only' option into LT_INIT's first parameter.])
7720 ])
7721
7722 dnl aclocal-1.4 backwards compatibility:
7723 dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
7724
7725 ## ----------------- ##
7726 ## LTDL_INIT Options ##
7727 ## ----------------- ##
7728
7729 m4_define([_LTDL_MODE], [])
7730 LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
7731 [m4_define([_LTDL_MODE], [nonrecursive])])
7732 LT_OPTION_DEFINE([LTDL_INIT], [recursive],
7733 [m4_define([_LTDL_MODE], [recursive])])
7734 LT_OPTION_DEFINE([LTDL_INIT], [subproject],
7735 [m4_define([_LTDL_MODE], [subproject])])
7736
7737 m4_define([_LTDL_TYPE], [])
7738 LT_OPTION_DEFINE([LTDL_INIT], [installable],
7739 [m4_define([_LTDL_TYPE], [installable])])
7740 LT_OPTION_DEFINE([LTDL_INIT], [convenience],
7741 [m4_define([_LTDL_TYPE], [convenience])])
7742
7743 ##############################################################################
7744 # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
7745 #
7746 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
7747 # Written by Gary V. Vaughan, 2004
7748 #
7749 # This file is free software; the Free Software Foundation gives
7750 # unlimited permission to copy and/or distribute it, with or without
7751 # modifications, as long as this notice is preserved.
7752
7753 # serial 6 ltsugar.m4
7754
7755 # This is to help aclocal find these macros, as it can't see m4_define.
7756 AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
7757
7758
7759 # lt_join(SEP, ARG1, [ARG2...])
7760 # -----------------------------
7761 # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
7762 # associated separator.
7763 # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
7764 # versions in m4sugar had bugs.
7765 m4_define([lt_join],
7766 [m4_if([$#], [1], [],
7767 [$#], [2], [[$2]],
7768 [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
7769 m4_define([_lt_join],
7770 [m4_if([$#$2], [2], [],
7771 [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
7772
7773
7774 # lt_car(LIST)
7775 # lt_cdr(LIST)
7776 # ------------
7777 # Manipulate m4 lists.
7778 # These macros are necessary as long as will still need to support
7779 # Autoconf-2.59 which quotes differently.
7780 m4_define([lt_car], [[$1]])
7781 m4_define([lt_cdr],
7782 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
7783 [$#], 1, [],
7784 [m4_dquote(m4_shift($@))])])
7785 m4_define([lt_unquote], $1)
7786
7787
7788 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
7789 # ------------------------------------------
7790 # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
7791 # Note that neither SEPARATOR nor STRING are expanded; they are appended
7792 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
7793 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
7794 # than defined and empty).
7795 #
7796 # This macro is needed until we can rely on Autoconf 2.62, since earlier
7797 # versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
7798 m4_define([lt_append],
7799 [m4_define([$1],
7800 m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
7801
7802
7803
7804 # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
7805 # ----------------------------------------------------------
7806 # Produce a SEP delimited list of all paired combinations of elements of
7807 # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
7808 # has the form PREFIXmINFIXSUFFIXn.
7809 # Needed until we can rely on m4_combine added in Autoconf 2.62.
7810 m4_define([lt_combine],
7811 [m4_if(m4_eval([$# > 3]), [1],
7812 [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
7813 [[m4_foreach([_Lt_prefix], [$2],
7814 [m4_foreach([_Lt_suffix],
7815 ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
7816 [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
7817
7818
7819 # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
7820 # -----------------------------------------------------------------------
7821 # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
7822 # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
7823 m4_define([lt_if_append_uniq],
7824 [m4_ifdef([$1],
7825 [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
7826 [lt_append([$1], [$2], [$3])$4],
7827 [$5])],
7828 [lt_append([$1], [$2], [$3])$4])])
7829
7830
7831 # lt_dict_add(DICT, KEY, VALUE)
7832 # -----------------------------
7833 m4_define([lt_dict_add],
7834 [m4_define([$1($2)], [$3])])
7835
7836
7837 # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
7838 # --------------------------------------------
7839 m4_define([lt_dict_add_subkey],
7840 [m4_define([$1($2:$3)], [$4])])
7841
7842
7843 # lt_dict_fetch(DICT, KEY, [SUBKEY])
7844 # ----------------------------------
7845 m4_define([lt_dict_fetch],
7846 [m4_ifval([$3],
7847 m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
7848 m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
7849
7850
7851 # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
7852 # -----------------------------------------------------------------
7853 m4_define([lt_if_dict_fetch],
7854 [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
7855 [$5],
7856 [$6])])
7857
7858
7859 # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
7860 # --------------------------------------------------------------
7861 m4_define([lt_dict_filter],
7862 [m4_if([$5], [], [],
7863 [lt_join(m4_quote(m4_default([$4], [[, ]])),
7864 lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
7865 [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
7866 ])
7867
7868 ##############################################################################
7869 # ltversion.m4 -- version numbers -*- Autoconf -*-
7870 #
7871 # Copyright (C) 2004 Free Software Foundation, Inc.
7872 # Written by Scott James Remnant, 2004
7873 #
7874 # This file is free software; the Free Software Foundation gives
7875 # unlimited permission to copy and/or distribute it, with or without
7876 # modifications, as long as this notice is preserved.
7877
7878 # Generated from ltversion.in.
7879
7880 # serial 3012 ltversion.m4
7881 # This file is part of GNU Libtool
7882
7883 m4_define([LT_PACKAGE_VERSION], [2.2.6])
7884 m4_define([LT_PACKAGE_REVISION], [1.3012])
7885
7886 AC_DEFUN([LTVERSION_VERSION],
7887 [macro_version='2.2.6'
7888 macro_revision='1.3012'
7889 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
7890 _LT_DECL(, macro_revision, 0)
7891 ])
7892
7893 ##############################################################################
7894 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
7895 #
7896 # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
7897 # Written by Scott James Remnant, 2004.
7898 #
7899 # This file is free software; the Free Software Foundation gives
7900 # unlimited permission to copy and/or distribute it, with or without
7901 # modifications, as long as this notice is preserved.
7902
7903 # serial 4 lt~obsolete.m4
7904
7905 # These exist entirely to fool aclocal when bootstrapping libtool.
7906 #
7907 # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
7908 # which have later been changed to m4_define as they aren't part of the
7909 # exported API, or moved to Autoconf or Automake where they belong.
7910 #
7911 # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
7912 # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
7913 # using a macro with the same name in our local m4/libtool.m4 it'll
7914 # pull the old libtool.m4 in (it doesn't see our shiny new m4_define
7915 # and doesn't know about Autoconf macros at all.)
7916 #
7917 # So we provide this file, which has a silly filename so it's always
7918 # included after everything else. This provides aclocal with the
7919 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
7920 # because those macros already exist, or will be overwritten later.
7921 # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
7922 #
7923 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
7924 # Yes, that means every name once taken will need to remain here until
7925 # we give up compatibility with versions before 1.7, at which point
7926 # we need to keep only those names which we still refer to.
7927
7928 # This is to help aclocal find these macros, as it can't see m4_define.
7929 AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
7930
7931 m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
7932 m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
7933 m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
7934 m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
7935 m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
7936 m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
7937 m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
7938 m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
7939 m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
7940 m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
7941 m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
7942 m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
7943 m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
7944 m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
7945 m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
7946 m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
7947 m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
7948 m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
7949 m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
7950 m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
7951 m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
7952 m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
7953 m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
7954 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
7955 m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
7956 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
7957 m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
7958 m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
7959 m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
7960 m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
7961 m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
7962 m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
7963 m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
7964 m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
7965 m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
7966 m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
7967 m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
7968 m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
7969 m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
7970 m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
7971 m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
7972 m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
7973 m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
7974 m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
7975 m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
7976 m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
7977 m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
7978 m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
7979 m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
7980 m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
7981 m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
7982 m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
7983 m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
7984 m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
7985 m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
7986 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
7987 #
7988 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
7989 #
7990 # This program is free software; you can redistribute it and/or modify
7991 # it under the terms of the GNU General Public License as published by
7992 # the Free Software Foundation; either version 2 of the License, or
7993 # (at your option) any later version.
7994 #
7995 # This program is distributed in the hope that it will be useful, but
7996 # WITHOUT ANY WARRANTY; without even the implied warranty of
7997 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7998 # General Public License for more details.
7999 #
8000 # You should have received a copy of the GNU General Public License
8001 # along with this program; if not, write to the Free Software
8002 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
8003 #
8004 # As a special exception to the GNU General Public License, if you
8005 # distribute this file as part of a program that contains a
8006 # configuration script generated by Autoconf, you may include it under
8007 # the same distribution terms that you use for the rest of that program.
8008
8009 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
8010 # ----------------------------------
8011 AC_DEFUN([PKG_PROG_PKG_CONFIG],
8012 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
8013 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
8014 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
8015 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
8016 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
8017 fi
8018 if test -n "$PKG_CONFIG"; then
8019 _pkg_min_version=m4_default([$1], [0.9.0])
8020 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
8021 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
8022 AC_MSG_RESULT([yes])
8023 else
8024 AC_MSG_RESULT([no])
8025 PKG_CONFIG=""
8026 fi
8027
8028 fi[]dnl
8029 ])# PKG_PROG_PKG_CONFIG
8030
8031 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
8032 #
8033 # Check to see whether a particular set of modules exists. Similar
8034 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
8035 #
8036 #
8037 # Similar to PKG_CHECK_MODULES, make sure that the first instance of
8038 # this or PKG_CHECK_MODULES is called, or make sure to call
8039 # PKG_CHECK_EXISTS manually
8040 # --------------------------------------------------------------
8041 AC_DEFUN([PKG_CHECK_EXISTS],
8042 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
8043 if test -n "$PKG_CONFIG" && \
8044 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
8045 m4_ifval([$2], [$2], [:])
8046 m4_ifvaln([$3], [else
8047 $3])dnl
8048 fi])
8049
8050
8051 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
8052 # ---------------------------------------------
8053 m4_define([_PKG_CONFIG],
8054 [if test -n "$PKG_CONFIG"; then
8055 if test -n "$$1"; then
8056 pkg_cv_[]$1="$$1"
8057 else
8058 PKG_CHECK_EXISTS([$3],
8059 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
8060 [pkg_failed=yes])
8061 fi
8062 else
8063 pkg_failed=untried
8064 fi[]dnl
8065 ])# _PKG_CONFIG
8066
8067 # _PKG_SHORT_ERRORS_SUPPORTED
8068 # -----------------------------
8069 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
8070 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
8071 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
8072 _pkg_short_errors_supported=yes
8073 else
8074 _pkg_short_errors_supported=no
8075 fi[]dnl
8076 ])# _PKG_SHORT_ERRORS_SUPPORTED
8077
8078
8079 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
8080 # [ACTION-IF-NOT-FOUND])
8081 #
8082 #
8083 # Note that if there is a possibility the first call to
8084 # PKG_CHECK_MODULES might not happen, you should be sure to include an
8085 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
8086 #
8087 #
8088 # --------------------------------------------------------------
8089 AC_DEFUN([PKG_CHECK_MODULES],
8090 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
8091 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
8092 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
8093
8094 pkg_failed=no
8095 AC_MSG_CHECKING([for $1])
8096
8097 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
8098 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
8099
8100 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
8101 and $1[]_LIBS to avoid the need to call pkg-config.
8102 See the pkg-config man page for more details.])
8103
8104 if test $pkg_failed = yes; then
8105 _PKG_SHORT_ERRORS_SUPPORTED
8106 if test $_pkg_short_errors_supported = yes; then
8107 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
8108 else
8109 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
8110 fi
8111 # Put the nasty error message in config.log where it belongs
8112 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
8113
8114 ifelse([$4], , [AC_MSG_ERROR(dnl
8115 [Package requirements ($2) were not met:
8116
8117 $$1_PKG_ERRORS
8118
8119 Consider adjusting the PKG_CONFIG_PATH environment variable if you
8120 installed software in a non-standard prefix.
8121
8122 _PKG_TEXT
8123 ])],
8124 [AC_MSG_RESULT([no])
8125 $4])
8126 elif test $pkg_failed = untried; then
8127 ifelse([$4], , [AC_MSG_FAILURE(dnl
8128 [The pkg-config script could not be found or is too old. Make sure it
8129 is in your PATH or set the PKG_CONFIG environment variable to the full
8130 path to pkg-config.
8131
8132 _PKG_TEXT
8133
8134 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
8135 [$4])
8136 else
8137 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
8138 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
8139 AC_MSG_RESULT([yes])
8140 ifelse([$3], , :, [$3])
8141 fi[]dnl
8142 ])# PKG_CHECK_MODULES
8143 # Configure paths for SDL
8144 # Sam Lantinga 9/21/99
8145 # stolen from Manish Singh
8146 # stolen back from Frank Belew
8147 # stolen from Manish Singh
8148 # Shamelessly stolen from Owen Taylor
8149
8150 # serial 1
8151
8152 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8153 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
8154 dnl
8155 AC_DEFUN([AM_PATH_SDL2],
8156 [dnl
8157 dnl Get the cflags and libraries from the sdl2-config script
8158 dnl
8159 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
8160 sdl_prefix="$withval", sdl_prefix="")
8161 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
8162 sdl_exec_prefix="$withval", sdl_exec_prefix="")
8163 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
8164 , enable_sdltest=yes)
8165
8166 min_sdl_version=ifelse([$1], ,2.0.0,$1)
8167
8168 if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
8169 PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
8170 [sdl_pc=yes],
8171 [sdl_pc=no])
8172 else
8173 sdl_pc=no
8174 if test x$sdl_exec_prefix != x ; then
8175 sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
8176 if test x${SDL2_CONFIG+set} != xset ; then
8177 SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config
8178 fi
8179 fi
8180 if test x$sdl_prefix != x ; then
8181 sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
8182 if test x${SDL2_CONFIG+set} != xset ; then
8183 SDL2_CONFIG=$sdl_prefix/bin/sdl2-config
8184 fi
8185 fi
8186 fi
8187
8188 if test "x$sdl_pc" = xyes ; then
8189 no_sdl=""
8190 SDL2_CONFIG="pkg-config sdl2"
8191 else
8192 as_save_PATH="$PATH"
8193 if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
8194 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
8195 fi
8196 AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH])
8197 PATH="$as_save_PATH"
8198 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
8199 no_sdl=""
8200
8201 if test "$SDL2_CONFIG" = "no" ; then
8202 no_sdl=yes
8203 else
8204 SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
8205 SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
8206
8207 sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
8208 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
8209 sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
8210 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
8211 sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \
8212 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
8213 if test "x$enable_sdltest" = "xyes" ; then
8214 ac_save_CFLAGS="$CFLAGS"
8215 ac_save_CXXFLAGS="$CXXFLAGS"
8216 ac_save_LIBS="$LIBS"
8217 CFLAGS="$CFLAGS $SDL_CFLAGS"
8218 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
8219 LIBS="$LIBS $SDL_LIBS"
8220 dnl
8221 dnl Now check if the installed SDL is sufficiently new. (Also sanity
8222 dnl checks the results of sdl2-config to some extent
8223 dnl
8224 rm -f conf.sdltest
8225 AC_TRY_RUN([
8226 #include <stdio.h>
8227 #include <stdlib.h>
8228 #include <string.h>
8229 #include "SDL.h"
8230
8231 char*
8232 my_strdup (char *str)
8233 {
8234 char *new_str;
8235
8236 if (str)
8237 {
8238 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
8239 strcpy (new_str, str);
8240 }
8241 else
8242 new_str = NULL;
8243
8244 return new_str;
8245 }
8246
8247 int main (int argc, char *argv[])
8248 {
8249 int major, minor, micro;
8250 char *tmp_version;
8251
8252 /* This hangs on some systems (?)
8253 system ("touch conf.sdltest");
8254 */
8255 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
8256
8257 /* HP/UX 9 (%@#!) writes to sscanf strings */
8258 tmp_version = my_strdup("$min_sdl_version");
8259 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
8260 printf("%s, bad version string\n", "$min_sdl_version");
8261 exit(1);
8262 }
8263
8264 if (($sdl_major_version > major) ||
8265 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
8266 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
8267 {
8268 return 0;
8269 }
8270 else
8271 {
8272 printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
8273 printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro);
8274 printf("*** best to upgrade to the required version.\n");
8275 printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n");
8276 printf("*** to point to the correct copy of sdl2-config, and remove the file\n");
8277 printf("*** config.cache before re-running configure\n");
8278 return 1;
8279 }
8280 }
8281
8282 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
8283 CFLAGS="$ac_save_CFLAGS"
8284 CXXFLAGS="$ac_save_CXXFLAGS"
8285 LIBS="$ac_save_LIBS"
8286 fi
8287 fi
8288 if test "x$no_sdl" = x ; then
8289 AC_MSG_RESULT(yes)
8290 else
8291 AC_MSG_RESULT(no)
8292 fi
8293 fi
8294 if test "x$no_sdl" = x ; then
8295 ifelse([$2], , :, [$2])
8296 else
8297 if test "$SDL2_CONFIG" = "no" ; then
8298 echo "*** The sdl2-config script installed by SDL could not be found"
8299 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
8300 echo "*** your path, or set the SDL2_CONFIG environment variable to the"
8301 echo "*** full path to sdl2-config."
8302 else
8303 if test -f conf.sdltest ; then
8304 :
8305 else
8306 echo "*** Could not run SDL test program, checking why..."
8307 CFLAGS="$CFLAGS $SDL_CFLAGS"
8308 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
8309 LIBS="$LIBS $SDL_LIBS"
8310 AC_TRY_LINK([
8311 #include <stdio.h>
8312 #include "SDL.h"
8313
8314 int main(int argc, char *argv[])
8315 { return 0; }
8316 #undef main
8317 #define main K_and_R_C_main
8318 ], [ return 0; ],
8319 [ echo "*** The test program compiled, but did not run. This usually means"
8320 echo "*** that the run-time linker is not finding SDL or finding the wrong"
8321 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
8322 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
8323 echo "*** to the installed location Also, make sure you have run ldconfig if that"
8324 echo "*** is required on your system"
8325 echo "***"
8326 echo "*** If you have an old version installed, it is best to remove it, although"
8327 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
8328 [ echo "*** The test program failed to compile or link. See the file config.log for the"
8329 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
8330 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
8331 echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ])
8332 CFLAGS="$ac_save_CFLAGS"
8333 CXXFLAGS="$ac_save_CXXFLAGS"
8334 LIBS="$ac_save_LIBS"
8335 fi
8336 fi
8337 SDL_CFLAGS=""
8338 SDL_LIBS=""
8339 ifelse([$3], , :, [$3])
8340 fi
8341 AC_SUBST(SDL_CFLAGS)
8342 AC_SUBST(SDL_LIBS)
8343 rm -f conf.sdltest
8344 ])
+0
-1476
build-scripts/config.guess less more
0 #! /bin/sh
1 # Attempt to guess a canonical system name.
2 # Copyright 1992-2017 Free Software Foundation, Inc.
3
4 timestamp='2017-08-08'
5
6 # This file is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #
19 # As a special exception to the GNU General Public License, if you
20 # distribute this file as part of a program that contains a
21 # configuration script generated by Autoconf, you may include it under
22 # the same distribution terms that you use for the rest of that
23 # program. This Exception is an additional permission under section 7
24 # of the GNU General Public License, version 3 ("GPLv3").
25 #
26 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
27 #
28 # You can get the latest version of this script from:
29 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
30 #
31 # Please send patches to <config-patches@gnu.org>.
32
33
34 me=`echo "$0" | sed -e 's,.*/,,'`
35
36 usage="\
37 Usage: $0 [OPTION]
38
39 Output the configuration name of the system \`$me' is run on.
40
41 Operation modes:
42 -h, --help print this help, then exit
43 -t, --time-stamp print date of last modification, then exit
44 -v, --version print version number, then exit
45
46 Report bugs and patches to <config-patches@gnu.org>."
47
48 version="\
49 GNU config.guess ($timestamp)
50
51 Originally written by Per Bothner.
52 Copyright 1992-2017 Free Software Foundation, Inc.
53
54 This is free software; see the source for copying conditions. There is NO
55 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
56
57 help="
58 Try \`$me --help' for more information."
59
60 # Parse command line
61 while test $# -gt 0 ; do
62 case $1 in
63 --time-stamp | --time* | -t )
64 echo "$timestamp" ; exit ;;
65 --version | -v )
66 echo "$version" ; exit ;;
67 --help | --h* | -h )
68 echo "$usage"; exit ;;
69 -- ) # Stop option processing
70 shift; break ;;
71 - ) # Use stdin as input.
72 break ;;
73 -* )
74 echo "$me: invalid option $1$help" >&2
75 exit 1 ;;
76 * )
77 break ;;
78 esac
79 done
80
81 if test $# != 0; then
82 echo "$me: too many arguments$help" >&2
83 exit 1
84 fi
85
86 trap 'exit 1' 1 2 15
87
88 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
89 # compiler to aid in system detection is discouraged as it requires
90 # temporary files to be created and, as you can see below, it is a
91 # headache to deal with in a portable fashion.
92
93 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
94 # use `HOST_CC' if defined, but it is deprecated.
95
96 # Portable tmp directory creation inspired by the Autoconf team.
97
98 set_cc_for_build='
99 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
100 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
101 : ${TMPDIR=/tmp} ;
102 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
103 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
104 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
105 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
106 dummy=$tmp/dummy ;
107 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
108 case $CC_FOR_BUILD,$HOST_CC,$CC in
109 ,,) echo "int x;" > $dummy.c ;
110 for c in cc gcc c89 c99 ; do
111 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
112 CC_FOR_BUILD="$c"; break ;
113 fi ;
114 done ;
115 if test x"$CC_FOR_BUILD" = x ; then
116 CC_FOR_BUILD=no_compiler_found ;
117 fi
118 ;;
119 ,,*) CC_FOR_BUILD=$CC ;;
120 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
121 esac ; set_cc_for_build= ;'
122
123 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
124 # (ghazi@noc.rutgers.edu 1994-08-24)
125 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
126 PATH=$PATH:/.attbin ; export PATH
127 fi
128
129 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
130 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
131 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
132 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
133
134 case "${UNAME_SYSTEM}" in
135 Linux|GNU|GNU/*)
136 # If the system lacks a compiler, then just pick glibc.
137 # We could probably try harder.
138 LIBC=gnu
139
140 eval $set_cc_for_build
141 cat <<-EOF > $dummy.c
142 #include <features.h>
143 #if defined(__UCLIBC__)
144 LIBC=uclibc
145 #elif defined(__dietlibc__)
146 LIBC=dietlibc
147 #else
148 LIBC=gnu
149 #endif
150 EOF
151 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
152 ;;
153 esac
154
155 # Note: order is significant - the case branches are not exclusive.
156
157 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
158 *:NetBSD:*:*)
159 # NetBSD (nbsd) targets should (where applicable) match one or
160 # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
161 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
162 # switched to ELF, *-*-netbsd* would select the old
163 # object file format. This provides both forward
164 # compatibility and a consistent mechanism for selecting the
165 # object file format.
166 #
167 # Note: NetBSD doesn't particularly care about the vendor
168 # portion of the name. We always set it to "unknown".
169 sysctl="sysctl -n hw.machine_arch"
170 UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
171 /sbin/$sysctl 2>/dev/null || \
172 /usr/sbin/$sysctl 2>/dev/null || \
173 echo unknown)`
174 case "${UNAME_MACHINE_ARCH}" in
175 armeb) machine=armeb-unknown ;;
176 arm*) machine=arm-unknown ;;
177 sh3el) machine=shl-unknown ;;
178 sh3eb) machine=sh-unknown ;;
179 sh5el) machine=sh5le-unknown ;;
180 earmv*)
181 arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
182 endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
183 machine=${arch}${endian}-unknown
184 ;;
185 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
186 esac
187 # The Operating System including object format, if it has switched
188 # to ELF recently (or will in the future) and ABI.
189 case "${UNAME_MACHINE_ARCH}" in
190 earm*)
191 os=netbsdelf
192 ;;
193 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
194 eval $set_cc_for_build
195 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
196 | grep -q __ELF__
197 then
198 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
199 # Return netbsd for either. FIX?
200 os=netbsd
201 else
202 os=netbsdelf
203 fi
204 ;;
205 *)
206 os=netbsd
207 ;;
208 esac
209 # Determine ABI tags.
210 case "${UNAME_MACHINE_ARCH}" in
211 earm*)
212 expr='s/^earmv[0-9]/-eabi/;s/eb$//'
213 abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
214 ;;
215 esac
216 # The OS release
217 # Debian GNU/NetBSD machines have a different userland, and
218 # thus, need a distinct triplet. However, they do not need
219 # kernel version information, so it can be replaced with a
220 # suitable tag, in the style of linux-gnu.
221 case "${UNAME_VERSION}" in
222 Debian*)
223 release='-gnu'
224 ;;
225 *)
226 release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
227 ;;
228 esac
229 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
230 # contains redundant information, the shorter form:
231 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
232 echo "${machine}-${os}${release}${abi}"
233 exit ;;
234 *:Bitrig:*:*)
235 UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
236 echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
237 exit ;;
238 *:OpenBSD:*:*)
239 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
240 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
241 exit ;;
242 *:LibertyBSD:*:*)
243 UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
244 echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE}
245 exit ;;
246 *:ekkoBSD:*:*)
247 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
248 exit ;;
249 *:SolidBSD:*:*)
250 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
251 exit ;;
252 macppc:MirBSD:*:*)
253 echo powerpc-unknown-mirbsd${UNAME_RELEASE}
254 exit ;;
255 *:MirBSD:*:*)
256 echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
257 exit ;;
258 *:Sortix:*:*)
259 echo ${UNAME_MACHINE}-unknown-sortix
260 exit ;;
261 *:Redox:*:*)
262 echo ${UNAME_MACHINE}-unknown-redox
263 exit ;;
264 alpha:OSF1:*:*)
265 case $UNAME_RELEASE in
266 *4.0)
267 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
268 ;;
269 *5.*)
270 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
271 ;;
272 esac
273 # According to Compaq, /usr/sbin/psrinfo has been available on
274 # OSF/1 and Tru64 systems produced since 1995. I hope that
275 # covers most systems running today. This code pipes the CPU
276 # types through head -n 1, so we only detect the type of CPU 0.
277 ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
278 case "$ALPHA_CPU_TYPE" in
279 "EV4 (21064)")
280 UNAME_MACHINE=alpha ;;
281 "EV4.5 (21064)")
282 UNAME_MACHINE=alpha ;;
283 "LCA4 (21066/21068)")
284 UNAME_MACHINE=alpha ;;
285 "EV5 (21164)")
286 UNAME_MACHINE=alphaev5 ;;
287 "EV5.6 (21164A)")
288 UNAME_MACHINE=alphaev56 ;;
289 "EV5.6 (21164PC)")
290 UNAME_MACHINE=alphapca56 ;;
291 "EV5.7 (21164PC)")
292 UNAME_MACHINE=alphapca57 ;;
293 "EV6 (21264)")
294 UNAME_MACHINE=alphaev6 ;;
295 "EV6.7 (21264A)")
296 UNAME_MACHINE=alphaev67 ;;
297 "EV6.8CB (21264C)")
298 UNAME_MACHINE=alphaev68 ;;
299 "EV6.8AL (21264B)")
300 UNAME_MACHINE=alphaev68 ;;
301 "EV6.8CX (21264D)")
302 UNAME_MACHINE=alphaev68 ;;
303 "EV6.9A (21264/EV69A)")
304 UNAME_MACHINE=alphaev69 ;;
305 "EV7 (21364)")
306 UNAME_MACHINE=alphaev7 ;;
307 "EV7.9 (21364A)")
308 UNAME_MACHINE=alphaev79 ;;
309 esac
310 # A Pn.n version is a patched version.
311 # A Vn.n version is a released version.
312 # A Tn.n version is a released field test version.
313 # A Xn.n version is an unreleased experimental baselevel.
314 # 1.2 uses "1.2" for uname -r.
315 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
316 # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
317 exitcode=$?
318 trap '' 0
319 exit $exitcode ;;
320 Alpha\ *:Windows_NT*:*)
321 # How do we know it's Interix rather than the generic POSIX subsystem?
322 # Should we change UNAME_MACHINE based on the output of uname instead
323 # of the specific Alpha model?
324 echo alpha-pc-interix
325 exit ;;
326 21064:Windows_NT:50:3)
327 echo alpha-dec-winnt3.5
328 exit ;;
329 Amiga*:UNIX_System_V:4.0:*)
330 echo m68k-unknown-sysv4
331 exit ;;
332 *:[Aa]miga[Oo][Ss]:*:*)
333 echo ${UNAME_MACHINE}-unknown-amigaos
334 exit ;;
335 *:[Mm]orph[Oo][Ss]:*:*)
336 echo ${UNAME_MACHINE}-unknown-morphos
337 exit ;;
338 *:OS/390:*:*)
339 echo i370-ibm-openedition
340 exit ;;
341 *:z/VM:*:*)
342 echo s390-ibm-zvmoe
343 exit ;;
344 *:OS400:*:*)
345 echo powerpc-ibm-os400
346 exit ;;
347 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
348 echo arm-acorn-riscix${UNAME_RELEASE}
349 exit ;;
350 arm*:riscos:*:*|arm*:RISCOS:*:*)
351 echo arm-unknown-riscos
352 exit ;;
353 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
354 echo hppa1.1-hitachi-hiuxmpp
355 exit ;;
356 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
357 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
358 if test "`(/bin/universe) 2>/dev/null`" = att ; then
359 echo pyramid-pyramid-sysv3
360 else
361 echo pyramid-pyramid-bsd
362 fi
363 exit ;;
364 NILE*:*:*:dcosx)
365 echo pyramid-pyramid-svr4
366 exit ;;
367 DRS?6000:unix:4.0:6*)
368 echo sparc-icl-nx6
369 exit ;;
370 DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
371 case `/usr/bin/uname -p` in
372 sparc) echo sparc-icl-nx7; exit ;;
373 esac ;;
374 s390x:SunOS:*:*)
375 echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
376 exit ;;
377 sun4H:SunOS:5.*:*)
378 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
379 exit ;;
380 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
381 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
382 exit ;;
383 i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
384 echo i386-pc-auroraux${UNAME_RELEASE}
385 exit ;;
386 i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
387 eval $set_cc_for_build
388 SUN_ARCH=i386
389 # If there is a compiler, see if it is configured for 64-bit objects.
390 # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
391 # This test works for both compilers.
392 if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
393 if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
394 (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
395 grep IS_64BIT_ARCH >/dev/null
396 then
397 SUN_ARCH=x86_64
398 fi
399 fi
400 echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
401 exit ;;
402 sun4*:SunOS:6*:*)
403 # According to config.sub, this is the proper way to canonicalize
404 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
405 # it's likely to be more like Solaris than SunOS4.
406 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
407 exit ;;
408 sun4*:SunOS:*:*)
409 case "`/usr/bin/arch -k`" in
410 Series*|S4*)
411 UNAME_RELEASE=`uname -v`
412 ;;
413 esac
414 # Japanese Language versions have a version number like `4.1.3-JL'.
415 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
416 exit ;;
417 sun3*:SunOS:*:*)
418 echo m68k-sun-sunos${UNAME_RELEASE}
419 exit ;;
420 sun*:*:4.2BSD:*)
421 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
422 test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3
423 case "`/bin/arch`" in
424 sun3)
425 echo m68k-sun-sunos${UNAME_RELEASE}
426 ;;
427 sun4)
428 echo sparc-sun-sunos${UNAME_RELEASE}
429 ;;
430 esac
431 exit ;;
432 aushp:SunOS:*:*)
433 echo sparc-auspex-sunos${UNAME_RELEASE}
434 exit ;;
435 # The situation for MiNT is a little confusing. The machine name
436 # can be virtually everything (everything which is not
437 # "atarist" or "atariste" at least should have a processor
438 # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
439 # to the lowercase version "mint" (or "freemint"). Finally
440 # the system name "TOS" denotes a system which is actually not
441 # MiNT. But MiNT is downward compatible to TOS, so this should
442 # be no problem.
443 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
444 echo m68k-atari-mint${UNAME_RELEASE}
445 exit ;;
446 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
447 echo m68k-atari-mint${UNAME_RELEASE}
448 exit ;;
449 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
450 echo m68k-atari-mint${UNAME_RELEASE}
451 exit ;;
452 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
453 echo m68k-milan-mint${UNAME_RELEASE}
454 exit ;;
455 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
456 echo m68k-hades-mint${UNAME_RELEASE}
457 exit ;;
458 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
459 echo m68k-unknown-mint${UNAME_RELEASE}
460 exit ;;
461 m68k:machten:*:*)
462 echo m68k-apple-machten${UNAME_RELEASE}
463 exit ;;
464 powerpc:machten:*:*)
465 echo powerpc-apple-machten${UNAME_RELEASE}
466 exit ;;
467 RISC*:Mach:*:*)
468 echo mips-dec-mach_bsd4.3
469 exit ;;
470 RISC*:ULTRIX:*:*)
471 echo mips-dec-ultrix${UNAME_RELEASE}
472 exit ;;
473 VAX*:ULTRIX*:*:*)
474 echo vax-dec-ultrix${UNAME_RELEASE}
475 exit ;;
476 2020:CLIX:*:* | 2430:CLIX:*:*)
477 echo clipper-intergraph-clix${UNAME_RELEASE}
478 exit ;;
479 mips:*:*:UMIPS | mips:*:*:RISCos)
480 eval $set_cc_for_build
481 sed 's/^ //' << EOF >$dummy.c
482 #ifdef __cplusplus
483 #include <stdio.h> /* for printf() prototype */
484 int main (int argc, char *argv[]) {
485 #else
486 int main (argc, argv) int argc; char *argv[]; {
487 #endif
488 #if defined (host_mips) && defined (MIPSEB)
489 #if defined (SYSTYPE_SYSV)
490 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
491 #endif
492 #if defined (SYSTYPE_SVR4)
493 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
494 #endif
495 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
496 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
497 #endif
498 #endif
499 exit (-1);
500 }
501 EOF
502 $CC_FOR_BUILD -o $dummy $dummy.c &&
503 dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
504 SYSTEM_NAME=`$dummy $dummyarg` &&
505 { echo "$SYSTEM_NAME"; exit; }
506 echo mips-mips-riscos${UNAME_RELEASE}
507 exit ;;
508 Motorola:PowerMAX_OS:*:*)
509 echo powerpc-motorola-powermax
510 exit ;;
511 Motorola:*:4.3:PL8-*)
512 echo powerpc-harris-powermax
513 exit ;;
514 Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
515 echo powerpc-harris-powermax
516 exit ;;
517 Night_Hawk:Power_UNIX:*:*)
518 echo powerpc-harris-powerunix
519 exit ;;
520 m88k:CX/UX:7*:*)
521 echo m88k-harris-cxux7
522 exit ;;
523 m88k:*:4*:R4*)
524 echo m88k-motorola-sysv4
525 exit ;;
526 m88k:*:3*:R3*)
527 echo m88k-motorola-sysv3
528 exit ;;
529 AViiON:dgux:*:*)
530 # DG/UX returns AViiON for all architectures
531 UNAME_PROCESSOR=`/usr/bin/uname -p`
532 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
533 then
534 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
535 [ ${TARGET_BINARY_INTERFACE}x = x ]
536 then
537 echo m88k-dg-dgux${UNAME_RELEASE}
538 else
539 echo m88k-dg-dguxbcs${UNAME_RELEASE}
540 fi
541 else
542 echo i586-dg-dgux${UNAME_RELEASE}
543 fi
544 exit ;;
545 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
546 echo m88k-dolphin-sysv3
547 exit ;;
548 M88*:*:R3*:*)
549 # Delta 88k system running SVR3
550 echo m88k-motorola-sysv3
551 exit ;;
552 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
553 echo m88k-tektronix-sysv3
554 exit ;;
555 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
556 echo m68k-tektronix-bsd
557 exit ;;
558 *:IRIX*:*:*)
559 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
560 exit ;;
561 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
562 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
563 exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
564 i*86:AIX:*:*)
565 echo i386-ibm-aix
566 exit ;;
567 ia64:AIX:*:*)
568 if [ -x /usr/bin/oslevel ] ; then
569 IBM_REV=`/usr/bin/oslevel`
570 else
571 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
572 fi
573 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
574 exit ;;
575 *:AIX:2:3)
576 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
577 eval $set_cc_for_build
578 sed 's/^ //' << EOF >$dummy.c
579 #include <sys/systemcfg.h>
580
581 main()
582 {
583 if (!__power_pc())
584 exit(1);
585 puts("powerpc-ibm-aix3.2.5");
586 exit(0);
587 }
588 EOF
589 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
590 then
591 echo "$SYSTEM_NAME"
592 else
593 echo rs6000-ibm-aix3.2.5
594 fi
595 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
596 echo rs6000-ibm-aix3.2.4
597 else
598 echo rs6000-ibm-aix3.2
599 fi
600 exit ;;
601 *:AIX:*:[4567])
602 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
603 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
604 IBM_ARCH=rs6000
605 else
606 IBM_ARCH=powerpc
607 fi
608 if [ -x /usr/bin/lslpp ] ; then
609 IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
610 awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
611 else
612 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
613 fi
614 echo ${IBM_ARCH}-ibm-aix${IBM_REV}
615 exit ;;
616 *:AIX:*:*)
617 echo rs6000-ibm-aix
618 exit ;;
619 ibmrt:4.4BSD:*|romp-ibm:BSD:*)
620 echo romp-ibm-bsd4.4
621 exit ;;
622 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
623 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
624 exit ;; # report: romp-ibm BSD 4.3
625 *:BOSX:*:*)
626 echo rs6000-bull-bosx
627 exit ;;
628 DPX/2?00:B.O.S.:*:*)
629 echo m68k-bull-sysv3
630 exit ;;
631 9000/[34]??:4.3bsd:1.*:*)
632 echo m68k-hp-bsd
633 exit ;;
634 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
635 echo m68k-hp-bsd4.4
636 exit ;;
637 9000/[34678]??:HP-UX:*:*)
638 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
639 case "${UNAME_MACHINE}" in
640 9000/31? ) HP_ARCH=m68000 ;;
641 9000/[34]?? ) HP_ARCH=m68k ;;
642 9000/[678][0-9][0-9])
643 if [ -x /usr/bin/getconf ]; then
644 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
645 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
646 case "${sc_cpu_version}" in
647 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
648 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
649 532) # CPU_PA_RISC2_0
650 case "${sc_kernel_bits}" in
651 32) HP_ARCH=hppa2.0n ;;
652 64) HP_ARCH=hppa2.0w ;;
653 '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
654 esac ;;
655 esac
656 fi
657 if [ "${HP_ARCH}" = "" ]; then
658 eval $set_cc_for_build
659 sed 's/^ //' << EOF >$dummy.c
660
661 #define _HPUX_SOURCE
662 #include <stdlib.h>
663 #include <unistd.h>
664
665 int main ()
666 {
667 #if defined(_SC_KERNEL_BITS)
668 long bits = sysconf(_SC_KERNEL_BITS);
669 #endif
670 long cpu = sysconf (_SC_CPU_VERSION);
671
672 switch (cpu)
673 {
674 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
675 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
676 case CPU_PA_RISC2_0:
677 #if defined(_SC_KERNEL_BITS)
678 switch (bits)
679 {
680 case 64: puts ("hppa2.0w"); break;
681 case 32: puts ("hppa2.0n"); break;
682 default: puts ("hppa2.0"); break;
683 } break;
684 #else /* !defined(_SC_KERNEL_BITS) */
685 puts ("hppa2.0"); break;
686 #endif
687 default: puts ("hppa1.0"); break;
688 }
689 exit (0);
690 }
691 EOF
692 (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
693 test -z "$HP_ARCH" && HP_ARCH=hppa
694 fi ;;
695 esac
696 if [ ${HP_ARCH} = hppa2.0w ]
697 then
698 eval $set_cc_for_build
699
700 # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
701 # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
702 # generating 64-bit code. GNU and HP use different nomenclature:
703 #
704 # $ CC_FOR_BUILD=cc ./config.guess
705 # => hppa2.0w-hp-hpux11.23
706 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
707 # => hppa64-hp-hpux11.23
708
709 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
710 grep -q __LP64__
711 then
712 HP_ARCH=hppa2.0w
713 else
714 HP_ARCH=hppa64
715 fi
716 fi
717 echo ${HP_ARCH}-hp-hpux${HPUX_REV}
718 exit ;;
719 ia64:HP-UX:*:*)
720 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
721 echo ia64-hp-hpux${HPUX_REV}
722 exit ;;
723 3050*:HI-UX:*:*)
724 eval $set_cc_for_build
725 sed 's/^ //' << EOF >$dummy.c
726 #include <unistd.h>
727 int
728 main ()
729 {
730 long cpu = sysconf (_SC_CPU_VERSION);
731 /* The order matters, because CPU_IS_HP_MC68K erroneously returns
732 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
733 results, however. */
734 if (CPU_IS_PA_RISC (cpu))
735 {
736 switch (cpu)
737 {
738 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
739 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
740 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
741 default: puts ("hppa-hitachi-hiuxwe2"); break;
742 }
743 }
744 else if (CPU_IS_HP_MC68K (cpu))
745 puts ("m68k-hitachi-hiuxwe2");
746 else puts ("unknown-hitachi-hiuxwe2");
747 exit (0);
748 }
749 EOF
750 $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
751 { echo "$SYSTEM_NAME"; exit; }
752 echo unknown-hitachi-hiuxwe2
753 exit ;;
754 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
755 echo hppa1.1-hp-bsd
756 exit ;;
757 9000/8??:4.3bsd:*:*)
758 echo hppa1.0-hp-bsd
759 exit ;;
760 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
761 echo hppa1.0-hp-mpeix
762 exit ;;
763 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
764 echo hppa1.1-hp-osf
765 exit ;;
766 hp8??:OSF1:*:*)
767 echo hppa1.0-hp-osf
768 exit ;;
769 i*86:OSF1:*:*)
770 if [ -x /usr/sbin/sysversion ] ; then
771 echo ${UNAME_MACHINE}-unknown-osf1mk
772 else
773 echo ${UNAME_MACHINE}-unknown-osf1
774 fi
775 exit ;;
776 parisc*:Lites*:*:*)
777 echo hppa1.1-hp-lites
778 exit ;;
779 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
780 echo c1-convex-bsd
781 exit ;;
782 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
783 if getsysinfo -f scalar_acc
784 then echo c32-convex-bsd
785 else echo c2-convex-bsd
786 fi
787 exit ;;
788 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
789 echo c34-convex-bsd
790 exit ;;
791 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
792 echo c38-convex-bsd
793 exit ;;
794 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
795 echo c4-convex-bsd
796 exit ;;
797 CRAY*Y-MP:*:*:*)
798 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
799 exit ;;
800 CRAY*[A-Z]90:*:*:*)
801 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
802 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
803 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
804 -e 's/\.[^.]*$/.X/'
805 exit ;;
806 CRAY*TS:*:*:*)
807 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
808 exit ;;
809 CRAY*T3E:*:*:*)
810 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
811 exit ;;
812 CRAY*SV1:*:*:*)
813 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
814 exit ;;
815 *:UNICOS/mp:*:*)
816 echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
817 exit ;;
818 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
819 FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
820 FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
821 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
822 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
823 exit ;;
824 5000:UNIX_System_V:4.*:*)
825 FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
826 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
827 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
828 exit ;;
829 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
830 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
831 exit ;;
832 sparc*:BSD/OS:*:*)
833 echo sparc-unknown-bsdi${UNAME_RELEASE}
834 exit ;;
835 *:BSD/OS:*:*)
836 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
837 exit ;;
838 *:FreeBSD:*:*)
839 UNAME_PROCESSOR=`/usr/bin/uname -p`
840 case ${UNAME_PROCESSOR} in
841 amd64)
842 UNAME_PROCESSOR=x86_64 ;;
843 i386)
844 UNAME_PROCESSOR=i586 ;;
845 esac
846 echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
847 exit ;;
848 i*:CYGWIN*:*)
849 echo ${UNAME_MACHINE}-pc-cygwin
850 exit ;;
851 *:MINGW64*:*)
852 echo ${UNAME_MACHINE}-pc-mingw64
853 exit ;;
854 *:MINGW*:*)
855 echo ${UNAME_MACHINE}-pc-mingw32
856 exit ;;
857 *:MSYS*:*)
858 echo ${UNAME_MACHINE}-pc-msys
859 exit ;;
860 i*:windows32*:*)
861 # uname -m includes "-pc" on this system.
862 echo ${UNAME_MACHINE}-mingw32
863 exit ;;
864 i*:PW*:*)
865 echo ${UNAME_MACHINE}-pc-pw32
866 exit ;;
867 *:Interix*:*)
868 case ${UNAME_MACHINE} in
869 x86)
870 echo i586-pc-interix${UNAME_RELEASE}
871 exit ;;
872 authenticamd | genuineintel | EM64T)
873 echo x86_64-unknown-interix${UNAME_RELEASE}
874 exit ;;
875 IA64)
876 echo ia64-unknown-interix${UNAME_RELEASE}
877 exit ;;
878 esac ;;
879 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
880 echo i${UNAME_MACHINE}-pc-mks
881 exit ;;
882 8664:Windows_NT:*)
883 echo x86_64-pc-mks
884 exit ;;
885 i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
886 # How do we know it's Interix rather than the generic POSIX subsystem?
887 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
888 # UNAME_MACHINE based on the output of uname instead of i386?
889 echo i586-pc-interix
890 exit ;;
891 i*:UWIN*:*)
892 echo ${UNAME_MACHINE}-pc-uwin
893 exit ;;
894 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
895 echo x86_64-unknown-cygwin
896 exit ;;
897 p*:CYGWIN*:*)
898 echo powerpcle-unknown-cygwin
899 exit ;;
900 prep*:SunOS:5.*:*)
901 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
902 exit ;;
903 *:GNU:*:*)
904 # the GNU system
905 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
906 exit ;;
907 *:GNU/*:*:*)
908 # other systems with GNU libc and userland
909 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
910 exit ;;
911 i*86:Minix:*:*)
912 echo ${UNAME_MACHINE}-pc-minix
913 exit ;;
914 aarch64:Linux:*:*)
915 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
916 exit ;;
917 aarch64_be:Linux:*:*)
918 UNAME_MACHINE=aarch64_be
919 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
920 exit ;;
921 alpha:Linux:*:*)
922 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
923 EV5) UNAME_MACHINE=alphaev5 ;;
924 EV56) UNAME_MACHINE=alphaev56 ;;
925 PCA56) UNAME_MACHINE=alphapca56 ;;
926 PCA57) UNAME_MACHINE=alphapca56 ;;
927 EV6) UNAME_MACHINE=alphaev6 ;;
928 EV67) UNAME_MACHINE=alphaev67 ;;
929 EV68*) UNAME_MACHINE=alphaev68 ;;
930 esac
931 objdump --private-headers /bin/sh | grep -q ld.so.1
932 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
933 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
934 exit ;;
935 arc:Linux:*:* | arceb:Linux:*:*)
936 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
937 exit ;;
938 arm*:Linux:*:*)
939 eval $set_cc_for_build
940 if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
941 | grep -q __ARM_EABI__
942 then
943 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
944 else
945 if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
946 | grep -q __ARM_PCS_VFP
947 then
948 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
949 else
950 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
951 fi
952 fi
953 exit ;;
954 avr32*:Linux:*:*)
955 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
956 exit ;;
957 cris:Linux:*:*)
958 echo ${UNAME_MACHINE}-axis-linux-${LIBC}
959 exit ;;
960 crisv32:Linux:*:*)
961 echo ${UNAME_MACHINE}-axis-linux-${LIBC}
962 exit ;;
963 e2k:Linux:*:*)
964 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
965 exit ;;
966 frv:Linux:*:*)
967 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
968 exit ;;
969 hexagon:Linux:*:*)
970 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
971 exit ;;
972 i*86:Linux:*:*)
973 echo ${UNAME_MACHINE}-pc-linux-${LIBC}
974 exit ;;
975 ia64:Linux:*:*)
976 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
977 exit ;;
978 k1om:Linux:*:*)
979 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
980 exit ;;
981 m32r*:Linux:*:*)
982 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
983 exit ;;
984 m68*:Linux:*:*)
985 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
986 exit ;;
987 mips:Linux:*:* | mips64:Linux:*:*)
988 eval $set_cc_for_build
989 sed 's/^ //' << EOF >$dummy.c
990 #undef CPU
991 #undef ${UNAME_MACHINE}
992 #undef ${UNAME_MACHINE}el
993 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
994 CPU=${UNAME_MACHINE}el
995 #else
996 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
997 CPU=${UNAME_MACHINE}
998 #else
999 CPU=
1000 #endif
1001 #endif
1002 EOF
1003 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
1004 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
1005 ;;
1006 mips64el:Linux:*:*)
1007 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1008 exit ;;
1009 openrisc*:Linux:*:*)
1010 echo or1k-unknown-linux-${LIBC}
1011 exit ;;
1012 or32:Linux:*:* | or1k*:Linux:*:*)
1013 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1014 exit ;;
1015 padre:Linux:*:*)
1016 echo sparc-unknown-linux-${LIBC}
1017 exit ;;
1018 parisc64:Linux:*:* | hppa64:Linux:*:*)
1019 echo hppa64-unknown-linux-${LIBC}
1020 exit ;;
1021 parisc:Linux:*:* | hppa:Linux:*:*)
1022 # Look for CPU level
1023 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1024 PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
1025 PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
1026 *) echo hppa-unknown-linux-${LIBC} ;;
1027 esac
1028 exit ;;
1029 ppc64:Linux:*:*)
1030 echo powerpc64-unknown-linux-${LIBC}
1031 exit ;;
1032 ppc:Linux:*:*)
1033 echo powerpc-unknown-linux-${LIBC}
1034 exit ;;
1035 ppc64le:Linux:*:*)
1036 echo powerpc64le-unknown-linux-${LIBC}
1037 exit ;;
1038 ppcle:Linux:*:*)
1039 echo powerpcle-unknown-linux-${LIBC}
1040 exit ;;
1041 riscv32:Linux:*:* | riscv64:Linux:*:*)
1042 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1043 exit ;;
1044 s390:Linux:*:* | s390x:Linux:*:*)
1045 echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
1046 exit ;;
1047 sh64*:Linux:*:*)
1048 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1049 exit ;;
1050 sh*:Linux:*:*)
1051 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1052 exit ;;
1053 sparc:Linux:*:* | sparc64:Linux:*:*)
1054 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1055 exit ;;
1056 tile*:Linux:*:*)
1057 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1058 exit ;;
1059 vax:Linux:*:*)
1060 echo ${UNAME_MACHINE}-dec-linux-${LIBC}
1061 exit ;;
1062 x86_64:Linux:*:*)
1063 echo ${UNAME_MACHINE}-pc-linux-${LIBC}
1064 exit ;;
1065 xtensa*:Linux:*:*)
1066 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
1067 exit ;;
1068 i*86:DYNIX/ptx:4*:*)
1069 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1070 # earlier versions are messed up and put the nodename in both
1071 # sysname and nodename.
1072 echo i386-sequent-sysv4
1073 exit ;;
1074 i*86:UNIX_SV:4.2MP:2.*)
1075 # Unixware is an offshoot of SVR4, but it has its own version
1076 # number series starting with 2...
1077 # I am not positive that other SVR4 systems won't match this,
1078 # I just have to hope. -- rms.
1079 # Use sysv4.2uw... so that sysv4* matches it.
1080 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
1081 exit ;;
1082 i*86:OS/2:*:*)
1083 # If we were able to find `uname', then EMX Unix compatibility
1084 # is probably installed.
1085 echo ${UNAME_MACHINE}-pc-os2-emx
1086 exit ;;
1087 i*86:XTS-300:*:STOP)
1088 echo ${UNAME_MACHINE}-unknown-stop
1089 exit ;;
1090 i*86:atheos:*:*)
1091 echo ${UNAME_MACHINE}-unknown-atheos
1092 exit ;;
1093 i*86:syllable:*:*)
1094 echo ${UNAME_MACHINE}-pc-syllable
1095 exit ;;
1096 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1097 echo i386-unknown-lynxos${UNAME_RELEASE}
1098 exit ;;
1099 i*86:*DOS:*:*)
1100 echo ${UNAME_MACHINE}-pc-msdosdjgpp
1101 exit ;;
1102 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
1103 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1104 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1105 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
1106 else
1107 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1108 fi
1109 exit ;;
1110 i*86:*:5:[678]*)
1111 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1112 case `/bin/uname -X | grep "^Machine"` in
1113 *486*) UNAME_MACHINE=i486 ;;
1114 *Pentium) UNAME_MACHINE=i586 ;;
1115 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1116 esac
1117 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1118 exit ;;
1119 i*86:*:3.2:*)
1120 if test -f /usr/options/cb.name; then
1121 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1122 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1123 elif /bin/uname -X 2>/dev/null >/dev/null ; then
1124 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1125 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1126 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1127 && UNAME_MACHINE=i586
1128 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1129 && UNAME_MACHINE=i686
1130 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1131 && UNAME_MACHINE=i686
1132 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1133 else
1134 echo ${UNAME_MACHINE}-pc-sysv32
1135 fi
1136 exit ;;
1137 pc:*:*:*)
1138 # Left here for compatibility:
1139 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1140 # the processor, so we play safe by assuming i586.
1141 # Note: whatever this is, it MUST be the same as what config.sub
1142 # prints for the "djgpp" host, or else GDB configure will decide that
1143 # this is a cross-build.
1144 echo i586-pc-msdosdjgpp
1145 exit ;;
1146 Intel:Mach:3*:*)
1147 echo i386-pc-mach3
1148 exit ;;
1149 paragon:*:*:*)
1150 echo i860-intel-osf1
1151 exit ;;
1152 i860:*:4.*:*) # i860-SVR4
1153 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1154 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1155 else # Add other i860-SVR4 vendors below as they are discovered.
1156 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
1157 fi
1158 exit ;;
1159 mini*:CTIX:SYS*5:*)
1160 # "miniframe"
1161 echo m68010-convergent-sysv
1162 exit ;;
1163 mc68k:UNIX:SYSTEM5:3.51m)
1164 echo m68k-convergent-sysv
1165 exit ;;
1166 M680?0:D-NIX:5.3:*)
1167 echo m68k-diab-dnix
1168 exit ;;
1169 M68*:*:R3V[5678]*:*)
1170 test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1171 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)
1172 OS_REL=''
1173 test -r /etc/.relid \
1174 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1175 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1176 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1177 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1178 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1179 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1180 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1181 && { echo i486-ncr-sysv4; exit; } ;;
1182 NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1183 OS_REL='.3'
1184 test -r /etc/.relid \
1185 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1186 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1187 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1188 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1189 && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
1190 /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1191 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1192 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1193 echo m68k-unknown-lynxos${UNAME_RELEASE}
1194 exit ;;
1195 mc68030:UNIX_System_V:4.*:*)
1196 echo m68k-atari-sysv4
1197 exit ;;
1198 TSUNAMI:LynxOS:2.*:*)
1199 echo sparc-unknown-lynxos${UNAME_RELEASE}
1200 exit ;;
1201 rs6000:LynxOS:2.*:*)
1202 echo rs6000-unknown-lynxos${UNAME_RELEASE}
1203 exit ;;
1204 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1205 echo powerpc-unknown-lynxos${UNAME_RELEASE}
1206 exit ;;
1207 SM[BE]S:UNIX_SV:*:*)
1208 echo mips-dde-sysv${UNAME_RELEASE}
1209 exit ;;
1210 RM*:ReliantUNIX-*:*:*)
1211 echo mips-sni-sysv4
1212 exit ;;
1213 RM*:SINIX-*:*:*)
1214 echo mips-sni-sysv4
1215 exit ;;
1216 *:SINIX-*:*:*)
1217 if uname -p 2>/dev/null >/dev/null ; then
1218 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1219 echo ${UNAME_MACHINE}-sni-sysv4
1220 else
1221 echo ns32k-sni-sysv
1222 fi
1223 exit ;;
1224 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1225 # says <Richard.M.Bartel@ccMail.Census.GOV>
1226 echo i586-unisys-sysv4
1227 exit ;;
1228 *:UNIX_System_V:4*:FTX*)
1229 # From Gerald Hewes <hewes@openmarket.com>.
1230 # How about differentiating between stratus architectures? -djm
1231 echo hppa1.1-stratus-sysv4
1232 exit ;;
1233 *:*:*:FTX*)
1234 # From seanf@swdc.stratus.com.
1235 echo i860-stratus-sysv4
1236 exit ;;
1237 i*86:VOS:*:*)
1238 # From Paul.Green@stratus.com.
1239 echo ${UNAME_MACHINE}-stratus-vos
1240 exit ;;
1241 *:VOS:*:*)
1242 # From Paul.Green@stratus.com.
1243 echo hppa1.1-stratus-vos
1244 exit ;;
1245 mc68*:A/UX:*:*)
1246 echo m68k-apple-aux${UNAME_RELEASE}
1247 exit ;;
1248 news*:NEWS-OS:6*:*)
1249 echo mips-sony-newsos6
1250 exit ;;
1251 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1252 if [ -d /usr/nec ]; then
1253 echo mips-nec-sysv${UNAME_RELEASE}
1254 else
1255 echo mips-unknown-sysv${UNAME_RELEASE}
1256 fi
1257 exit ;;
1258 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1259 echo powerpc-be-beos
1260 exit ;;
1261 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1262 echo powerpc-apple-beos
1263 exit ;;
1264 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1265 echo i586-pc-beos
1266 exit ;;
1267 BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1268 echo i586-pc-haiku
1269 exit ;;
1270 x86_64:Haiku:*:*)
1271 echo x86_64-unknown-haiku
1272 exit ;;
1273 SX-4:SUPER-UX:*:*)
1274 echo sx4-nec-superux${UNAME_RELEASE}
1275 exit ;;
1276 SX-5:SUPER-UX:*:*)
1277 echo sx5-nec-superux${UNAME_RELEASE}
1278 exit ;;
1279 SX-6:SUPER-UX:*:*)
1280 echo sx6-nec-superux${UNAME_RELEASE}
1281 exit ;;
1282 SX-7:SUPER-UX:*:*)
1283 echo sx7-nec-superux${UNAME_RELEASE}
1284 exit ;;
1285 SX-8:SUPER-UX:*:*)
1286 echo sx8-nec-superux${UNAME_RELEASE}
1287 exit ;;
1288 SX-8R:SUPER-UX:*:*)
1289 echo sx8r-nec-superux${UNAME_RELEASE}
1290 exit ;;
1291 SX-ACE:SUPER-UX:*:*)
1292 echo sxace-nec-superux${UNAME_RELEASE}
1293 exit ;;
1294 Power*:Rhapsody:*:*)
1295 echo powerpc-apple-rhapsody${UNAME_RELEASE}
1296 exit ;;
1297 *:Rhapsody:*:*)
1298 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1299 exit ;;
1300 *:Darwin:*:*)
1301 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
1302 eval $set_cc_for_build
1303 if test "$UNAME_PROCESSOR" = unknown ; then
1304 UNAME_PROCESSOR=powerpc
1305 fi
1306 if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
1307 if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
1308 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1309 (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1310 grep IS_64BIT_ARCH >/dev/null
1311 then
1312 case $UNAME_PROCESSOR in
1313 i386) UNAME_PROCESSOR=x86_64 ;;
1314 powerpc) UNAME_PROCESSOR=powerpc64 ;;
1315 esac
1316 fi
1317 # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1318 if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1319 (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1320 grep IS_PPC >/dev/null
1321 then
1322 UNAME_PROCESSOR=powerpc
1323 fi
1324 fi
1325 elif test "$UNAME_PROCESSOR" = i386 ; then
1326 # Avoid executing cc on OS X 10.9, as it ships with a stub
1327 # that puts up a graphical alert prompting to install
1328 # developer tools. Any system running Mac OS X 10.7 or
1329 # later (Darwin 11 and later) is required to have a 64-bit
1330 # processor. This is not true of the ARM version of Darwin
1331 # that Apple uses in portable devices.
1332 UNAME_PROCESSOR=x86_64
1333 fi
1334 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1335 exit ;;
1336 *:procnto*:*:* | *:QNX:[0123456789]*:*)
1337 UNAME_PROCESSOR=`uname -p`
1338 if test "$UNAME_PROCESSOR" = x86; then
1339 UNAME_PROCESSOR=i386
1340 UNAME_MACHINE=pc
1341 fi
1342 echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1343 exit ;;
1344 *:QNX:*:4*)
1345 echo i386-pc-qnx
1346 exit ;;
1347 NEO-*:NONSTOP_KERNEL:*:*)
1348 echo neo-tandem-nsk${UNAME_RELEASE}
1349 exit ;;
1350 NSE-*:NONSTOP_KERNEL:*:*)
1351 echo nse-tandem-nsk${UNAME_RELEASE}
1352 exit ;;
1353 NSR-*:NONSTOP_KERNEL:*:*)
1354 echo nsr-tandem-nsk${UNAME_RELEASE}
1355 exit ;;
1356 NSX-*:NONSTOP_KERNEL:*:*)
1357 echo nsx-tandem-nsk${UNAME_RELEASE}
1358 exit ;;
1359 *:NonStop-UX:*:*)
1360 echo mips-compaq-nonstopux
1361 exit ;;
1362 BS2000:POSIX*:*:*)
1363 echo bs2000-siemens-sysv
1364 exit ;;
1365 DS/*:UNIX_System_V:*:*)
1366 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1367 exit ;;
1368 *:Plan9:*:*)
1369 # "uname -m" is not consistent, so use $cputype instead. 386
1370 # is converted to i386 for consistency with other x86
1371 # operating systems.
1372 if test "$cputype" = 386; then
1373 UNAME_MACHINE=i386
1374 else
1375 UNAME_MACHINE="$cputype"
1376 fi
1377 echo ${UNAME_MACHINE}-unknown-plan9
1378 exit ;;
1379 *:TOPS-10:*:*)
1380 echo pdp10-unknown-tops10
1381 exit ;;
1382 *:TENEX:*:*)
1383 echo pdp10-unknown-tenex
1384 exit ;;
1385 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1386 echo pdp10-dec-tops20
1387 exit ;;
1388 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1389 echo pdp10-xkl-tops20
1390 exit ;;
1391 *:TOPS-20:*:*)
1392 echo pdp10-unknown-tops20
1393 exit ;;
1394 *:ITS:*:*)
1395 echo pdp10-unknown-its
1396 exit ;;
1397 SEI:*:*:SEIUX)
1398 echo mips-sei-seiux${UNAME_RELEASE}
1399 exit ;;
1400 *:DragonFly:*:*)
1401 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
1402 exit ;;
1403 *:*VMS:*:*)
1404 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1405 case "${UNAME_MACHINE}" in
1406 A*) echo alpha-dec-vms ; exit ;;
1407 I*) echo ia64-dec-vms ; exit ;;
1408 V*) echo vax-dec-vms ; exit ;;
1409 esac ;;
1410 *:XENIX:*:SysV)
1411 echo i386-pc-xenix
1412 exit ;;
1413 i*86:skyos:*:*)
1414 echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'`
1415 exit ;;
1416 i*86:rdos:*:*)
1417 echo ${UNAME_MACHINE}-pc-rdos
1418 exit ;;
1419 i*86:AROS:*:*)
1420 echo ${UNAME_MACHINE}-pc-aros
1421 exit ;;
1422 x86_64:VMkernel:*:*)
1423 echo ${UNAME_MACHINE}-unknown-esx
1424 exit ;;
1425 amd64:Isilon\ OneFS:*:*)
1426 echo x86_64-unknown-onefs
1427 exit ;;
1428 esac
1429
1430 cat >&2 <<EOF
1431 $0: unable to guess system type
1432
1433 This script (version $timestamp), has failed to recognize the
1434 operating system you are using. If your script is old, overwrite *all*
1435 copies of config.guess and config.sub with the latest versions from:
1436
1437 http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
1438 and
1439 http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
1440
1441 If $0 has already been updated, send the following data and any
1442 information you think might be pertinent to config-patches@gnu.org to
1443 provide the necessary information to handle your system.
1444
1445 config.guess timestamp = $timestamp
1446
1447 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1448 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1449 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1450 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1451
1452 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1453 /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1454
1455 hostinfo = `(hostinfo) 2>/dev/null`
1456 /bin/universe = `(/bin/universe) 2>/dev/null`
1457 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1458 /bin/arch = `(/bin/arch) 2>/dev/null`
1459 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1460 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1461
1462 UNAME_MACHINE = ${UNAME_MACHINE}
1463 UNAME_RELEASE = ${UNAME_RELEASE}
1464 UNAME_SYSTEM = ${UNAME_SYSTEM}
1465 UNAME_VERSION = ${UNAME_VERSION}
1466 EOF
1467
1468 exit 1
1469
1470 # Local variables:
1471 # eval: (add-hook 'write-file-hooks 'time-stamp)
1472 # time-stamp-start: "timestamp='"
1473 # time-stamp-format: "%:y-%02m-%02d"
1474 # time-stamp-end: "'"
1475 # End:
+0
-1868
build-scripts/config.sub less more
0 #! /bin/sh
1 # Configuration validation subroutine script.
2 # Copyright 1992-2017 Free Software Foundation, Inc.
3
4 timestamp='2017-04-02'
5
6 # This file is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #
19 # As a special exception to the GNU General Public License, if you
20 # distribute this file as part of a program that contains a
21 # configuration script generated by Autoconf, you may include it under
22 # the same distribution terms that you use for the rest of that
23 # program. This Exception is an additional permission under section 7
24 # of the GNU General Public License, version 3 ("GPLv3").
25
26
27 # Please send patches to <config-patches@gnu.org>.
28 #
29 # Configuration subroutine to validate and canonicalize a configuration type.
30 # Supply the specified configuration type as an argument.
31 # If it is invalid, we print an error message on stderr and exit with code 1.
32 # Otherwise, we print the canonical config type on stdout and succeed.
33
34 # You can get the latest version of this script from:
35 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
36
37 # This file is supposed to be the same for all GNU packages
38 # and recognize all the CPU types, system types and aliases
39 # that are meaningful with *any* GNU software.
40 # Each package is responsible for reporting which valid configurations
41 # it does not support. The user should be able to distinguish
42 # a failure to support a valid configuration from a meaningless
43 # configuration.
44
45 # The goal of this file is to map all the various variations of a given
46 # machine specification into a single specification in the form:
47 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
48 # or in some cases, the newer four-part form:
49 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
50 # It is wrong to echo any other type of specification.
51
52 me=`echo "$0" | sed -e 's,.*/,,'`
53
54 usage="\
55 Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
56
57 Canonicalize a configuration name.
58
59 Operation modes:
60 -h, --help print this help, then exit
61 -t, --time-stamp print date of last modification, then exit
62 -v, --version print version number, then exit
63
64 Report bugs and patches to <config-patches@gnu.org>."
65
66 version="\
67 GNU config.sub ($timestamp)
68
69 Copyright 1992-2017 Free Software Foundation, Inc.
70
71 This is free software; see the source for copying conditions. There is NO
72 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
73
74 help="
75 Try \`$me --help' for more information."
76
77 # Parse command line
78 while test $# -gt 0 ; do
79 case $1 in
80 --time-stamp | --time* | -t )
81 echo "$timestamp" ; exit ;;
82 --version | -v )
83 echo "$version" ; exit ;;
84 --help | --h* | -h )
85 echo "$usage"; exit ;;
86 -- ) # Stop option processing
87 shift; break ;;
88 - ) # Use stdin as input.
89 break ;;
90 -* )
91 echo "$me: invalid option $1$help"
92 exit 1 ;;
93
94 *local*)
95 # First pass through any local machine types.
96 echo $1
97 exit ;;
98
99 * )
100 break ;;
101 esac
102 done
103
104 case $# in
105 0) echo "$me: missing argument$help" >&2
106 exit 1;;
107 1) ;;
108 *) echo "$me: too many arguments$help" >&2
109 exit 1;;
110 esac
111
112 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
113 # Here we must recognize all the valid KERNEL-OS combinations.
114 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
115 case $maybe_os in
116 nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
117 linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
118 knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
119 kopensolaris*-gnu* | cloudabi*-eabi* | \
120 storm-chaos* | os2-emx* | rtmk-nova*)
121 os=-$maybe_os
122 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
123 ;;
124 android-linux)
125 os=-linux-android
126 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
127 ;;
128 *)
129 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
130 if [ $basic_machine != $1 ]
131 then os=`echo $1 | sed 's/.*-/-/'`
132 else os=; fi
133 ;;
134 esac
135
136 ### Let's recognize common machines as not being operating systems so
137 ### that things like config.sub decstation-3100 work. We also
138 ### recognize some manufacturers as not being operating systems, so we
139 ### can provide default operating systems below.
140 case $os in
141 -sun*os*)
142 # Prevent following clause from handling this invalid input.
143 ;;
144 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
145 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
146 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
147 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
148 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
149 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
150 -apple | -axis | -knuth | -cray | -microblaze*)
151 os=
152 basic_machine=$1
153 ;;
154 -bluegene*)
155 os=-cnk
156 ;;
157 -sim | -cisco | -oki | -wec | -winbond)
158 os=
159 basic_machine=$1
160 ;;
161 -scout)
162 ;;
163 -wrs)
164 os=-vxworks
165 basic_machine=$1
166 ;;
167 -chorusos*)
168 os=-chorusos
169 basic_machine=$1
170 ;;
171 -chorusrdb)
172 os=-chorusrdb
173 basic_machine=$1
174 ;;
175 -hiux*)
176 os=-hiuxwe2
177 ;;
178 -sco6)
179 os=-sco5v6
180 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
181 ;;
182 -sco5)
183 os=-sco3.2v5
184 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
185 ;;
186 -sco4)
187 os=-sco3.2v4
188 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
189 ;;
190 -sco3.2.[4-9]*)
191 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
192 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
193 ;;
194 -sco3.2v[4-9]*)
195 # Don't forget version if it is 3.2v4 or newer.
196 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
197 ;;
198 -sco5v6*)
199 # Don't forget version if it is 3.2v4 or newer.
200 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
201 ;;
202 -sco*)
203 os=-sco3.2v2
204 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
205 ;;
206 -udk*)
207 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
208 ;;
209 -isc)
210 os=-isc2.2
211 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
212 ;;
213 -clix*)
214 basic_machine=clipper-intergraph
215 ;;
216 -isc*)
217 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
218 ;;
219 -lynx*178)
220 os=-lynxos178
221 ;;
222 -lynx*5)
223 os=-lynxos5
224 ;;
225 -lynx*)
226 os=-lynxos
227 ;;
228 -ptx*)
229 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
230 ;;
231 -windowsnt*)
232 os=`echo $os | sed -e 's/windowsnt/winnt/'`
233 ;;
234 -psos*)
235 os=-psos
236 ;;
237 -mint | -mint[0-9]*)
238 basic_machine=m68k-atari
239 os=-mint
240 ;;
241 esac
242
243 # Decode aliases for certain CPU-COMPANY combinations.
244 case $basic_machine in
245 # Recognize the basic CPU types without company name.
246 # Some are omitted here because they have special meanings below.
247 1750a | 580 \
248 | a29k \
249 | aarch64 | aarch64_be \
250 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
251 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
252 | am33_2.0 \
253 | arc | arceb \
254 | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
255 | avr | avr32 \
256 | ba \
257 | be32 | be64 \
258 | bfin \
259 | c4x | c8051 | clipper \
260 | d10v | d30v | dlx | dsp16xx \
261 | e2k | epiphany \
262 | fido | fr30 | frv | ft32 \
263 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
264 | hexagon \
265 | i370 | i860 | i960 | ia16 | ia64 \
266 | ip2k | iq2000 \
267 | k1om \
268 | le32 | le64 \
269 | lm32 \
270 | m32c | m32r | m32rle | m68000 | m68k | m88k \
271 | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
272 | mips | mipsbe | mipseb | mipsel | mipsle \
273 | mips16 \
274 | mips64 | mips64el \
275 | mips64octeon | mips64octeonel \
276 | mips64orion | mips64orionel \
277 | mips64r5900 | mips64r5900el \
278 | mips64vr | mips64vrel \
279 | mips64vr4100 | mips64vr4100el \
280 | mips64vr4300 | mips64vr4300el \
281 | mips64vr5000 | mips64vr5000el \
282 | mips64vr5900 | mips64vr5900el \
283 | mipsisa32 | mipsisa32el \
284 | mipsisa32r2 | mipsisa32r2el \
285 | mipsisa32r6 | mipsisa32r6el \
286 | mipsisa64 | mipsisa64el \
287 | mipsisa64r2 | mipsisa64r2el \
288 | mipsisa64r6 | mipsisa64r6el \
289 | mipsisa64sb1 | mipsisa64sb1el \
290 | mipsisa64sr71k | mipsisa64sr71kel \
291 | mipsr5900 | mipsr5900el \
292 | mipstx39 | mipstx39el \
293 | mn10200 | mn10300 \
294 | moxie \
295 | mt \
296 | msp430 \
297 | nds32 | nds32le | nds32be \
298 | nios | nios2 | nios2eb | nios2el \
299 | ns16k | ns32k \
300 | open8 | or1k | or1knd | or32 \
301 | pdp10 | pdp11 | pj | pjl \
302 | powerpc | powerpc64 | powerpc64le | powerpcle \
303 | pru \
304 | pyramid \
305 | riscv32 | riscv64 \
306 | rl78 | rx \
307 | score \
308 | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
309 | sh64 | sh64le \
310 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
311 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
312 | spu \
313 | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
314 | ubicom32 \
315 | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
316 | visium \
317 | wasm32 \
318 | we32k \
319 | x86 | xc16x | xstormy16 | xtensa \
320 | z8k | z80)
321 basic_machine=$basic_machine-unknown
322 ;;
323 c54x)
324 basic_machine=tic54x-unknown
325 ;;
326 c55x)
327 basic_machine=tic55x-unknown
328 ;;
329 c6x)
330 basic_machine=tic6x-unknown
331 ;;
332 leon|leon[3-9])
333 basic_machine=sparc-$basic_machine
334 ;;
335 m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
336 basic_machine=$basic_machine-unknown
337 os=-none
338 ;;
339 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
340 ;;
341 ms1)
342 basic_machine=mt-unknown
343 ;;
344
345 strongarm | thumb | xscale)
346 basic_machine=arm-unknown
347 ;;
348 xgate)
349 basic_machine=$basic_machine-unknown
350 os=-none
351 ;;
352 xscaleeb)
353 basic_machine=armeb-unknown
354 ;;
355
356 xscaleel)
357 basic_machine=armel-unknown
358 ;;
359
360 # We use `pc' rather than `unknown'
361 # because (1) that's what they normally are, and
362 # (2) the word "unknown" tends to confuse beginning users.
363 i*86 | x86_64)
364 basic_machine=$basic_machine-pc
365 ;;
366 nacl64*)
367 basic_machine=x86_64-pc
368 os=-nacl
369 ;;
370 nacl*)
371 basic_machine=i686-pc
372 os=-nacl
373 ;;
374 pnacl*)
375 # le32-unknown-pnacl comes from http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
376 basic_machine=le32-unknown
377 os=-pnacl
378 ;;
379 # Object if more than one company name word.
380 *-*-*)
381 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
382 exit 1
383 ;;
384 # Recognize the basic CPU types with company name.
385 580-* \
386 | a29k-* \
387 | aarch64-* | aarch64_be-* \
388 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
389 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
390 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
391 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
392 | avr-* | avr32-* \
393 | ba-* \
394 | be32-* | be64-* \
395 | bfin-* | bs2000-* \
396 | c[123]* | c30-* | [cjt]90-* | c4x-* \
397 | c8051-* | clipper-* | craynv-* | cydra-* \
398 | d10v-* | d30v-* | dlx-* \
399 | e2k-* | elxsi-* \
400 | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
401 | h8300-* | h8500-* \
402 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
403 | hexagon-* \
404 | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
405 | ip2k-* | iq2000-* \
406 | k1om-* \
407 | le32-* | le64-* \
408 | lm32-* \
409 | m32c-* | m32r-* | m32rle-* \
410 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
411 | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
412 | microblaze-* | microblazeel-* \
413 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
414 | mips16-* \
415 | mips64-* | mips64el-* \
416 | mips64octeon-* | mips64octeonel-* \
417 | mips64orion-* | mips64orionel-* \
418 | mips64r5900-* | mips64r5900el-* \
419 | mips64vr-* | mips64vrel-* \
420 | mips64vr4100-* | mips64vr4100el-* \
421 | mips64vr4300-* | mips64vr4300el-* \
422 | mips64vr5000-* | mips64vr5000el-* \
423 | mips64vr5900-* | mips64vr5900el-* \
424 | mipsisa32-* | mipsisa32el-* \
425 | mipsisa32r2-* | mipsisa32r2el-* \
426 | mipsisa32r6-* | mipsisa32r6el-* \
427 | mipsisa64-* | mipsisa64el-* \
428 | mipsisa64r2-* | mipsisa64r2el-* \
429 | mipsisa64r6-* | mipsisa64r6el-* \
430 | mipsisa64sb1-* | mipsisa64sb1el-* \
431 | mipsisa64sr71k-* | mipsisa64sr71kel-* \
432 | mipsr5900-* | mipsr5900el-* \
433 | mipstx39-* | mipstx39el-* \
434 | mmix-* \
435 | mt-* \
436 | msp430-* \
437 | nds32-* | nds32le-* | nds32be-* \
438 | nios-* | nios2-* | nios2eb-* | nios2el-* \
439 | none-* | np1-* | ns16k-* | ns32k-* \
440 | open8-* \
441 | or1k*-* \
442 | orion-* \
443 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
444 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
445 | pru-* \
446 | pyramid-* \
447 | riscv32-* | riscv64-* \
448 | rl78-* | romp-* | rs6000-* | rx-* \
449 | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
450 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
451 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
452 | sparclite-* \
453 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
454 | tahoe-* \
455 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
456 | tile*-* \
457 | tron-* \
458 | ubicom32-* \
459 | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
460 | vax-* \
461 | visium-* \
462 | wasm32-* \
463 | we32k-* \
464 | x86-* | x86_64-* | xc16x-* | xps100-* \
465 | xstormy16-* | xtensa*-* \
466 | ymp-* \
467 | z8k-* | z80-*)
468 ;;
469 # Recognize the basic CPU types without company name, with glob match.
470 xtensa*)
471 basic_machine=$basic_machine-unknown
472 ;;
473 # Recognize the various machine names and aliases which stand
474 # for a CPU type and a company and sometimes even an OS.
475 386bsd)
476 basic_machine=i386-unknown
477 os=-bsd
478 ;;
479 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
480 basic_machine=m68000-att
481 ;;
482 3b*)
483 basic_machine=we32k-att
484 ;;
485 a29khif)
486 basic_machine=a29k-amd
487 os=-udi
488 ;;
489 abacus)
490 basic_machine=abacus-unknown
491 ;;
492 adobe68k)
493 basic_machine=m68010-adobe
494 os=-scout
495 ;;
496 alliant | fx80)
497 basic_machine=fx80-alliant
498 ;;
499 altos | altos3068)
500 basic_machine=m68k-altos
501 ;;
502 am29k)
503 basic_machine=a29k-none
504 os=-bsd
505 ;;
506 amd64)
507 basic_machine=x86_64-pc
508 ;;
509 amd64-*)
510 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
511 ;;
512 amdahl)
513 basic_machine=580-amdahl
514 os=-sysv
515 ;;
516 amiga | amiga-*)
517 basic_machine=m68k-unknown
518 ;;
519 amigaos | amigados)
520 basic_machine=m68k-unknown
521 os=-amigaos
522 ;;
523 amigaunix | amix)
524 basic_machine=m68k-unknown
525 os=-sysv4
526 ;;
527 apollo68)
528 basic_machine=m68k-apollo
529 os=-sysv
530 ;;
531 apollo68bsd)
532 basic_machine=m68k-apollo
533 os=-bsd
534 ;;
535 aros)
536 basic_machine=i386-pc
537 os=-aros
538 ;;
539 asmjs)
540 basic_machine=asmjs-unknown
541 ;;
542 aux)
543 basic_machine=m68k-apple
544 os=-aux
545 ;;
546 balance)
547 basic_machine=ns32k-sequent
548 os=-dynix
549 ;;
550 blackfin)
551 basic_machine=bfin-unknown
552 os=-linux
553 ;;
554 blackfin-*)
555 basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
556 os=-linux
557 ;;
558 bluegene*)
559 basic_machine=powerpc-ibm
560 os=-cnk
561 ;;
562 c54x-*)
563 basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
564 ;;
565 c55x-*)
566 basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
567 ;;
568 c6x-*)
569 basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
570 ;;
571 c90)
572 basic_machine=c90-cray
573 os=-unicos
574 ;;
575 cegcc)
576 basic_machine=arm-unknown
577 os=-cegcc
578 ;;
579 convex-c1)
580 basic_machine=c1-convex
581 os=-bsd
582 ;;
583 convex-c2)
584 basic_machine=c2-convex
585 os=-bsd
586 ;;
587 convex-c32)
588 basic_machine=c32-convex
589 os=-bsd
590 ;;
591 convex-c34)
592 basic_machine=c34-convex
593 os=-bsd
594 ;;
595 convex-c38)
596 basic_machine=c38-convex
597 os=-bsd
598 ;;
599 cray | j90)
600 basic_machine=j90-cray
601 os=-unicos
602 ;;
603 craynv)
604 basic_machine=craynv-cray
605 os=-unicosmp
606 ;;
607 cr16 | cr16-*)
608 basic_machine=cr16-unknown
609 os=-elf
610 ;;
611 crds | unos)
612 basic_machine=m68k-crds
613 ;;
614 crisv32 | crisv32-* | etraxfs*)
615 basic_machine=crisv32-axis
616 ;;
617 cris | cris-* | etrax*)
618 basic_machine=cris-axis
619 ;;
620 crx)
621 basic_machine=crx-unknown
622 os=-elf
623 ;;
624 da30 | da30-*)
625 basic_machine=m68k-da30
626 ;;
627 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
628 basic_machine=mips-dec
629 ;;
630 decsystem10* | dec10*)
631 basic_machine=pdp10-dec
632 os=-tops10
633 ;;
634 decsystem20* | dec20*)
635 basic_machine=pdp10-dec
636 os=-tops20
637 ;;
638 delta | 3300 | motorola-3300 | motorola-delta \
639 | 3300-motorola | delta-motorola)
640 basic_machine=m68k-motorola
641 ;;
642 delta88)
643 basic_machine=m88k-motorola
644 os=-sysv3
645 ;;
646 dicos)
647 basic_machine=i686-pc
648 os=-dicos
649 ;;
650 djgpp)
651 basic_machine=i586-pc
652 os=-msdosdjgpp
653 ;;
654 dpx20 | dpx20-*)
655 basic_machine=rs6000-bull
656 os=-bosx
657 ;;
658 dpx2* | dpx2*-bull)
659 basic_machine=m68k-bull
660 os=-sysv3
661 ;;
662 e500v[12])
663 basic_machine=powerpc-unknown
664 os=$os"spe"
665 ;;
666 e500v[12]-*)
667 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
668 os=$os"spe"
669 ;;
670 ebmon29k)
671 basic_machine=a29k-amd
672 os=-ebmon
673 ;;
674 elxsi)
675 basic_machine=elxsi-elxsi
676 os=-bsd
677 ;;
678 encore | umax | mmax)
679 basic_machine=ns32k-encore
680 ;;
681 es1800 | OSE68k | ose68k | ose | OSE)
682 basic_machine=m68k-ericsson
683 os=-ose
684 ;;
685 fx2800)
686 basic_machine=i860-alliant
687 ;;
688 genix)
689 basic_machine=ns32k-ns
690 ;;
691 gmicro)
692 basic_machine=tron-gmicro
693 os=-sysv
694 ;;
695 go32)
696 basic_machine=i386-pc
697 os=-go32
698 ;;
699 h3050r* | hiux*)
700 basic_machine=hppa1.1-hitachi
701 os=-hiuxwe2
702 ;;
703 h8300hms)
704 basic_machine=h8300-hitachi
705 os=-hms
706 ;;
707 h8300xray)
708 basic_machine=h8300-hitachi
709 os=-xray
710 ;;
711 h8500hms)
712 basic_machine=h8500-hitachi
713 os=-hms
714 ;;
715 harris)
716 basic_machine=m88k-harris
717 os=-sysv3
718 ;;
719 hp300-*)
720 basic_machine=m68k-hp
721 ;;
722 hp300bsd)
723 basic_machine=m68k-hp
724 os=-bsd
725 ;;
726 hp300hpux)
727 basic_machine=m68k-hp
728 os=-hpux
729 ;;
730 hp3k9[0-9][0-9] | hp9[0-9][0-9])
731 basic_machine=hppa1.0-hp
732 ;;
733 hp9k2[0-9][0-9] | hp9k31[0-9])
734 basic_machine=m68000-hp
735 ;;
736 hp9k3[2-9][0-9])
737 basic_machine=m68k-hp
738 ;;
739 hp9k6[0-9][0-9] | hp6[0-9][0-9])
740 basic_machine=hppa1.0-hp
741 ;;
742 hp9k7[0-79][0-9] | hp7[0-79][0-9])
743 basic_machine=hppa1.1-hp
744 ;;
745 hp9k78[0-9] | hp78[0-9])
746 # FIXME: really hppa2.0-hp
747 basic_machine=hppa1.1-hp
748 ;;
749 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
750 # FIXME: really hppa2.0-hp
751 basic_machine=hppa1.1-hp
752 ;;
753 hp9k8[0-9][13679] | hp8[0-9][13679])
754 basic_machine=hppa1.1-hp
755 ;;
756 hp9k8[0-9][0-9] | hp8[0-9][0-9])
757 basic_machine=hppa1.0-hp
758 ;;
759 hppa-next)
760 os=-nextstep3
761 ;;
762 hppaosf)
763 basic_machine=hppa1.1-hp
764 os=-osf
765 ;;
766 hppro)
767 basic_machine=hppa1.1-hp
768 os=-proelf
769 ;;
770 i370-ibm* | ibm*)
771 basic_machine=i370-ibm
772 ;;
773 i*86v32)
774 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
775 os=-sysv32
776 ;;
777 i*86v4*)
778 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
779 os=-sysv4
780 ;;
781 i*86v)
782 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
783 os=-sysv
784 ;;
785 i*86sol2)
786 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
787 os=-solaris2
788 ;;
789 i386mach)
790 basic_machine=i386-mach
791 os=-mach
792 ;;
793 i386-vsta | vsta)
794 basic_machine=i386-unknown
795 os=-vsta
796 ;;
797 iris | iris4d)
798 basic_machine=mips-sgi
799 case $os in
800 -irix*)
801 ;;
802 *)
803 os=-irix4
804 ;;
805 esac
806 ;;
807 isi68 | isi)
808 basic_machine=m68k-isi
809 os=-sysv
810 ;;
811 leon-*|leon[3-9]-*)
812 basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
813 ;;
814 m68knommu)
815 basic_machine=m68k-unknown
816 os=-linux
817 ;;
818 m68knommu-*)
819 basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
820 os=-linux
821 ;;
822 m88k-omron*)
823 basic_machine=m88k-omron
824 ;;
825 magnum | m3230)
826 basic_machine=mips-mips
827 os=-sysv
828 ;;
829 merlin)
830 basic_machine=ns32k-utek
831 os=-sysv
832 ;;
833 microblaze*)
834 basic_machine=microblaze-xilinx
835 ;;
836 mingw64)
837 basic_machine=x86_64-pc
838 os=-mingw64
839 ;;
840 mingw32)
841 basic_machine=i686-pc
842 os=-mingw32
843 ;;
844 mingw32ce)
845 basic_machine=arm-unknown
846 os=-mingw32ce
847 ;;
848 miniframe)
849 basic_machine=m68000-convergent
850 ;;
851 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
852 basic_machine=m68k-atari
853 os=-mint
854 ;;
855 mips3*-*)
856 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
857 ;;
858 mips3*)
859 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
860 ;;
861 monitor)
862 basic_machine=m68k-rom68k
863 os=-coff
864 ;;
865 morphos)
866 basic_machine=powerpc-unknown
867 os=-morphos
868 ;;
869 moxiebox)
870 basic_machine=moxie-unknown
871 os=-moxiebox
872 ;;
873 msdos)
874 basic_machine=i386-pc
875 os=-msdos
876 ;;
877 ms1-*)
878 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
879 ;;
880 msys)
881 basic_machine=i686-pc
882 os=-msys
883 ;;
884 mvs)
885 basic_machine=i370-ibm
886 os=-mvs
887 ;;
888 nacl)
889 basic_machine=le32-unknown
890 os=-nacl
891 ;;
892 pnacl)
893 basic_machine=le32-unknown
894 os=-pnacl
895 ;;
896 ncr3000)
897 basic_machine=i486-ncr
898 os=-sysv4
899 ;;
900 netbsd386)
901 basic_machine=i386-unknown
902 os=-netbsd
903 ;;
904 netwinder)
905 basic_machine=armv4l-rebel
906 os=-linux
907 ;;
908 news | news700 | news800 | news900)
909 basic_machine=m68k-sony
910 os=-newsos
911 ;;
912 news1000)
913 basic_machine=m68030-sony
914 os=-newsos
915 ;;
916 news-3600 | risc-news)
917 basic_machine=mips-sony
918 os=-newsos
919 ;;
920 necv70)
921 basic_machine=v70-nec
922 os=-sysv
923 ;;
924 next | m*-next )
925 basic_machine=m68k-next
926 case $os in
927 -nextstep* )
928 ;;
929 -ns2*)
930 os=-nextstep2
931 ;;
932 *)
933 os=-nextstep3
934 ;;
935 esac
936 ;;
937 nh3000)
938 basic_machine=m68k-harris
939 os=-cxux
940 ;;
941 nh[45]000)
942 basic_machine=m88k-harris
943 os=-cxux
944 ;;
945 nindy960)
946 basic_machine=i960-intel
947 os=-nindy
948 ;;
949 mon960)
950 basic_machine=i960-intel
951 os=-mon960
952 ;;
953 nonstopux)
954 basic_machine=mips-compaq
955 os=-nonstopux
956 ;;
957 np1)
958 basic_machine=np1-gould
959 ;;
960 neo-tandem)
961 basic_machine=neo-tandem
962 ;;
963 nse-tandem)
964 basic_machine=nse-tandem
965 ;;
966 nsr-tandem)
967 basic_machine=nsr-tandem
968 ;;
969 nsx-tandem)
970 basic_machine=nsx-tandem
971 ;;
972 op50n-* | op60c-*)
973 basic_machine=hppa1.1-oki
974 os=-proelf
975 ;;
976 openrisc | openrisc-*)
977 basic_machine=or32-unknown
978 ;;
979 os400)
980 basic_machine=powerpc-ibm
981 os=-os400
982 ;;
983 OSE68000 | ose68000)
984 basic_machine=m68000-ericsson
985 os=-ose
986 ;;
987 os68k)
988 basic_machine=m68k-none
989 os=-os68k
990 ;;
991 pa-hitachi)
992 basic_machine=hppa1.1-hitachi
993 os=-hiuxwe2
994 ;;
995 paragon)
996 basic_machine=i860-intel
997 os=-osf
998 ;;
999 parisc)
1000 basic_machine=hppa-unknown
1001 os=-linux
1002 ;;
1003 parisc-*)
1004 basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
1005 os=-linux
1006 ;;
1007 pbd)
1008 basic_machine=sparc-tti
1009 ;;
1010 pbb)
1011 basic_machine=m68k-tti
1012 ;;
1013 pc532 | pc532-*)
1014 basic_machine=ns32k-pc532
1015 ;;
1016 pc98)
1017 basic_machine=i386-pc
1018 ;;
1019 pc98-*)
1020 basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
1021 ;;
1022 pentium | p5 | k5 | k6 | nexgen | viac3)
1023 basic_machine=i586-pc
1024 ;;
1025 pentiumpro | p6 | 6x86 | athlon | athlon_*)
1026 basic_machine=i686-pc
1027 ;;
1028 pentiumii | pentium2 | pentiumiii | pentium3)
1029 basic_machine=i686-pc
1030 ;;
1031 pentium4)
1032 basic_machine=i786-pc
1033 ;;
1034 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1035 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
1036 ;;
1037 pentiumpro-* | p6-* | 6x86-* | athlon-*)
1038 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
1039 ;;
1040 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1041 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
1042 ;;
1043 pentium4-*)
1044 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
1045 ;;
1046 pn)
1047 basic_machine=pn-gould
1048 ;;
1049 power) basic_machine=power-ibm
1050 ;;
1051 ppc | ppcbe) basic_machine=powerpc-unknown
1052 ;;
1053 ppc-* | ppcbe-*)
1054 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
1055 ;;
1056 ppcle | powerpclittle)
1057 basic_machine=powerpcle-unknown
1058 ;;
1059 ppcle-* | powerpclittle-*)
1060 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
1061 ;;
1062 ppc64) basic_machine=powerpc64-unknown
1063 ;;
1064 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
1065 ;;
1066 ppc64le | powerpc64little)
1067 basic_machine=powerpc64le-unknown
1068 ;;
1069 ppc64le-* | powerpc64little-*)
1070 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
1071 ;;
1072 ps2)
1073 basic_machine=i386-ibm
1074 ;;
1075 pw32)
1076 basic_machine=i586-unknown
1077 os=-pw32
1078 ;;
1079 rdos | rdos64)
1080 basic_machine=x86_64-pc
1081 os=-rdos
1082 ;;
1083 rdos32)
1084 basic_machine=i386-pc
1085 os=-rdos
1086 ;;
1087 rom68k)
1088 basic_machine=m68k-rom68k
1089 os=-coff
1090 ;;
1091 rm[46]00)
1092 basic_machine=mips-siemens
1093 ;;
1094 rtpc | rtpc-*)
1095 basic_machine=romp-ibm
1096 ;;
1097 s390 | s390-*)
1098 basic_machine=s390-ibm
1099 ;;
1100 s390x | s390x-*)
1101 basic_machine=s390x-ibm
1102 ;;
1103 sa29200)
1104 basic_machine=a29k-amd
1105 os=-udi
1106 ;;
1107 sb1)
1108 basic_machine=mipsisa64sb1-unknown
1109 ;;
1110 sb1el)
1111 basic_machine=mipsisa64sb1el-unknown
1112 ;;
1113 sde)
1114 basic_machine=mipsisa32-sde
1115 os=-elf
1116 ;;
1117 sei)
1118 basic_machine=mips-sei
1119 os=-seiux
1120 ;;
1121 sequent)
1122 basic_machine=i386-sequent
1123 ;;
1124 sh)
1125 basic_machine=sh-hitachi
1126 os=-hms
1127 ;;
1128 sh5el)
1129 basic_machine=sh5le-unknown
1130 ;;
1131 sh64)
1132 basic_machine=sh64-unknown
1133 ;;
1134 sparclite-wrs | simso-wrs)
1135 basic_machine=sparclite-wrs
1136 os=-vxworks
1137 ;;
1138 sps7)
1139 basic_machine=m68k-bull
1140 os=-sysv2
1141 ;;
1142 spur)
1143 basic_machine=spur-unknown
1144 ;;
1145 st2000)
1146 basic_machine=m68k-tandem
1147 ;;
1148 stratus)
1149 basic_machine=i860-stratus
1150 os=-sysv4
1151 ;;
1152 strongarm-* | thumb-*)
1153 basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
1154 ;;
1155 sun2)
1156 basic_machine=m68000-sun
1157 ;;
1158 sun2os3)
1159 basic_machine=m68000-sun
1160 os=-sunos3
1161 ;;
1162 sun2os4)
1163 basic_machine=m68000-sun
1164 os=-sunos4
1165 ;;
1166 sun3os3)
1167 basic_machine=m68k-sun
1168 os=-sunos3
1169 ;;
1170 sun3os4)
1171 basic_machine=m68k-sun
1172 os=-sunos4
1173 ;;
1174 sun4os3)
1175 basic_machine=sparc-sun
1176 os=-sunos3
1177 ;;
1178 sun4os4)
1179 basic_machine=sparc-sun
1180 os=-sunos4
1181 ;;
1182 sun4sol2)
1183 basic_machine=sparc-sun
1184 os=-solaris2
1185 ;;
1186 sun3 | sun3-*)
1187 basic_machine=m68k-sun
1188 ;;
1189 sun4)
1190 basic_machine=sparc-sun
1191 ;;
1192 sun386 | sun386i | roadrunner)
1193 basic_machine=i386-sun
1194 ;;
1195 sv1)
1196 basic_machine=sv1-cray
1197 os=-unicos
1198 ;;
1199 symmetry)
1200 basic_machine=i386-sequent
1201 os=-dynix
1202 ;;
1203 t3e)
1204 basic_machine=alphaev5-cray
1205 os=-unicos
1206 ;;
1207 t90)
1208 basic_machine=t90-cray
1209 os=-unicos
1210 ;;
1211 tile*)
1212 basic_machine=$basic_machine-unknown
1213 os=-linux-gnu
1214 ;;
1215 tx39)
1216 basic_machine=mipstx39-unknown
1217 ;;
1218 tx39el)
1219 basic_machine=mipstx39el-unknown
1220 ;;
1221 toad1)
1222 basic_machine=pdp10-xkl
1223 os=-tops20
1224 ;;
1225 tower | tower-32)
1226 basic_machine=m68k-ncr
1227 ;;
1228 tpf)
1229 basic_machine=s390x-ibm
1230 os=-tpf
1231 ;;
1232 udi29k)
1233 basic_machine=a29k-amd
1234 os=-udi
1235 ;;
1236 ultra3)
1237 basic_machine=a29k-nyu
1238 os=-sym1
1239 ;;
1240 v810 | necv810)
1241 basic_machine=v810-nec
1242 os=-none
1243 ;;
1244 vaxv)
1245 basic_machine=vax-dec
1246 os=-sysv
1247 ;;
1248 vms)
1249 basic_machine=vax-dec
1250 os=-vms
1251 ;;
1252 vpp*|vx|vx-*)
1253 basic_machine=f301-fujitsu
1254 ;;
1255 vxworks960)
1256 basic_machine=i960-wrs
1257 os=-vxworks
1258 ;;
1259 vxworks68)
1260 basic_machine=m68k-wrs
1261 os=-vxworks
1262 ;;
1263 vxworks29k)
1264 basic_machine=a29k-wrs
1265 os=-vxworks
1266 ;;
1267 wasm32)
1268 basic_machine=wasm32-unknown
1269 ;;
1270 w65*)
1271 basic_machine=w65-wdc
1272 os=-none
1273 ;;
1274 w89k-*)
1275 basic_machine=hppa1.1-winbond
1276 os=-proelf
1277 ;;
1278 xbox)
1279 basic_machine=i686-pc
1280 os=-mingw32
1281 ;;
1282 xps | xps100)
1283 basic_machine=xps100-honeywell
1284 ;;
1285 xscale-* | xscalee[bl]-*)
1286 basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
1287 ;;
1288 ymp)
1289 basic_machine=ymp-cray
1290 os=-unicos
1291 ;;
1292 z8k-*-coff)
1293 basic_machine=z8k-unknown
1294 os=-sim
1295 ;;
1296 z80-*-coff)
1297 basic_machine=z80-unknown
1298 os=-sim
1299 ;;
1300 none)
1301 basic_machine=none-none
1302 os=-none
1303 ;;
1304
1305 # Here we handle the default manufacturer of certain CPU types. It is in
1306 # some cases the only manufacturer, in others, it is the most popular.
1307 w89k)
1308 basic_machine=hppa1.1-winbond
1309 ;;
1310 op50n)
1311 basic_machine=hppa1.1-oki
1312 ;;
1313 op60c)
1314 basic_machine=hppa1.1-oki
1315 ;;
1316 romp)
1317 basic_machine=romp-ibm
1318 ;;
1319 mmix)
1320 basic_machine=mmix-knuth
1321 ;;
1322 rs6000)
1323 basic_machine=rs6000-ibm
1324 ;;
1325 vax)
1326 basic_machine=vax-dec
1327 ;;
1328 pdp10)
1329 # there are many clones, so DEC is not a safe bet
1330 basic_machine=pdp10-unknown
1331 ;;
1332 pdp11)
1333 basic_machine=pdp11-dec
1334 ;;
1335 we32k)
1336 basic_machine=we32k-att
1337 ;;
1338 sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
1339 basic_machine=sh-unknown
1340 ;;
1341 sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
1342 basic_machine=sparc-sun
1343 ;;
1344 cydra)
1345 basic_machine=cydra-cydrome
1346 ;;
1347 orion)
1348 basic_machine=orion-highlevel
1349 ;;
1350 orion105)
1351 basic_machine=clipper-highlevel
1352 ;;
1353 mac | mpw | mac-mpw)
1354 basic_machine=m68k-apple
1355 ;;
1356 pmac | pmac-mpw)
1357 basic_machine=powerpc-apple
1358 ;;
1359 *-unknown)
1360 # Make sure to match an already-canonicalized machine name.
1361 ;;
1362 *)
1363 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
1364 exit 1
1365 ;;
1366 esac
1367
1368 # Here we canonicalize certain aliases for manufacturers.
1369 case $basic_machine in
1370 *-digital*)
1371 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
1372 ;;
1373 *-commodore*)
1374 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
1375 ;;
1376 *)
1377 ;;
1378 esac
1379
1380 # Decode manufacturer-specific aliases for certain operating systems.
1381
1382 if [ x"$os" != x"" ]
1383 then
1384 case $os in
1385 # First match some system type aliases
1386 # that might get confused with valid system types.
1387 # -solaris* is a basic system type, with this one exception.
1388 -auroraux)
1389 os=-auroraux
1390 ;;
1391 -solaris1 | -solaris1.*)
1392 os=`echo $os | sed -e 's|solaris1|sunos4|'`
1393 ;;
1394 -solaris)
1395 os=-solaris2
1396 ;;
1397 -svr4*)
1398 os=-sysv4
1399 ;;
1400 -unixware*)
1401 os=-sysv4.2uw
1402 ;;
1403 -gnu/linux*)
1404 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
1405 ;;
1406 # First accept the basic system types.
1407 # The portable systems comes first.
1408 # Each alternative MUST END IN A *, to match a version number.
1409 # -sysv* is not here because it comes later, after sysvr4.
1410 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
1411 | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
1412 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
1413 | -sym* | -kopensolaris* | -plan9* \
1414 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
1415 | -aos* | -aros* | -cloudabi* | -sortix* \
1416 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
1417 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
1418 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
1419 | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
1420 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
1421 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
1422 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
1423 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
1424 | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
1425 | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1426 | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
1427 | -linux-newlib* | -linux-musl* | -linux-uclibc* \
1428 | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
1429 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1430 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1431 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1432 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1433 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1434 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1435 | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
1436 | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
1437 # Remember, each alternative MUST END IN *, to match a version number.
1438 ;;
1439 -qnx*)
1440 case $basic_machine in
1441 x86-* | i*86-*)
1442 ;;
1443 *)
1444 os=-nto$os
1445 ;;
1446 esac
1447 ;;
1448 -nacl*)
1449 os=-nacl
1450 ;;
1451 -pnacl*)
1452 os=-pnacl
1453 ;;
1454 -nto-qnx*)
1455 ;;
1456 -nto*)
1457 os=`echo $os | sed -e 's|nto|nto-qnx|'`
1458 ;;
1459 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
1460 | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
1461 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
1462 ;;
1463 -mac*)
1464 os=`echo $os | sed -e 's|mac|macos|'`
1465 ;;
1466 -linux-dietlibc)
1467 os=-linux-dietlibc
1468 ;;
1469 -linux*)
1470 os=`echo $os | sed -e 's|linux|linux-gnu|'`
1471 ;;
1472 -sunos5*)
1473 os=`echo $os | sed -e 's|sunos5|solaris2|'`
1474 ;;
1475 -sunos6*)
1476 os=`echo $os | sed -e 's|sunos6|solaris3|'`
1477 ;;
1478 -opened*)
1479 os=-openedition
1480 ;;
1481 -os400*)
1482 os=-os400
1483 ;;
1484 -cegcc*)
1485 os=-cegcc
1486 ;;
1487 -wince*)
1488 os=-wince
1489 ;;
1490 -osfrose*)
1491 os=-osfrose
1492 ;;
1493 -osf*)
1494 os=-osf
1495 ;;
1496 -utek*)
1497 os=-bsd
1498 ;;
1499 -dynix*)
1500 os=-bsd
1501 ;;
1502 -acis*)
1503 os=-aos
1504 ;;
1505 -atheos*)
1506 os=-atheos
1507 ;;
1508 -syllable*)
1509 os=-syllable
1510 ;;
1511 -386bsd)
1512 os=-bsd
1513 ;;
1514 -ctix* | -uts*)
1515 os=-sysv
1516 ;;
1517 -nova*)
1518 os=-rtmk-nova
1519 ;;
1520 -ns2 )
1521 os=-nextstep2
1522 ;;
1523 -nsk*)
1524 os=-nsk
1525 ;;
1526 # Preserve the version number of sinix5.
1527 -sinix5.*)
1528 os=`echo $os | sed -e 's|sinix|sysv|'`
1529 ;;
1530 -sinix*)
1531 os=-sysv4
1532 ;;
1533 -tpf*)
1534 os=-tpf
1535 ;;
1536 -triton*)
1537 os=-sysv3
1538 ;;
1539 -oss*)
1540 os=-sysv3
1541 ;;
1542 -svr4)
1543 os=-sysv4
1544 ;;
1545 -svr3)
1546 os=-sysv3
1547 ;;
1548 -sysvr4)
1549 os=-sysv4
1550 ;;
1551 # This must come after -sysvr4.
1552 -sysv*)
1553 ;;
1554 -ose*)
1555 os=-ose
1556 ;;
1557 -es1800*)
1558 os=-ose
1559 ;;
1560 -xenix)
1561 os=-xenix
1562 ;;
1563 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1564 os=-mint
1565 ;;
1566 -aros*)
1567 os=-aros
1568 ;;
1569 -zvmoe)
1570 os=-zvmoe
1571 ;;
1572 -dicos*)
1573 os=-dicos
1574 ;;
1575 -nacl*)
1576 os=-nacl
1577 ;;
1578 -pnacl*)
1579 os=-pnacl
1580 ;;
1581 -ios)
1582 ;;
1583 -emscripten*)
1584 ;;
1585 -none)
1586 ;;
1587 *)
1588 # Get rid of the `-' at the beginning of $os.
1589 os=`echo $os | sed 's/[^-]*-//'`
1590 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1591 exit 1
1592 ;;
1593 esac
1594 else
1595
1596 # Here we handle the default operating systems that come with various machines.
1597 # The value should be what the vendor currently ships out the door with their
1598 # machine or put another way, the most popular os provided with the machine.
1599
1600 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1601 # "-sun"), then you have to tell the case statement up towards the top
1602 # that MANUFACTURER isn't an operating system. Otherwise, code above
1603 # will signal an error saying that MANUFACTURER isn't an operating
1604 # system, and we'll never get to this point.
1605
1606 case $basic_machine in
1607 score-*)
1608 os=-elf
1609 ;;
1610 spu-*)
1611 os=-elf
1612 ;;
1613 *-acorn)
1614 os=-riscix1.2
1615 ;;
1616 arm*-rebel)
1617 os=-linux
1618 ;;
1619 arm*-semi)
1620 os=-aout
1621 ;;
1622 c4x-* | tic4x-*)
1623 os=-coff
1624 ;;
1625 c8051-*)
1626 os=-elf
1627 ;;
1628 hexagon-*)
1629 os=-elf
1630 ;;
1631 tic54x-*)
1632 os=-coff
1633 ;;
1634 tic55x-*)
1635 os=-coff
1636 ;;
1637 tic6x-*)
1638 os=-coff
1639 ;;
1640 # This must come before the *-dec entry.
1641 pdp10-*)
1642 os=-tops20
1643 ;;
1644 pdp11-*)
1645 os=-none
1646 ;;
1647 *-dec | vax-*)
1648 os=-ultrix4.2
1649 ;;
1650 m68*-apollo)
1651 os=-domain
1652 ;;
1653 i386-sun)
1654 os=-sunos4.0.2
1655 ;;
1656 m68000-sun)
1657 os=-sunos3
1658 ;;
1659 m68*-cisco)
1660 os=-aout
1661 ;;
1662 mep-*)
1663 os=-elf
1664 ;;
1665 mips*-cisco)
1666 os=-elf
1667 ;;
1668 mips*-*)
1669 os=-elf
1670 ;;
1671 or32-*)
1672 os=-coff
1673 ;;
1674 *-tti) # must be before sparc entry or we get the wrong os.
1675 os=-sysv3
1676 ;;
1677 sparc-* | *-sun)
1678 os=-sunos4.1.1
1679 ;;
1680 pru-*)
1681 os=-elf
1682 ;;
1683 *-be)
1684 os=-beos
1685 ;;
1686 *-haiku)
1687 os=-haiku
1688 ;;
1689 *-ibm)
1690 os=-aix
1691 ;;
1692 *-knuth)
1693 os=-mmixware
1694 ;;
1695 *-wec)
1696 os=-proelf
1697 ;;
1698 *-winbond)
1699 os=-proelf
1700 ;;
1701 *-oki)
1702 os=-proelf
1703 ;;
1704 *-hp)
1705 os=-hpux
1706 ;;
1707 *-hitachi)
1708 os=-hiux
1709 ;;
1710 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1711 os=-sysv
1712 ;;
1713 *-cbm)
1714 os=-amigaos
1715 ;;
1716 *-dg)
1717 os=-dgux
1718 ;;
1719 *-dolphin)
1720 os=-sysv3
1721 ;;
1722 m68k-ccur)
1723 os=-rtu
1724 ;;
1725 m88k-omron*)
1726 os=-luna
1727 ;;
1728 *-next )
1729 os=-nextstep
1730 ;;
1731 *-sequent)
1732 os=-ptx
1733 ;;
1734 *-crds)
1735 os=-unos
1736 ;;
1737 *-ns)
1738 os=-genix
1739 ;;
1740 i370-*)
1741 os=-mvs
1742 ;;
1743 *-next)
1744 os=-nextstep3
1745 ;;
1746 *-gould)
1747 os=-sysv
1748 ;;
1749 *-highlevel)
1750 os=-bsd
1751 ;;
1752 *-encore)
1753 os=-bsd
1754 ;;
1755 *-sgi)
1756 os=-irix
1757 ;;
1758 *-siemens)
1759 os=-sysv4
1760 ;;
1761 *-masscomp)
1762 os=-rtu
1763 ;;
1764 f30[01]-fujitsu | f700-fujitsu)
1765 os=-uxpv
1766 ;;
1767 *-rom68k)
1768 os=-coff
1769 ;;
1770 *-*bug)
1771 os=-coff
1772 ;;
1773 *-apple)
1774 os=-macos
1775 ;;
1776 *-atari*)
1777 os=-mint
1778 ;;
1779 *)
1780 os=-none
1781 ;;
1782 esac
1783 fi
1784
1785 # Here we handle the case where we know the os, and the CPU type, but not the
1786 # manufacturer. We pick the logical manufacturer.
1787 vendor=unknown
1788 case $basic_machine in
1789 *-unknown)
1790 case $os in
1791 -riscix*)
1792 vendor=acorn
1793 ;;
1794 -sunos*)
1795 vendor=sun
1796 ;;
1797 -cnk*|-aix*)
1798 vendor=ibm
1799 ;;
1800 -beos*)
1801 vendor=be
1802 ;;
1803 -hpux*)
1804 vendor=hp
1805 ;;
1806 -mpeix*)
1807 vendor=hp
1808 ;;
1809 -hiux*)
1810 vendor=hitachi
1811 ;;
1812 -unos*)
1813 vendor=crds
1814 ;;
1815 -dgux*)
1816 vendor=dg
1817 ;;
1818 -luna*)
1819 vendor=omron
1820 ;;
1821 -genix*)
1822 vendor=ns
1823 ;;
1824 -mvs* | -opened*)
1825 vendor=ibm
1826 ;;
1827 -os400*)
1828 vendor=ibm
1829 ;;
1830 -ptx*)
1831 vendor=sequent
1832 ;;
1833 -tpf*)
1834 vendor=ibm
1835 ;;
1836 -vxsim* | -vxworks* | -windiss*)
1837 vendor=wrs
1838 ;;
1839 -aux*)
1840 vendor=apple
1841 ;;
1842 -hms*)
1843 vendor=hitachi
1844 ;;
1845 -mpw* | -macos*)
1846 vendor=apple
1847 ;;
1848 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1849 vendor=atari
1850 ;;
1851 -vos*)
1852 vendor=stratus
1853 ;;
1854 esac
1855 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1856 ;;
1857 esac
1858
1859 echo $basic_machine$os
1860 exit
1861
1862 # Local variables:
1863 # eval: (add-hook 'write-file-hooks 'time-stamp)
1864 # time-stamp-start: "timestamp='"
1865 # time-stamp-format: "%:y-%02m-%02d"
1866 # time-stamp-end: "'"
1867 # End:
+0
-527
build-scripts/install-sh less more
0 #!/bin/sh
1 # install - install a program, script, or datafile
2
3 scriptversion=2011-11-20.07; # UTC
4
5 # This originates from X11R5 (mit/util/scripts/install.sh), which was
6 # later released in X11R6 (xc/config/util/install.sh) with the
7 # following copyright and license.
8 #
9 # Copyright (C) 1994 X Consortium
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to
13 # deal in the Software without restriction, including without limitation the
14 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 # sell copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 # Except as contained in this notice, the name of the X Consortium shall not
29 # be used in advertising or otherwise to promote the sale, use or other deal-
30 # ings in this Software without prior written authorization from the X Consor-
31 # tium.
32 #
33 #
34 # FSF changes to this file are in the public domain.
35 #
36 # Calling this script install-sh is preferred over install.sh, to prevent
37 # 'make' implicit rules from creating a file called install from it
38 # when there is no Makefile.
39 #
40 # This script is compatible with the BSD install script, but was written
41 # from scratch.
42
43 nl='
44 '
45 IFS=" "" $nl"
46
47 # set DOITPROG to echo to test this script
48
49 # Don't use :- since 4.3BSD and earlier shells don't like it.
50 doit=${DOITPROG-}
51 if test -z "$doit"; then
52 doit_exec=exec
53 else
54 doit_exec=$doit
55 fi
56
57 # Put in absolute file names if you don't have them in your path;
58 # or use environment vars.
59
60 chgrpprog=${CHGRPPROG-chgrp}
61 chmodprog=${CHMODPROG-chmod}
62 chownprog=${CHOWNPROG-chown}
63 cmpprog=${CMPPROG-cmp}
64 cpprog=${CPPROG-cp}
65 mkdirprog=${MKDIRPROG-mkdir}
66 mvprog=${MVPROG-mv}
67 rmprog=${RMPROG-rm}
68 stripprog=${STRIPPROG-strip}
69
70 posix_glob='?'
71 initialize_posix_glob='
72 test "$posix_glob" != "?" || {
73 if (set -f) 2>/dev/null; then
74 posix_glob=
75 else
76 posix_glob=:
77 fi
78 }
79 '
80
81 posix_mkdir=
82
83 # Desired mode of installed file.
84 mode=0755
85
86 chgrpcmd=
87 chmodcmd=$chmodprog
88 chowncmd=
89 mvcmd=$mvprog
90 rmcmd="$rmprog -f"
91 stripcmd=
92
93 src=
94 dst=
95 dir_arg=
96 dst_arg=
97
98 copy_on_change=false
99 no_target_directory=
100
101 usage="\
102 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
103 or: $0 [OPTION]... SRCFILES... DIRECTORY
104 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
105 or: $0 [OPTION]... -d DIRECTORIES...
106
107 In the 1st form, copy SRCFILE to DSTFILE.
108 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
109 In the 4th, create DIRECTORIES.
110
111 Options:
112 --help display this help and exit.
113 --version display version info and exit.
114
115 -c (ignored)
116 -C install only if different (preserve the last data modification time)
117 -d create directories instead of installing files.
118 -g GROUP $chgrpprog installed files to GROUP.
119 -m MODE $chmodprog installed files to MODE.
120 -o USER $chownprog installed files to USER.
121 -s $stripprog installed files.
122 -t DIRECTORY install into DIRECTORY.
123 -T report an error if DSTFILE is a directory.
124
125 Environment variables override the default commands:
126 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
127 RMPROG STRIPPROG
128 "
129
130 while test $# -ne 0; do
131 case $1 in
132 -c) ;;
133
134 -C) copy_on_change=true;;
135
136 -d) dir_arg=true;;
137
138 -g) chgrpcmd="$chgrpprog $2"
139 shift;;
140
141 --help) echo "$usage"; exit $?;;
142
143 -m) mode=$2
144 case $mode in
145 *' '* | *' '* | *'
146 '* | *'*'* | *'?'* | *'['*)
147 echo "$0: invalid mode: $mode" >&2
148 exit 1;;
149 esac
150 shift;;
151
152 -o) chowncmd="$chownprog $2"
153 shift;;
154
155 -s) stripcmd=$stripprog;;
156
157 -t) dst_arg=$2
158 # Protect names problematic for 'test' and other utilities.
159 case $dst_arg in
160 -* | [=\(\)!]) dst_arg=./$dst_arg;;
161 esac
162 shift;;
163
164 -T) no_target_directory=true;;
165
166 --version) echo "$0 $scriptversion"; exit $?;;
167
168 --) shift
169 break;;
170
171 -*) echo "$0: invalid option: $1" >&2
172 exit 1;;
173
174 *) break;;
175 esac
176 shift
177 done
178
179 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
180 # When -d is used, all remaining arguments are directories to create.
181 # When -t is used, the destination is already specified.
182 # Otherwise, the last argument is the destination. Remove it from $@.
183 for arg
184 do
185 if test -n "$dst_arg"; then
186 # $@ is not empty: it contains at least $arg.
187 set fnord "$@" "$dst_arg"
188 shift # fnord
189 fi
190 shift # arg
191 dst_arg=$arg
192 # Protect names problematic for 'test' and other utilities.
193 case $dst_arg in
194 -* | [=\(\)!]) dst_arg=./$dst_arg;;
195 esac
196 done
197 fi
198
199 if test $# -eq 0; then
200 if test -z "$dir_arg"; then
201 echo "$0: no input file specified." >&2
202 exit 1
203 fi
204 # It's OK to call 'install-sh -d' without argument.
205 # This can happen when creating conditional directories.
206 exit 0
207 fi
208
209 if test -z "$dir_arg"; then
210 do_exit='(exit $ret); exit $ret'
211 trap "ret=129; $do_exit" 1
212 trap "ret=130; $do_exit" 2
213 trap "ret=141; $do_exit" 13
214 trap "ret=143; $do_exit" 15
215
216 # Set umask so as not to create temps with too-generous modes.
217 # However, 'strip' requires both read and write access to temps.
218 case $mode in
219 # Optimize common cases.
220 *644) cp_umask=133;;
221 *755) cp_umask=22;;
222
223 *[0-7])
224 if test -z "$stripcmd"; then
225 u_plus_rw=
226 else
227 u_plus_rw='% 200'
228 fi
229 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
230 *)
231 if test -z "$stripcmd"; then
232 u_plus_rw=
233 else
234 u_plus_rw=,u+rw
235 fi
236 cp_umask=$mode$u_plus_rw;;
237 esac
238 fi
239
240 for src
241 do
242 # Protect names problematic for 'test' and other utilities.
243 case $src in
244 -* | [=\(\)!]) src=./$src;;
245 esac
246
247 if test -n "$dir_arg"; then
248 dst=$src
249 dstdir=$dst
250 test -d "$dstdir"
251 dstdir_status=$?
252 else
253
254 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
255 # might cause directories to be created, which would be especially bad
256 # if $src (and thus $dsttmp) contains '*'.
257 if test ! -f "$src" && test ! -d "$src"; then
258 echo "$0: $src does not exist." >&2
259 exit 1
260 fi
261
262 if test -z "$dst_arg"; then
263 echo "$0: no destination specified." >&2
264 exit 1
265 fi
266 dst=$dst_arg
267
268 # If destination is a directory, append the input filename; won't work
269 # if double slashes aren't ignored.
270 if test -d "$dst"; then
271 if test -n "$no_target_directory"; then
272 echo "$0: $dst_arg: Is a directory" >&2
273 exit 1
274 fi
275 dstdir=$dst
276 dst=$dstdir/`basename "$src"`
277 dstdir_status=0
278 else
279 # Prefer dirname, but fall back on a substitute if dirname fails.
280 dstdir=`
281 (dirname "$dst") 2>/dev/null ||
282 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
283 X"$dst" : 'X\(//\)[^/]' \| \
284 X"$dst" : 'X\(//\)$' \| \
285 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
286 echo X"$dst" |
287 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
288 s//\1/
289 q
290 }
291 /^X\(\/\/\)[^/].*/{
292 s//\1/
293 q
294 }
295 /^X\(\/\/\)$/{
296 s//\1/
297 q
298 }
299 /^X\(\/\).*/{
300 s//\1/
301 q
302 }
303 s/.*/./; q'
304 `
305
306 test -d "$dstdir"
307 dstdir_status=$?
308 fi
309 fi
310
311 obsolete_mkdir_used=false
312
313 if test $dstdir_status != 0; then
314 case $posix_mkdir in
315 '')
316 # Create intermediate dirs using mode 755 as modified by the umask.
317 # This is like FreeBSD 'install' as of 1997-10-28.
318 umask=`umask`
319 case $stripcmd.$umask in
320 # Optimize common cases.
321 *[2367][2367]) mkdir_umask=$umask;;
322 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
323
324 *[0-7])
325 mkdir_umask=`expr $umask + 22 \
326 - $umask % 100 % 40 + $umask % 20 \
327 - $umask % 10 % 4 + $umask % 2
328 `;;
329 *) mkdir_umask=$umask,go-w;;
330 esac
331
332 # With -d, create the new directory with the user-specified mode.
333 # Otherwise, rely on $mkdir_umask.
334 if test -n "$dir_arg"; then
335 mkdir_mode=-m$mode
336 else
337 mkdir_mode=
338 fi
339
340 posix_mkdir=false
341 case $umask in
342 *[123567][0-7][0-7])
343 # POSIX mkdir -p sets u+wx bits regardless of umask, which
344 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
345 ;;
346 *)
347 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
348 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
349
350 if (umask $mkdir_umask &&
351 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
352 then
353 if test -z "$dir_arg" || {
354 # Check for POSIX incompatibilities with -m.
355 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
356 # other-writable bit of parent directory when it shouldn't.
357 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
358 ls_ld_tmpdir=`ls -ld "$tmpdir"`
359 case $ls_ld_tmpdir in
360 d????-?r-*) different_mode=700;;
361 d????-?--*) different_mode=755;;
362 *) false;;
363 esac &&
364 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
365 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
366 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
367 }
368 }
369 then posix_mkdir=:
370 fi
371 rmdir "$tmpdir/d" "$tmpdir"
372 else
373 # Remove any dirs left behind by ancient mkdir implementations.
374 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
375 fi
376 trap '' 0;;
377 esac;;
378 esac
379
380 if
381 $posix_mkdir && (
382 umask $mkdir_umask &&
383 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
384 )
385 then :
386 else
387
388 # The umask is ridiculous, or mkdir does not conform to POSIX,
389 # or it failed possibly due to a race condition. Create the
390 # directory the slow way, step by step, checking for races as we go.
391
392 case $dstdir in
393 /*) prefix='/';;
394 [-=\(\)!]*) prefix='./';;
395 *) prefix='';;
396 esac
397
398 eval "$initialize_posix_glob"
399
400 oIFS=$IFS
401 IFS=/
402 $posix_glob set -f
403 set fnord $dstdir
404 shift
405 $posix_glob set +f
406 IFS=$oIFS
407
408 prefixes=
409
410 for d
411 do
412 test X"$d" = X && continue
413
414 prefix=$prefix$d
415 if test -d "$prefix"; then
416 prefixes=
417 else
418 if $posix_mkdir; then
419 (umask=$mkdir_umask &&
420 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
421 # Don't fail if two instances are running concurrently.
422 test -d "$prefix" || exit 1
423 else
424 case $prefix in
425 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
426 *) qprefix=$prefix;;
427 esac
428 prefixes="$prefixes '$qprefix'"
429 fi
430 fi
431 prefix=$prefix/
432 done
433
434 if test -n "$prefixes"; then
435 # Don't fail if two instances are running concurrently.
436 (umask $mkdir_umask &&
437 eval "\$doit_exec \$mkdirprog $prefixes") ||
438 test -d "$dstdir" || exit 1
439 obsolete_mkdir_used=true
440 fi
441 fi
442 fi
443
444 if test -n "$dir_arg"; then
445 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
446 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
447 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
448 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
449 else
450
451 # Make a couple of temp file names in the proper directory.
452 dsttmp=$dstdir/_inst.$$_
453 rmtmp=$dstdir/_rm.$$_
454
455 # Trap to clean up those temp files at exit.
456 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
457
458 # Copy the file name to the temp name.
459 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
460
461 # and set any options; do chmod last to preserve setuid bits.
462 #
463 # If any of these fail, we abort the whole thing. If we want to
464 # ignore errors from any of these, just make sure not to ignore
465 # errors from the above "$doit $cpprog $src $dsttmp" command.
466 #
467 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
468 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
469 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
470 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
471
472 # If -C, don't bother to copy if it wouldn't change the file.
473 if $copy_on_change &&
474 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
475 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
476
477 eval "$initialize_posix_glob" &&
478 $posix_glob set -f &&
479 set X $old && old=:$2:$4:$5:$6 &&
480 set X $new && new=:$2:$4:$5:$6 &&
481 $posix_glob set +f &&
482
483 test "$old" = "$new" &&
484 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
485 then
486 rm -f "$dsttmp"
487 else
488 # Rename the file to the real destination.
489 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
490
491 # The rename failed, perhaps because mv can't rename something else
492 # to itself, or perhaps because mv is so ancient that it does not
493 # support -f.
494 {
495 # Now remove or move aside any old file at destination location.
496 # We try this two ways since rm can't unlink itself on some
497 # systems and the destination file might be busy for other
498 # reasons. In this case, the final cleanup might fail but the new
499 # file should still install successfully.
500 {
501 test ! -f "$dst" ||
502 $doit $rmcmd -f "$dst" 2>/dev/null ||
503 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
504 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
505 } ||
506 { echo "$0: cannot unlink or rename $dst" >&2
507 (exit 1); exit 1
508 }
509 } &&
510
511 # Now rename the file to the real destination.
512 $doit $mvcmd "$dsttmp" "$dst"
513 }
514 fi || exit 1
515
516 trap '' 0
517 fi
518 done
519
520 # Local variables:
521 # eval: (add-hook 'write-file-hooks 'time-stamp)
522 # time-stamp-start: "scriptversion="
523 # time-stamp-format: "%:y-%02m-%02d.%02H"
524 # time-stamp-time-zone: "UTC"
525 # time-stamp-end: "; # UTC"
526 # End:
+0
-8407
build-scripts/ltmain.sh less more
0 # Generated from ltmain.m4sh.
1
2 # ltmain.sh (GNU libtool) 2.2.6
3 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4
5 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
6 # This is free software; see the source for copying conditions. There is NO
7 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
9 # GNU Libtool is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # As a special exception to the GNU General Public License,
15 # if you distribute this file as part of a program or library that
16 # is built using GNU Libtool, you may include this file under the
17 # same distribution terms that you use for the rest of that program.
18 #
19 # GNU Libtool is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with GNU Libtool; see the file COPYING. If not, a copy
26 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
27 # or obtained by writing to the Free Software Foundation, Inc.,
28 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
30 # Usage: $progname [OPTION]... [MODE-ARG]...
31 #
32 # Provide generalized library-building support services.
33 #
34 # --config show all configuration variables
35 # --debug enable verbose shell tracing
36 # -n, --dry-run display commands without modifying any files
37 # --features display basic configuration information and exit
38 # --mode=MODE use operation mode MODE
39 # --preserve-dup-deps don't remove duplicate dependency libraries
40 # --quiet, --silent don't print informational messages
41 # --tag=TAG use configuration variables from tag TAG
42 # -v, --verbose print informational messages (default)
43 # --version print version information
44 # -h, --help print short or long help message
45 #
46 # MODE must be one of the following:
47 #
48 # clean remove files from the build directory
49 # compile compile a source file into a libtool object
50 # execute automatically set library path, then run a program
51 # finish complete the installation of libtool libraries
52 # install install libraries or executables
53 # link create a library or an executable
54 # uninstall remove libraries from an installed directory
55 #
56 # MODE-ARGS vary depending on the MODE.
57 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
58 #
59 # When reporting a bug, please describe a test case to reproduce it and
60 # include the following information:
61 #
62 # host-triplet: $host
63 # shell: $SHELL
64 # compiler: $LTCC
65 # compiler flags: $LTCFLAGS
66 # linker: $LD (gnu? $with_gnu_ld)
67 # $progname: (GNU libtool) 2.2.6
68 # automake: $automake_version
69 # autoconf: $autoconf_version
70 #
71 # Report bugs to <bug-libtool@gnu.org>.
72
73 PROGRAM=ltmain.sh
74 PACKAGE=libtool
75 VERSION=2.2.6
76 TIMESTAMP=""
77 package_revision=1.3012
78
79 # Be Bourne compatible
80 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
81 emulate sh
82 NULLCMD=:
83 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
84 # is contrary to our usage. Disable this feature.
85 alias -g '${1+"$@"}'='"$@"'
86 setopt NO_GLOB_SUBST
87 else
88 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
89 fi
90 BIN_SH=xpg4; export BIN_SH # for Tru64
91 DUALCASE=1; export DUALCASE # for MKS sh
92
93 # NLS nuisances: We save the old values to restore during execute mode.
94 # Only set LANG and LC_ALL to C if already set.
95 # These must not be set unconditionally because not all systems understand
96 # e.g. LANG=C (notably SCO).
97 lt_user_locale=
98 lt_safe_locale=
99 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
100 do
101 eval "if test \"\${$lt_var+set}\" = set; then
102 save_$lt_var=\$$lt_var
103 $lt_var=C
104 export $lt_var
105 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
106 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
107 fi"
108 done
109
110 $lt_unset CDPATH
111
112
113
114
115
116 : ${CP="cp -f"}
117 : ${ECHO="echo"}
118 : ${EGREP="/usr/bin/grep -E"}
119 : ${FGREP="/usr/bin/grep -F"}
120 : ${GREP="/usr/bin/grep"}
121 : ${LN_S="ln -s"}
122 : ${MAKE="make"}
123 : ${MKDIR="mkdir"}
124 : ${MV="mv -f"}
125 : ${RM="rm -f"}
126 : ${SED="/opt/local/bin/gsed"}
127 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
128 : ${Xsed="$SED -e 1s/^X//"}
129
130 # Global variables:
131 EXIT_SUCCESS=0
132 EXIT_FAILURE=1
133 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
134 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
135
136 exit_status=$EXIT_SUCCESS
137
138 # Make sure IFS has a sensible default
139 lt_nl='
140 '
141 IFS=" $lt_nl"
142
143 dirname="s,/[^/]*$,,"
144 basename="s,^.*/,,"
145
146 # func_dirname_and_basename file append nondir_replacement
147 # perform func_basename and func_dirname in a single function
148 # call:
149 # dirname: Compute the dirname of FILE. If nonempty,
150 # add APPEND to the result, otherwise set result
151 # to NONDIR_REPLACEMENT.
152 # value returned in "$func_dirname_result"
153 # basename: Compute filename of FILE.
154 # value retuned in "$func_basename_result"
155 # Implementation must be kept synchronized with func_dirname
156 # and func_basename. For efficiency, we do not delegate to
157 # those functions but instead duplicate the functionality here.
158 func_dirname_and_basename ()
159 {
160 # Extract subdirectory from the argument.
161 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
162 if test "X$func_dirname_result" = "X${1}"; then
163 func_dirname_result="${3}"
164 else
165 func_dirname_result="$func_dirname_result${2}"
166 fi
167 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
168 }
169
170 # Generated shell functions inserted here.
171
172 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
173 # is ksh but when the shell is invoked as "sh" and the current value of
174 # the _XPG environment variable is not equal to 1 (one), the special
175 # positional parameter $0, within a function call, is the name of the
176 # function.
177 progpath="$0"
178
179 # The name of this program:
180 # In the unlikely event $progname began with a '-', it would play havoc with
181 # func_echo (imagine progname=-n), so we prepend ./ in that case:
182 func_dirname_and_basename "$progpath"
183 progname=$func_basename_result
184 case $progname in
185 -*) progname=./$progname ;;
186 esac
187
188 # Make sure we have an absolute path for reexecution:
189 case $progpath in
190 [\\/]*|[A-Za-z]:\\*) ;;
191 *[\\/]*)
192 progdir=$func_dirname_result
193 progdir=`cd "$progdir" && pwd`
194 progpath="$progdir/$progname"
195 ;;
196 *)
197 save_IFS="$IFS"
198 IFS=:
199 for progdir in $PATH; do
200 IFS="$save_IFS"
201 test -x "$progdir/$progname" && break
202 done
203 IFS="$save_IFS"
204 test -n "$progdir" || progdir=`pwd`
205 progpath="$progdir/$progname"
206 ;;
207 esac
208
209 # Sed substitution that helps us do robust quoting. It backslashifies
210 # metacharacters that are still active within double-quoted strings.
211 Xsed="${SED}"' -e 1s/^X//'
212 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
213
214 # Same as above, but do not quote variable references.
215 double_quote_subst='s/\(["`\\]\)/\\\1/g'
216
217 # Re-`\' parameter expansions in output of double_quote_subst that were
218 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
219 # in input to double_quote_subst, that '$' was protected from expansion.
220 # Since each input `\' is now two `\'s, look for any number of runs of
221 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
222 bs='\\'
223 bs2='\\\\'
224 bs4='\\\\\\\\'
225 dollar='\$'
226 sed_double_backslash="\
227 s/$bs4/&\\
228 /g
229 s/^$bs2$dollar/$bs&/
230 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
231 s/\n//g"
232
233 # Standard options:
234 opt_dry_run=false
235 opt_help=false
236 opt_quiet=false
237 opt_verbose=false
238 opt_warning=:
239
240 # func_echo arg...
241 # Echo program name prefixed message, along with the current mode
242 # name if it has been set yet.
243 func_echo ()
244 {
245 $ECHO "$progname${mode+: }$mode: $*"
246 }
247
248 # func_verbose arg...
249 # Echo program name prefixed message in verbose mode only.
250 func_verbose ()
251 {
252 $opt_verbose && func_echo ${1+"$@"}
253
254 # A bug in bash halts the script if the last line of a function
255 # fails when set -e is in force, so we need another command to
256 # work around that:
257 :
258 }
259
260 # func_error arg...
261 # Echo program name prefixed message to standard error.
262 func_error ()
263 {
264 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
265 }
266
267 # func_warning arg...
268 # Echo program name prefixed warning message to standard error.
269 func_warning ()
270 {
271 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
272
273 # bash bug again:
274 :
275 }
276
277 # func_fatal_error arg...
278 # Echo program name prefixed message to standard error, and exit.
279 func_fatal_error ()
280 {
281 func_error ${1+"$@"}
282 exit $EXIT_FAILURE
283 }
284
285 # func_fatal_help arg...
286 # Echo program name prefixed message to standard error, followed by
287 # a help hint, and exit.
288 func_fatal_help ()
289 {
290 func_error ${1+"$@"}
291 func_fatal_error "$help"
292 }
293 help="Try \`$progname --help' for more information." ## default
294
295
296 # func_grep expression filename
297 # Check whether EXPRESSION matches any line of FILENAME, without output.
298 func_grep ()
299 {
300 $GREP "$1" "$2" >/dev/null 2>&1
301 }
302
303
304 # func_mkdir_p directory-path
305 # Make sure the entire path to DIRECTORY-PATH is available.
306 func_mkdir_p ()
307 {
308 my_directory_path="$1"
309 my_dir_list=
310
311 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
312
313 # Protect directory names starting with `-'
314 case $my_directory_path in
315 -*) my_directory_path="./$my_directory_path" ;;
316 esac
317
318 # While some portion of DIR does not yet exist...
319 while test ! -d "$my_directory_path"; do
320 # ...make a list in topmost first order. Use a colon delimited
321 # list incase some portion of path contains whitespace.
322 my_dir_list="$my_directory_path:$my_dir_list"
323
324 # If the last portion added has no slash in it, the list is done
325 case $my_directory_path in */*) ;; *) break ;; esac
326
327 # ...otherwise throw away the child directory and loop
328 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
329 done
330 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
331
332 save_mkdir_p_IFS="$IFS"; IFS=':'
333 for my_dir in $my_dir_list; do
334 IFS="$save_mkdir_p_IFS"
335 # mkdir can fail with a `File exist' error if two processes
336 # try to create one of the directories concurrently. Don't
337 # stop in that case!
338 $MKDIR "$my_dir" 2>/dev/null || :
339 done
340 IFS="$save_mkdir_p_IFS"
341
342 # Bail out if we (or some other process) failed to create a directory.
343 test -d "$my_directory_path" || \
344 func_fatal_error "Failed to create \`$1'"
345 fi
346 }
347
348
349 # func_mktempdir [string]
350 # Make a temporary directory that won't clash with other running
351 # libtool processes, and avoids race conditions if possible. If
352 # given, STRING is the basename for that directory.
353 func_mktempdir ()
354 {
355 my_template="${TMPDIR-/tmp}/${1-$progname}"
356
357 if test "$opt_dry_run" = ":"; then
358 # Return a directory name, but don't create it in dry-run mode
359 my_tmpdir="${my_template}-$$"
360 else
361
362 # If mktemp works, use that first and foremost
363 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
364
365 if test ! -d "$my_tmpdir"; then
366 # Failing that, at least try and use $RANDOM to avoid a race
367 my_tmpdir="${my_template}-${RANDOM-0}$$"
368
369 save_mktempdir_umask=`umask`
370 umask 0077
371 $MKDIR "$my_tmpdir"
372 umask $save_mktempdir_umask
373 fi
374
375 # If we're not in dry-run mode, bomb out on failure
376 test -d "$my_tmpdir" || \
377 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
378 fi
379
380 $ECHO "X$my_tmpdir" | $Xsed
381 }
382
383
384 # func_quote_for_eval arg
385 # Aesthetically quote ARG to be evaled later.
386 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
387 # is double-quoted, suitable for a subsequent eval, whereas
388 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
389 # which are still active within double quotes backslashified.
390 func_quote_for_eval ()
391 {
392 case $1 in
393 *[\\\`\"\$]*)
394 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
395 *)
396 func_quote_for_eval_unquoted_result="$1" ;;
397 esac
398
399 case $func_quote_for_eval_unquoted_result in
400 # Double-quote args containing shell metacharacters to delay
401 # word splitting, command substitution and and variable
402 # expansion for a subsequent eval.
403 # Many Bourne shells cannot handle close brackets correctly
404 # in scan sets, so we specify it separately.
405 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
406 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
407 ;;
408 *)
409 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
410 esac
411 }
412
413
414 # func_quote_for_expand arg
415 # Aesthetically quote ARG to be evaled later; same as above,
416 # but do not quote variable references.
417 func_quote_for_expand ()
418 {
419 case $1 in
420 *[\\\`\"]*)
421 my_arg=`$ECHO "X$1" | $Xsed \
422 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
423 *)
424 my_arg="$1" ;;
425 esac
426
427 case $my_arg in
428 # Double-quote args containing shell metacharacters to delay
429 # word splitting and command substitution for a subsequent eval.
430 # Many Bourne shells cannot handle close brackets correctly
431 # in scan sets, so we specify it separately.
432 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
433 my_arg="\"$my_arg\""
434 ;;
435 esac
436
437 func_quote_for_expand_result="$my_arg"
438 }
439
440
441 # func_show_eval cmd [fail_exp]
442 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
443 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
444 # is given, then evaluate it.
445 func_show_eval ()
446 {
447 my_cmd="$1"
448 my_fail_exp="${2-:}"
449
450 ${opt_silent-false} || {
451 func_quote_for_expand "$my_cmd"
452 eval "func_echo $func_quote_for_expand_result"
453 }
454
455 if ${opt_dry_run-false}; then :; else
456 eval "$my_cmd"
457 my_status=$?
458 if test "$my_status" -eq 0; then :; else
459 eval "(exit $my_status); $my_fail_exp"
460 fi
461 fi
462 }
463
464
465 # func_show_eval_locale cmd [fail_exp]
466 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
467 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
468 # is given, then evaluate it. Use the saved locale for evaluation.
469 func_show_eval_locale ()
470 {
471 my_cmd="$1"
472 my_fail_exp="${2-:}"
473
474 ${opt_silent-false} || {
475 func_quote_for_expand "$my_cmd"
476 eval "func_echo $func_quote_for_expand_result"
477 }
478
479 if ${opt_dry_run-false}; then :; else
480 eval "$lt_user_locale
481 $my_cmd"
482 my_status=$?
483 eval "$lt_safe_locale"
484 if test "$my_status" -eq 0; then :; else
485 eval "(exit $my_status); $my_fail_exp"
486 fi
487 fi
488 }
489
490
491
492
493
494 # func_version
495 # Echo version message to standard output and exit.
496 func_version ()
497 {
498 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
499 s/^# //
500 s/^# *$//
501 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
502 p
503 }' < "$progpath"
504 exit $?
505 }
506
507 # func_usage
508 # Echo short help message to standard output and exit.
509 func_usage ()
510 {
511 $SED -n '/^# Usage:/,/# -h/ {
512 s/^# //
513 s/^# *$//
514 s/\$progname/'$progname'/
515 p
516 }' < "$progpath"
517 $ECHO
518 $ECHO "run \`$progname --help | more' for full usage"
519 exit $?
520 }
521
522 # func_help
523 # Echo long help message to standard output and exit.
524 func_help ()
525 {
526 $SED -n '/^# Usage:/,/# Report bugs to/ {
527 s/^# //
528 s/^# *$//
529 s*\$progname*'$progname'*
530 s*\$host*'"$host"'*
531 s*\$SHELL*'"$SHELL"'*
532 s*\$LTCC*'"$LTCC"'*
533 s*\$LTCFLAGS*'"$LTCFLAGS"'*
534 s*\$LD*'"$LD"'*
535 s/\$with_gnu_ld/'"$with_gnu_ld"'/
536 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
537 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
538 p
539 }' < "$progpath"
540 exit $?
541 }
542
543 # func_missing_arg argname
544 # Echo program name prefixed message to standard error and set global
545 # exit_cmd.
546 func_missing_arg ()
547 {
548 func_error "missing argument for $1"
549 exit_cmd=exit
550 }
551
552 exit_cmd=:
553
554
555
556
557
558 # Check that we have a working $ECHO.
559 if test "X$1" = X--no-reexec; then
560 # Discard the --no-reexec flag, and continue.
561 shift
562 elif test "X$1" = X--fallback-echo; then
563 # Avoid inline document here, it may be left over
564 :
565 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
566 # Yippee, $ECHO works!
567 :
568 else
569 # Restart under the correct shell, and then maybe $ECHO will work.
570 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
571 fi
572
573 if test "X$1" = X--fallback-echo; then
574 # used as fallback echo
575 shift
576 cat <<EOF
577 $*
578 EOF
579 exit $EXIT_SUCCESS
580 fi
581
582 magic="%%%MAGIC variable%%%"
583 magic_exe="%%%MAGIC EXE variable%%%"
584
585 # Global variables.
586 # $mode is unset
587 nonopt=
588 execute_dlfiles=
589 preserve_args=
590 lo2o="s/\\.lo\$/.${objext}/"
591 o2lo="s/\\.${objext}\$/.lo/"
592 extracted_archives=
593 extracted_serial=0
594
595 opt_dry_run=false
596 opt_duplicate_deps=false
597 opt_silent=false
598 opt_debug=:
599
600 # If this variable is set in any of the actions, the command in it
601 # will be execed at the end. This prevents here-documents from being
602 # left over by shells.
603 exec_cmd=
604
605 # func_fatal_configuration arg...
606 # Echo program name prefixed message to standard error, followed by
607 # a configuration failure hint, and exit.
608 func_fatal_configuration ()
609 {
610 func_error ${1+"$@"}
611 func_error "See the $PACKAGE documentation for more information."
612 func_fatal_error "Fatal configuration error."
613 }
614
615
616 # func_config
617 # Display the configuration for all the tags in this script.
618 func_config ()
619 {
620 re_begincf='^# ### BEGIN LIBTOOL'
621 re_endcf='^# ### END LIBTOOL'
622
623 # Default configuration.
624 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
625
626 # Now print the configurations for the tags.
627 for tagname in $taglist; do
628 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
629 done
630
631 exit $?
632 }
633
634 # func_features
635 # Display the features supported by this script.
636 func_features ()
637 {
638 $ECHO "host: $host"
639 if test "$build_libtool_libs" = yes; then
640 $ECHO "enable shared libraries"
641 else
642 $ECHO "disable shared libraries"
643 fi
644 if test "$build_old_libs" = yes; then
645 $ECHO "enable static libraries"
646 else
647 $ECHO "disable static libraries"
648 fi
649
650 exit $?
651 }
652
653 # func_enable_tag tagname
654 # Verify that TAGNAME is valid, and either flag an error and exit, or
655 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
656 # variable here.
657 func_enable_tag ()
658 {
659 # Global variable:
660 tagname="$1"
661
662 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
663 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
664 sed_extractcf="/$re_begincf/,/$re_endcf/p"
665
666 # Validate tagname.
667 case $tagname in
668 *[!-_A-Za-z0-9,/]*)
669 func_fatal_error "invalid tag name: $tagname"
670 ;;
671 esac
672
673 # Don't test for the "default" C tag, as we know it's
674 # there but not specially marked.
675 case $tagname in
676 CC) ;;
677 *)
678 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
679 taglist="$taglist $tagname"
680
681 # Evaluate the configuration. Be careful to quote the path
682 # and the sed script, to avoid splitting on whitespace, but
683 # also don't use non-portable quotes within backquotes within
684 # quotes we have to do it in 2 steps:
685 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
686 eval "$extractedcf"
687 else
688 func_error "ignoring unknown tag $tagname"
689 fi
690 ;;
691 esac
692 }
693
694 # Parse options once, thoroughly. This comes as soon as possible in
695 # the script to make things like `libtool --version' happen quickly.
696 {
697
698 # Shorthand for --mode=foo, only valid as the first argument
699 case $1 in
700 clean|clea|cle|cl)
701 shift; set dummy --mode clean ${1+"$@"}; shift
702 ;;
703 compile|compil|compi|comp|com|co|c)
704 shift; set dummy --mode compile ${1+"$@"}; shift
705 ;;
706 execute|execut|execu|exec|exe|ex|e)
707 shift; set dummy --mode execute ${1+"$@"}; shift
708 ;;
709 finish|finis|fini|fin|fi|f)
710 shift; set dummy --mode finish ${1+"$@"}; shift
711 ;;
712 install|instal|insta|inst|ins|in|i)
713 shift; set dummy --mode install ${1+"$@"}; shift
714 ;;
715 link|lin|li|l)
716 shift; set dummy --mode link ${1+"$@"}; shift
717 ;;
718 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
719 shift; set dummy --mode uninstall ${1+"$@"}; shift
720 ;;
721 esac
722
723 # Parse non-mode specific arguments:
724 while test "$#" -gt 0; do
725 opt="$1"
726 shift
727
728 case $opt in
729 --config) func_config ;;
730
731 --debug) preserve_args="$preserve_args $opt"
732 func_echo "enabling shell trace mode"
733 opt_debug='set -x'
734 $opt_debug
735 ;;
736
737 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
738 execute_dlfiles="$execute_dlfiles $1"
739 shift
740 ;;
741
742 --dry-run | -n) opt_dry_run=: ;;
743 --features) func_features ;;
744 --finish) mode="finish" ;;
745
746 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
747 case $1 in
748 # Valid mode arguments:
749 clean) ;;
750 compile) ;;
751 execute) ;;
752 finish) ;;
753 install) ;;
754 link) ;;
755 relink) ;;
756 uninstall) ;;
757
758 # Catch anything else as an error
759 *) func_error "invalid argument for $opt"
760 exit_cmd=exit
761 break
762 ;;
763 esac
764
765 mode="$1"
766 shift
767 ;;
768
769 --preserve-dup-deps)
770 opt_duplicate_deps=: ;;
771
772 --quiet|--silent) preserve_args="$preserve_args $opt"
773 opt_silent=:
774 ;;
775
776 --verbose| -v) preserve_args="$preserve_args $opt"
777 opt_silent=false
778 ;;
779
780 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
781 preserve_args="$preserve_args $opt $1"
782 func_enable_tag "$1" # tagname is set here
783 shift
784 ;;
785
786 # Separate optargs to long options:
787 -dlopen=*|--mode=*|--tag=*)
788 func_opt_split "$opt"
789 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
790 shift
791 ;;
792
793 -\?|-h) func_usage ;;
794 --help) opt_help=: ;;
795 --version) func_version ;;
796
797 -*) func_fatal_help "unrecognized option \`$opt'" ;;
798
799 *) nonopt="$opt"
800 break
801 ;;
802 esac
803 done
804
805
806 case $host in
807 *cygwin* | *mingw* | *pw32* | *cegcc*)
808 # don't eliminate duplications in $postdeps and $predeps
809 opt_duplicate_compiler_generated_deps=:
810 ;;
811 *)
812 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
813 ;;
814 esac
815
816 # Having warned about all mis-specified options, bail out if
817 # anything was wrong.
818 $exit_cmd $EXIT_FAILURE
819 }
820
821 # func_check_version_match
822 # Ensure that we are using m4 macros, and libtool script from the same
823 # release of libtool.
824 func_check_version_match ()
825 {
826 if test "$package_revision" != "$macro_revision"; then
827 if test "$VERSION" != "$macro_version"; then
828 if test -z "$macro_version"; then
829 cat >&2 <<_LT_EOF
830 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
831 $progname: definition of this LT_INIT comes from an older release.
832 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
833 $progname: and run autoconf again.
834 _LT_EOF
835 else
836 cat >&2 <<_LT_EOF
837 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
838 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
839 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
840 $progname: and run autoconf again.
841 _LT_EOF
842 fi
843 else
844 cat >&2 <<_LT_EOF
845 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
846 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
847 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
848 $progname: of $PACKAGE $VERSION and run autoconf again.
849 _LT_EOF
850 fi
851
852 exit $EXIT_MISMATCH
853 fi
854 }
855
856
857 ## ----------- ##
858 ## Main. ##
859 ## ----------- ##
860
861 $opt_help || {
862 # Sanity checks first:
863 func_check_version_match
864
865 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
866 func_fatal_configuration "not configured to build any kind of library"
867 fi
868
869 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
870
871
872 # Darwin sucks
873 eval std_shrext=\"$shrext_cmds\"
874
875
876 # Only execute mode is allowed to have -dlopen flags.
877 if test -n "$execute_dlfiles" && test "$mode" != execute; then
878 func_error "unrecognized option \`-dlopen'"
879 $ECHO "$help" 1>&2
880 exit $EXIT_FAILURE
881 fi
882
883 # Change the help message to a mode-specific one.
884 generic_help="$help"
885 help="Try \`$progname --help --mode=$mode' for more information."
886 }
887
888
889 # func_lalib_p file
890 # True iff FILE is a libtool `.la' library or `.lo' object file.
891 # This function is only a basic sanity check; it will hardly flush out
892 # determined imposters.
893 func_lalib_p ()
894 {
895 test -f "$1" &&
896 $SED -e 4q "$1" 2>/dev/null \
897 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
898 }
899
900 # func_lalib_unsafe_p file
901 # True iff FILE is a libtool `.la' library or `.lo' object file.
902 # This function implements the same check as func_lalib_p without
903 # resorting to external programs. To this end, it redirects stdin and
904 # closes it afterwards, without saving the original file descriptor.
905 # As a safety measure, use it only where a negative result would be
906 # fatal anyway. Works if `file' does not exist.
907 func_lalib_unsafe_p ()
908 {
909 lalib_p=no
910 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
911 for lalib_p_l in 1 2 3 4
912 do
913 read lalib_p_line
914 case "$lalib_p_line" in
915 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
916 esac
917 done
918 exec 0<&5 5<&-
919 fi
920 test "$lalib_p" = yes
921 }
922
923 # func_ltwrapper_script_p file
924 # True iff FILE is a libtool wrapper script
925 # This function is only a basic sanity check; it will hardly flush out
926 # determined imposters.
927 func_ltwrapper_script_p ()
928 {
929 func_lalib_p "$1"
930 }
931
932 # func_ltwrapper_executable_p file
933 # True iff FILE is a libtool wrapper executable
934 # This function is only a basic sanity check; it will hardly flush out
935 # determined imposters.
936 func_ltwrapper_executable_p ()
937 {
938 func_ltwrapper_exec_suffix=
939 case $1 in
940 *.exe) ;;
941 *) func_ltwrapper_exec_suffix=.exe ;;
942 esac
943 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
944 }
945
946 # func_ltwrapper_scriptname file
947 # Assumes file is an ltwrapper_executable
948 # uses $file to determine the appropriate filename for a
949 # temporary ltwrapper_script.
950 func_ltwrapper_scriptname ()
951 {
952 func_ltwrapper_scriptname_result=""
953 if func_ltwrapper_executable_p "$1"; then
954 func_dirname_and_basename "$1" "" "."
955 func_stripname '' '.exe' "$func_basename_result"
956 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
957 fi
958 }
959
960 # func_ltwrapper_p file
961 # True iff FILE is a libtool wrapper script or wrapper executable
962 # This function is only a basic sanity check; it will hardly flush out
963 # determined imposters.
964 func_ltwrapper_p ()
965 {
966 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
967 }
968
969
970 # func_execute_cmds commands fail_cmd
971 # Execute tilde-delimited COMMANDS.
972 # If FAIL_CMD is given, eval that upon failure.
973 # FAIL_CMD may read-access the current command in variable CMD!
974 func_execute_cmds ()
975 {
976 $opt_debug
977 save_ifs=$IFS; IFS='~'
978 for cmd in $1; do
979 IFS=$save_ifs
980 eval cmd=\"$cmd\"
981 func_show_eval "$cmd" "${2-:}"
982 done
983 IFS=$save_ifs
984 }
985
986
987 # func_source file
988 # Source FILE, adding directory component if necessary.
989 # Note that it is not necessary on cygwin/mingw to append a dot to
990 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
991 # behavior happens only for exec(3), not for open(2)! Also, sourcing
992 # `FILE.' does not work on cygwin managed mounts.
993 func_source ()
994 {
995 $opt_debug
996 case $1 in
997 */* | *\\*) . "$1" ;;
998 *) . "./$1" ;;
999 esac
1000 }
1001
1002
1003 # func_infer_tag arg
1004 # Infer tagged configuration to use if any are available and
1005 # if one wasn't chosen via the "--tag" command line option.
1006 # Only attempt this if the compiler in the base compile
1007 # command doesn't match the default compiler.
1008 # arg is usually of the form 'gcc ...'
1009 func_infer_tag ()
1010 {
1011 $opt_debug
1012 if test -n "$available_tags" && test -z "$tagname"; then
1013 CC_quoted=
1014 for arg in $CC; do
1015 func_quote_for_eval "$arg"
1016 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1017 done
1018 case $@ in
1019 # Blanks in the command may have been stripped by the calling shell,
1020 # but not from the CC environment variable when configure was run.
1021 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1022 # Blanks at the start of $base_compile will cause this to fail
1023 # if we don't check for them as well.
1024 *)
1025 for z in $available_tags; do
1026 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1027 # Evaluate the configuration.
1028 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1029 CC_quoted=
1030 for arg in $CC; do
1031 # Double-quote args containing other shell metacharacters.
1032 func_quote_for_eval "$arg"
1033 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1034 done
1035 case "$@ " in
1036 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1037 # The compiler in the base compile command matches
1038 # the one in the tagged configuration.
1039 # Assume this is the tagged configuration we want.
1040 tagname=$z
1041 break
1042 ;;
1043 esac
1044 fi
1045 done
1046 # If $tagname still isn't set, then no tagged configuration
1047 # was found and let the user know that the "--tag" command
1048 # line option must be used.
1049 if test -z "$tagname"; then
1050 func_echo "unable to infer tagged configuration"
1051 func_fatal_error "specify a tag with \`--tag'"
1052 # else
1053 # func_verbose "using $tagname tagged configuration"
1054 fi
1055 ;;
1056 esac
1057 fi
1058 }
1059
1060
1061
1062 # func_write_libtool_object output_name pic_name nonpic_name
1063 # Create a libtool object file (analogous to a ".la" file),
1064 # but don't create it if we're doing a dry run.
1065 func_write_libtool_object ()
1066 {
1067 write_libobj=${1}
1068 if test "$build_libtool_libs" = yes; then
1069 write_lobj=\'${2}\'
1070 else
1071 write_lobj=none
1072 fi
1073
1074 if test "$build_old_libs" = yes; then
1075 write_oldobj=\'${3}\'
1076 else
1077 write_oldobj=none
1078 fi
1079
1080 $opt_dry_run || {
1081 cat >${write_libobj}T <<EOF
1082 # $write_libobj - a libtool object file
1083 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1084 #
1085 # Please DO NOT delete this file!
1086 # It is necessary for linking the library.
1087
1088 # Name of the PIC object.
1089 pic_object=$write_lobj
1090
1091 # Name of the non-PIC object
1092 non_pic_object=$write_oldobj
1093
1094 EOF
1095 $MV "${write_libobj}T" "${write_libobj}"
1096 }
1097 }
1098
1099 # func_mode_compile arg...
1100 func_mode_compile ()
1101 {
1102 $opt_debug
1103 # Get the compilation command and the source file.
1104 base_compile=
1105 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1106 suppress_opt=yes
1107 suppress_output=
1108 arg_mode=normal
1109 libobj=
1110 later=
1111 pie_flag=
1112
1113 for arg
1114 do
1115 case $arg_mode in
1116 arg )
1117 # do not "continue". Instead, add this to base_compile
1118 lastarg="$arg"
1119 arg_mode=normal
1120 ;;
1121
1122 target )
1123 libobj="$arg"
1124 arg_mode=normal
1125 continue
1126 ;;
1127
1128 normal )
1129 # Accept any command-line options.
1130 case $arg in
1131 -o)
1132 test -n "$libobj" && \
1133 func_fatal_error "you cannot specify \`-o' more than once"
1134 arg_mode=target
1135 continue
1136 ;;
1137
1138 -pie | -fpie | -fPIE)
1139 pie_flag="$pie_flag $arg"
1140 continue
1141 ;;
1142
1143 -shared | -static | -prefer-pic | -prefer-non-pic)
1144 later="$later $arg"
1145 continue
1146 ;;
1147
1148 -no-suppress)
1149 suppress_opt=no
1150 continue
1151 ;;
1152
1153 -Xcompiler)
1154 arg_mode=arg # the next one goes into the "base_compile" arg list
1155 continue # The current "srcfile" will either be retained or
1156 ;; # replaced later. I would guess that would be a bug.
1157
1158 -Wc,*)
1159 func_stripname '-Wc,' '' "$arg"
1160 args=$func_stripname_result
1161 lastarg=
1162 save_ifs="$IFS"; IFS=','
1163 for arg in $args; do
1164 IFS="$save_ifs"
1165 func_quote_for_eval "$arg"
1166 lastarg="$lastarg $func_quote_for_eval_result"
1167 done
1168 IFS="$save_ifs"
1169 func_stripname ' ' '' "$lastarg"
1170 lastarg=$func_stripname_result
1171
1172 # Add the arguments to base_compile.
1173 base_compile="$base_compile $lastarg"
1174 continue
1175 ;;
1176
1177 *)
1178 # Accept the current argument as the source file.
1179 # The previous "srcfile" becomes the current argument.
1180 #
1181 lastarg="$srcfile"
1182 srcfile="$arg"
1183 ;;
1184 esac # case $arg
1185 ;;
1186 esac # case $arg_mode
1187
1188 # Aesthetically quote the previous argument.
1189 func_quote_for_eval "$lastarg"
1190 base_compile="$base_compile $func_quote_for_eval_result"
1191 done # for arg
1192
1193 case $arg_mode in
1194 arg)
1195 func_fatal_error "you must specify an argument for -Xcompile"
1196 ;;
1197 target)
1198 func_fatal_error "you must specify a target with \`-o'"
1199 ;;
1200 *)
1201 # Get the name of the library object.
1202 test -z "$libobj" && {
1203 func_basename "$srcfile"
1204 libobj="$func_basename_result"
1205 }
1206 ;;
1207 esac
1208
1209 # Recognize several different file suffixes.
1210 # If the user specifies -o file.o, it is replaced with file.lo
1211 case $libobj in
1212 *.[cCFSifmso] | \
1213 *.ada | *.adb | *.ads | *.asm | \
1214 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1215 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1216 func_xform "$libobj"
1217 libobj=$func_xform_result
1218 ;;
1219 esac
1220
1221 case $libobj in
1222 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1223 *)
1224 func_fatal_error "cannot determine name of library object from \`$libobj'"
1225 ;;
1226 esac
1227
1228 func_infer_tag $base_compile
1229
1230 for arg in $later; do
1231 case $arg in
1232 -shared)
1233 test "$build_libtool_libs" != yes && \
1234 func_fatal_configuration "can not build a shared library"
1235 build_old_libs=no
1236 continue
1237 ;;
1238
1239 -static)
1240 build_libtool_libs=no
1241 build_old_libs=yes
1242 continue
1243 ;;
1244
1245 -prefer-pic)
1246 pic_mode=yes
1247 continue
1248 ;;
1249
1250 -prefer-non-pic)
1251 pic_mode=no
1252 continue
1253 ;;
1254 esac
1255 done
1256
1257 func_quote_for_eval "$libobj"
1258 test "X$libobj" != "X$func_quote_for_eval_result" \
1259 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1260 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1261 func_dirname_and_basename "$obj" "/" ""
1262 objname="$func_basename_result"
1263 xdir="$func_dirname_result"
1264 lobj=${xdir}$objdir/$objname
1265
1266 test -z "$base_compile" && \
1267 func_fatal_help "you must specify a compilation command"
1268
1269 # Delete any leftover library objects.
1270 if test "$build_old_libs" = yes; then
1271 removelist="$obj $lobj $libobj ${libobj}T"
1272 else
1273 removelist="$lobj $libobj ${libobj}T"
1274 fi
1275
1276 # On Cygwin there's no "real" PIC flag so we must build both object types
1277 case $host_os in
1278 cygwin* | mingw* | pw32* | os2* | cegcc*)
1279 pic_mode=default
1280 ;;
1281 esac
1282 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1283 # non-PIC code in shared libraries is not supported
1284 pic_mode=default
1285 fi
1286
1287 # Calculate the filename of the output object if compiler does
1288 # not support -o with -c
1289 if test "$compiler_c_o" = no; then
1290 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1291 lockfile="$output_obj.lock"
1292 else
1293 output_obj=
1294 need_locks=no
1295 lockfile=
1296 fi
1297
1298 # Lock this critical section if it is needed
1299 # We use this script file to make the link, it avoids creating a new file
1300 if test "$need_locks" = yes; then
1301 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1302 func_echo "Waiting for $lockfile to be removed"
1303 sleep 2
1304 done
1305 elif test "$need_locks" = warn; then
1306 if test -f "$lockfile"; then
1307 $ECHO "\
1308 *** ERROR, $lockfile exists and contains:
1309 `cat $lockfile 2>/dev/null`
1310
1311 This indicates that another process is trying to use the same
1312 temporary object file, and libtool could not work around it because
1313 your compiler does not support \`-c' and \`-o' together. If you
1314 repeat this compilation, it may succeed, by chance, but you had better
1315 avoid parallel builds (make -j) in this platform, or get a better
1316 compiler."
1317
1318 $opt_dry_run || $RM $removelist
1319 exit $EXIT_FAILURE
1320 fi
1321 removelist="$removelist $output_obj"
1322 $ECHO "$srcfile" > "$lockfile"
1323 fi
1324
1325 $opt_dry_run || $RM $removelist
1326 removelist="$removelist $lockfile"
1327 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1328
1329 if test -n "$fix_srcfile_path"; then
1330 eval srcfile=\"$fix_srcfile_path\"
1331 fi
1332 func_quote_for_eval "$srcfile"
1333 qsrcfile=$func_quote_for_eval_result
1334
1335 # Only build a PIC object if we are building libtool libraries.
1336 if test "$build_libtool_libs" = yes; then
1337 # Without this assignment, base_compile gets emptied.
1338 fbsd_hideous_sh_bug=$base_compile
1339
1340 if test "$pic_mode" != no; then
1341 command="$base_compile $qsrcfile $pic_flag"
1342 else
1343 # Don't build PIC code
1344 command="$base_compile $qsrcfile"
1345 fi
1346
1347 func_mkdir_p "$xdir$objdir"
1348
1349 if test -z "$output_obj"; then
1350 # Place PIC objects in $objdir
1351 command="$command -o $lobj"
1352 fi
1353
1354 func_show_eval_locale "$command" \
1355 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1356
1357 if test "$need_locks" = warn &&
1358 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1359 $ECHO "\
1360 *** ERROR, $lockfile contains:
1361 `cat $lockfile 2>/dev/null`
1362
1363 but it should contain:
1364 $srcfile
1365
1366 This indicates that another process is trying to use the same
1367 temporary object file, and libtool could not work around it because
1368 your compiler does not support \`-c' and \`-o' together. If you
1369 repeat this compilation, it may succeed, by chance, but you had better
1370 avoid parallel builds (make -j) in this platform, or get a better
1371 compiler."
1372
1373 $opt_dry_run || $RM $removelist
1374 exit $EXIT_FAILURE
1375 fi
1376
1377 # Just move the object if needed, then go on to compile the next one
1378 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1379 func_show_eval '$MV "$output_obj" "$lobj"' \
1380 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1381 fi
1382
1383 # Allow error messages only from the first compilation.
1384 if test "$suppress_opt" = yes; then
1385 suppress_output=' >/dev/null 2>&1'
1386 fi
1387 fi
1388
1389 # Only build a position-dependent object if we build old libraries.
1390 if test "$build_old_libs" = yes; then
1391 if test "$pic_mode" != yes; then
1392 # Don't build PIC code
1393 command="$base_compile $qsrcfile$pie_flag"
1394 else
1395 command="$base_compile $qsrcfile $pic_flag"
1396 fi
1397 if test "$compiler_c_o" = yes; then
1398 command="$command -o $obj"
1399 fi
1400
1401 # Suppress compiler output if we already did a PIC compilation.
1402 command="$command$suppress_output"
1403 func_show_eval_locale "$command" \
1404 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1405
1406 if test "$need_locks" = warn &&
1407 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1408 $ECHO "\
1409 *** ERROR, $lockfile contains:
1410 `cat $lockfile 2>/dev/null`
1411
1412 but it should contain:
1413 $srcfile
1414
1415 This indicates that another process is trying to use the same
1416 temporary object file, and libtool could not work around it because
1417 your compiler does not support \`-c' and \`-o' together. If you
1418 repeat this compilation, it may succeed, by chance, but you had better
1419 avoid parallel builds (make -j) in this platform, or get a better
1420 compiler."
1421
1422 $opt_dry_run || $RM $removelist
1423 exit $EXIT_FAILURE
1424 fi
1425
1426 # Just move the object if needed
1427 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1428 func_show_eval '$MV "$output_obj" "$obj"' \
1429 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1430 fi
1431 fi
1432
1433 $opt_dry_run || {
1434 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1435
1436 # Unlock the critical section if it was locked
1437 if test "$need_locks" != no; then
1438 removelist=$lockfile
1439 $RM "$lockfile"
1440 fi
1441 }
1442
1443 exit $EXIT_SUCCESS
1444 }
1445
1446 $opt_help || {
1447 test "$mode" = compile && func_mode_compile ${1+"$@"}
1448 }
1449
1450 func_mode_help ()
1451 {
1452 # We need to display help for each of the modes.
1453 case $mode in
1454 "")
1455 # Generic help is extracted from the usage comments
1456 # at the start of this file.
1457 func_help
1458 ;;
1459
1460 clean)
1461 $ECHO \
1462 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1463
1464 Remove files from the build directory.
1465
1466 RM is the name of the program to use to delete files associated with each FILE
1467 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1468 to RM.
1469
1470 If FILE is a libtool library, object or program, all the files associated
1471 with it are deleted. Otherwise, only FILE itself is deleted using RM."
1472 ;;
1473
1474 compile)
1475 $ECHO \
1476 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1477
1478 Compile a source file into a libtool library object.
1479
1480 This mode accepts the following additional options:
1481
1482 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1483 -no-suppress do not suppress compiler output for multiple passes
1484 -prefer-pic try to building PIC objects only
1485 -prefer-non-pic try to building non-PIC objects only
1486 -shared do not build a \`.o' file suitable for static linking
1487 -static only build a \`.o' file suitable for static linking
1488
1489 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1490 from the given SOURCEFILE.
1491
1492 The output file name is determined by removing the directory component from
1493 SOURCEFILE, then substituting the C source code suffix \`.c' with the
1494 library object suffix, \`.lo'."
1495 ;;
1496
1497 execute)
1498 $ECHO \
1499 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1500
1501 Automatically set library path, then run a program.
1502
1503 This mode accepts the following additional options:
1504
1505 -dlopen FILE add the directory containing FILE to the library path
1506
1507 This mode sets the library path environment variable according to \`-dlopen'
1508 flags.
1509
1510 If any of the ARGS are libtool executable wrappers, then they are translated
1511 into their corresponding uninstalled binary, and any of their required library
1512 directories are added to the library path.
1513
1514 Then, COMMAND is executed, with ARGS as arguments."
1515 ;;
1516
1517 finish)
1518 $ECHO \
1519 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1520
1521 Complete the installation of libtool libraries.
1522
1523 Each LIBDIR is a directory that contains libtool libraries.
1524
1525 The commands that this mode executes may require superuser privileges. Use
1526 the \`--dry-run' option if you just want to see what would be executed."
1527 ;;
1528
1529 install)
1530 $ECHO \
1531 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1532
1533 Install executables or libraries.
1534
1535 INSTALL-COMMAND is the installation command. The first component should be
1536 either the \`install' or \`cp' program.
1537
1538 The following components of INSTALL-COMMAND are treated specially:
1539
1540 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
1541
1542 The rest of the components are interpreted as arguments to that command (only
1543 BSD-compatible install options are recognized)."
1544 ;;
1545
1546 link)
1547 $ECHO \
1548 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1549
1550 Link object files or libraries together to form another library, or to
1551 create an executable program.
1552
1553 LINK-COMMAND is a command using the C compiler that you would use to create
1554 a program from several object files.
1555
1556 The following components of LINK-COMMAND are treated specially:
1557
1558 -all-static do not do any dynamic linking at all
1559 -avoid-version do not add a version suffix if possible
1560 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1561 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1562 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1563 -export-symbols SYMFILE
1564 try to export only the symbols listed in SYMFILE
1565 -export-symbols-regex REGEX
1566 try to export only the symbols matching REGEX
1567 -LLIBDIR search LIBDIR for required installed libraries
1568 -lNAME OUTPUT-FILE requires the installed library libNAME
1569 -module build a library that can dlopened
1570 -no-fast-install disable the fast-install mode
1571 -no-install link a not-installable executable
1572 -no-undefined declare that a library does not refer to external symbols
1573 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1574 -objectlist FILE Use a list of object files found in FILE to specify objects
1575 -precious-files-regex REGEX
1576 don't remove output files matching REGEX
1577 -release RELEASE specify package release information
1578 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1579 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1580 -shared only do dynamic linking of libtool libraries
1581 -shrext SUFFIX override the standard shared library file extension
1582 -static do not do any dynamic linking of uninstalled libtool libraries
1583 -static-libtool-libs
1584 do not do any dynamic linking of libtool libraries
1585 -version-info CURRENT[:REVISION[:AGE]]
1586 specify library version info [each variable defaults to 0]
1587 -weak LIBNAME declare that the target provides the LIBNAME interface
1588
1589 All other options (arguments beginning with \`-') are ignored.
1590
1591 Every other argument is treated as a filename. Files ending in \`.la' are
1592 treated as uninstalled libtool libraries, other files are standard or library
1593 object files.
1594
1595 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1596 only library objects (\`.lo' files) may be specified, and \`-rpath' is
1597 required, except when creating a convenience library.
1598
1599 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1600 using \`ar' and \`ranlib', or on Windows using \`lib'.
1601
1602 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1603 is created, otherwise an executable program is created."
1604 ;;
1605
1606 uninstall)
1607 $ECHO \
1608 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1609
1610 Remove libraries from an installation directory.
1611
1612 RM is the name of the program to use to delete files associated with each FILE
1613 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1614 to RM.
1615
1616 If FILE is a libtool library, all the files associated with it are deleted.
1617 Otherwise, only FILE itself is deleted using RM."
1618 ;;
1619
1620 *)
1621 func_fatal_help "invalid operation mode \`$mode'"
1622 ;;
1623 esac
1624
1625 $ECHO
1626 $ECHO "Try \`$progname --help' for more information about other modes."
1627
1628 exit $?
1629 }
1630
1631 # Now that we've collected a possible --mode arg, show help if necessary
1632 $opt_help && func_mode_help
1633
1634
1635 # func_mode_execute arg...
1636 func_mode_execute ()
1637 {
1638 $opt_debug
1639 # The first argument is the command name.
1640 cmd="$nonopt"
1641 test -z "$cmd" && \
1642 func_fatal_help "you must specify a COMMAND"
1643
1644 # Handle -dlopen flags immediately.
1645 for file in $execute_dlfiles; do
1646 test -f "$file" \
1647 || func_fatal_help "\`$file' is not a file"
1648
1649 dir=
1650 case $file in
1651 *.la)
1652 # Check to see that this really is a libtool archive.
1653 func_lalib_unsafe_p "$file" \
1654 || func_fatal_help "\`$lib' is not a valid libtool archive"
1655
1656 # Read the libtool library.
1657 dlname=
1658 library_names=
1659 func_source "$file"
1660
1661 # Skip this library if it cannot be dlopened.
1662 if test -z "$dlname"; then
1663 # Warn if it was a shared library.
1664 test -n "$library_names" && \
1665 func_warning "\`$file' was not linked with \`-export-dynamic'"
1666 continue
1667 fi
1668
1669 func_dirname "$file" "" "."
1670 dir="$func_dirname_result"
1671
1672 if test -f "$dir/$objdir/$dlname"; then
1673 dir="$dir/$objdir"
1674 else
1675 if test ! -f "$dir/$dlname"; then
1676 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1677 fi
1678 fi
1679 ;;
1680
1681 *.lo)
1682 # Just add the directory containing the .lo file.
1683 func_dirname "$file" "" "."
1684 dir="$func_dirname_result"
1685 ;;
1686
1687 *)
1688 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1689 continue
1690 ;;
1691 esac
1692
1693 # Get the absolute pathname.
1694 absdir=`cd "$dir" && pwd`
1695 test -n "$absdir" && dir="$absdir"
1696
1697 # Now add the directory to shlibpath_var.
1698 if eval "test -z \"\$$shlibpath_var\""; then
1699 eval "$shlibpath_var=\"\$dir\""
1700 else
1701 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1702 fi
1703 done
1704
1705 # This variable tells wrapper scripts just to set shlibpath_var
1706 # rather than running their programs.
1707 libtool_execute_magic="$magic"
1708
1709 # Check if any of the arguments is a wrapper script.
1710 args=
1711 for file
1712 do
1713 case $file in
1714 -*) ;;
1715 *)
1716 # Do a test to see if this is really a libtool program.
1717 if func_ltwrapper_script_p "$file"; then
1718 func_source "$file"
1719 # Transform arg to wrapped name.
1720 file="$progdir/$program"
1721 elif func_ltwrapper_executable_p "$file"; then
1722 func_ltwrapper_scriptname "$file"
1723 func_source "$func_ltwrapper_scriptname_result"
1724 # Transform arg to wrapped name.
1725 file="$progdir/$program"
1726 fi
1727 ;;
1728 esac
1729 # Quote arguments (to preserve shell metacharacters).
1730 func_quote_for_eval "$file"
1731 args="$args $func_quote_for_eval_result"
1732 done
1733
1734 if test "X$opt_dry_run" = Xfalse; then
1735 if test -n "$shlibpath_var"; then
1736 # Export the shlibpath_var.
1737 eval "export $shlibpath_var"
1738 fi
1739
1740 # Restore saved environment variables
1741 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1742 do
1743 eval "if test \"\${save_$lt_var+set}\" = set; then
1744 $lt_var=\$save_$lt_var; export $lt_var
1745 else
1746 $lt_unset $lt_var
1747 fi"
1748 done
1749
1750 # Now prepare to actually exec the command.
1751 exec_cmd="\$cmd$args"
1752 else
1753 # Display what would be done.
1754 if test -n "$shlibpath_var"; then
1755 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1756 $ECHO "export $shlibpath_var"
1757 fi
1758 $ECHO "$cmd$args"
1759 exit $EXIT_SUCCESS
1760 fi
1761 }
1762
1763 test "$mode" = execute && func_mode_execute ${1+"$@"}
1764
1765
1766 # func_mode_finish arg...
1767 func_mode_finish ()
1768 {
1769 $opt_debug
1770 libdirs="$nonopt"
1771 admincmds=
1772
1773 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1774 for dir
1775 do
1776 libdirs="$libdirs $dir"
1777 done
1778
1779 for libdir in $libdirs; do
1780 if test -n "$finish_cmds"; then
1781 # Do each command in the finish commands.
1782 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1783 '"$cmd"'"'
1784 fi
1785 if test -n "$finish_eval"; then
1786 # Do the single finish_eval.
1787 eval cmds=\"$finish_eval\"
1788 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1789 $cmds"
1790 fi
1791 done
1792 fi
1793
1794 # Exit here if they wanted silent mode.
1795 $opt_silent && exit $EXIT_SUCCESS
1796
1797 $ECHO "X----------------------------------------------------------------------" | $Xsed
1798 $ECHO "Libraries have been installed in:"
1799 for libdir in $libdirs; do
1800 $ECHO " $libdir"
1801 done
1802 $ECHO
1803 $ECHO "If you ever happen to want to link against installed libraries"
1804 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1805 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1806 $ECHO "flag during linking and do at least one of the following:"
1807 if test -n "$shlibpath_var"; then
1808 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
1809 $ECHO " during execution"
1810 fi
1811 if test -n "$runpath_var"; then
1812 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
1813 $ECHO " during linking"
1814 fi
1815 if test -n "$hardcode_libdir_flag_spec"; then
1816 libdir=LIBDIR
1817 eval flag=\"$hardcode_libdir_flag_spec\"
1818
1819 $ECHO " - use the \`$flag' linker flag"
1820 fi
1821 if test -n "$admincmds"; then
1822 $ECHO " - have your system administrator run these commands:$admincmds"
1823 fi
1824 if test -f /etc/ld.so.conf; then
1825 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1826 fi
1827 $ECHO
1828
1829 $ECHO "See any operating system documentation about shared libraries for"
1830 case $host in
1831 solaris2.[6789]|solaris2.1[0-9])
1832 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1833 $ECHO "pages."
1834 ;;
1835 *)
1836 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1837 ;;
1838 esac
1839 $ECHO "X----------------------------------------------------------------------" | $Xsed
1840 exit $EXIT_SUCCESS
1841 }
1842
1843 test "$mode" = finish && func_mode_finish ${1+"$@"}
1844
1845
1846 # func_mode_install arg...
1847 func_mode_install ()
1848 {
1849 $opt_debug
1850 # There may be an optional sh(1) argument at the beginning of
1851 # install_prog (especially on Windows NT).
1852 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1853 # Allow the use of GNU shtool's install command.
1854 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1855 # Aesthetically quote it.
1856 func_quote_for_eval "$nonopt"
1857 install_prog="$func_quote_for_eval_result "
1858 arg=$1
1859 shift
1860 else
1861 install_prog=
1862 arg=$nonopt
1863 fi
1864
1865 # The real first argument should be the name of the installation program.
1866 # Aesthetically quote it.
1867 func_quote_for_eval "$arg"
1868 install_prog="$install_prog$func_quote_for_eval_result"
1869
1870 # We need to accept at least all the BSD install flags.
1871 dest=
1872 files=
1873 opts=
1874 prev=
1875 install_type=
1876 isdir=no
1877 stripme=
1878 for arg
1879 do
1880 if test -n "$dest"; then
1881 files="$files $dest"
1882 dest=$arg
1883 continue
1884 fi
1885
1886 case $arg in
1887 -d) isdir=yes ;;
1888 -f)
1889 case " $install_prog " in
1890 *[\\\ /]cp\ *) ;;
1891 *) prev=$arg ;;
1892 esac
1893 ;;
1894 -g | -m | -o)
1895 prev=$arg
1896 ;;
1897 -s)
1898 stripme=" -s"
1899 continue
1900 ;;
1901 -*)
1902 ;;
1903 *)
1904 # If the previous option needed an argument, then skip it.
1905 if test -n "$prev"; then
1906 prev=
1907 else
1908 dest=$arg
1909 continue
1910 fi
1911 ;;
1912 esac
1913
1914 # Aesthetically quote the argument.
1915 func_quote_for_eval "$arg"
1916 install_prog="$install_prog $func_quote_for_eval_result"
1917 done
1918
1919 test -z "$install_prog" && \
1920 func_fatal_help "you must specify an install program"
1921
1922 test -n "$prev" && \
1923 func_fatal_help "the \`$prev' option requires an argument"
1924
1925 if test -z "$files"; then
1926 if test -z "$dest"; then
1927 func_fatal_help "no file or destination specified"
1928 else
1929 func_fatal_help "you must specify a destination"
1930 fi
1931 fi
1932
1933 # Strip any trailing slash from the destination.
1934 func_stripname '' '/' "$dest"
1935 dest=$func_stripname_result
1936
1937 # Check to see that the destination is a directory.
1938 test -d "$dest" && isdir=yes
1939 if test "$isdir" = yes; then
1940 destdir="$dest"
1941 destname=
1942 else
1943 func_dirname_and_basename "$dest" "" "."
1944 destdir="$func_dirname_result"
1945 destname="$func_basename_result"
1946
1947 # Not a directory, so check to see that there is only one file specified.
1948 set dummy $files; shift
1949 test "$#" -gt 1 && \
1950 func_fatal_help "\`$dest' is not a directory"
1951 fi
1952 case $destdir in
1953 [\\/]* | [A-Za-z]:[\\/]*) ;;
1954 *)
1955 for file in $files; do
1956 case $file in
1957 *.lo) ;;
1958 *)
1959 func_fatal_help "\`$destdir' must be an absolute directory name"
1960 ;;
1961 esac
1962 done
1963 ;;
1964 esac
1965
1966 # This variable tells wrapper scripts just to set variables rather
1967 # than running their programs.
1968 libtool_install_magic="$magic"
1969
1970 staticlibs=
1971 future_libdirs=
1972 current_libdirs=
1973 for file in $files; do
1974
1975 # Do each installation.
1976 case $file in
1977 *.$libext)
1978 # Do the static libraries later.
1979 staticlibs="$staticlibs $file"
1980 ;;
1981
1982 *.la)
1983 # Check to see that this really is a libtool archive.
1984 func_lalib_unsafe_p "$file" \
1985 || func_fatal_help "\`$file' is not a valid libtool archive"
1986
1987 library_names=
1988 old_library=
1989 relink_command=
1990 func_source "$file"
1991
1992 # Add the libdir to current_libdirs if it is the destination.
1993 if test "X$destdir" = "X$libdir"; then
1994 case "$current_libdirs " in
1995 *" $libdir "*) ;;
1996 *) current_libdirs="$current_libdirs $libdir" ;;
1997 esac
1998 else
1999 # Note the libdir as a future libdir.
2000 case "$future_libdirs " in
2001 *" $libdir "*) ;;
2002 *) future_libdirs="$future_libdirs $libdir" ;;
2003 esac
2004 fi
2005
2006 func_dirname "$file" "/" ""
2007 dir="$func_dirname_result"
2008 dir="$dir$objdir"
2009
2010 if test -n "$relink_command"; then
2011 # Determine the prefix the user has applied to our future dir.
2012 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2013
2014 # Don't allow the user to place us outside of our expected
2015 # location b/c this prevents finding dependent libraries that
2016 # are installed to the same prefix.
2017 # At present, this check doesn't affect windows .dll's that
2018 # are installed into $libdir/../bin (currently, that works fine)
2019 # but it's something to keep an eye on.
2020 test "$inst_prefix_dir" = "$destdir" && \
2021 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2022
2023 if test -n "$inst_prefix_dir"; then
2024 # Stick the inst_prefix_dir data into the link command.
2025 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2026 else
2027 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2028 fi
2029
2030 func_warning "relinking \`$file'"
2031 func_show_eval "$relink_command" \
2032 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2033 fi
2034
2035 # See the names of the shared library.
2036 set dummy $library_names; shift
2037 if test -n "$1"; then
2038 realname="$1"
2039 shift
2040
2041 srcname="$realname"
2042 test -n "$relink_command" && srcname="$realname"T
2043
2044 # Install the shared library and build the symlinks.
2045 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2046 'exit $?'
2047 tstripme="$stripme"
2048 case $host_os in
2049 cygwin* | mingw* | pw32* | cegcc*)
2050 case $realname in
2051 *.dll.a)
2052 tstripme=""
2053 ;;
2054 esac
2055 ;;
2056 esac
2057 if test -n "$tstripme" && test -n "$striplib"; then
2058 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2059 fi
2060
2061 if test "$#" -gt 0; then
2062 # Delete the old symlinks, and create new ones.
2063 # Try `ln -sf' first, because the `ln' binary might depend on
2064 # the symlink we replace! Solaris /bin/ln does not understand -f,
2065 # so we also need to try rm && ln -s.
2066 for linkname
2067 do
2068 test "$linkname" != "$realname" \
2069 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2070 done
2071 fi
2072
2073 # Do each command in the postinstall commands.
2074 lib="$destdir/$realname"
2075 func_execute_cmds "$postinstall_cmds" 'exit $?'
2076 fi
2077
2078 # Install the pseudo-library for information purposes.
2079 func_basename "$file"
2080 name="$func_basename_result"
2081 instname="$dir/$name"i
2082 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2083
2084 # Maybe install the static library, too.
2085 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2086 ;;
2087
2088 *.lo)
2089 # Install (i.e. copy) a libtool object.
2090
2091 # Figure out destination file name, if it wasn't already specified.
2092 if test -n "$destname"; then
2093 destfile="$destdir/$destname"
2094 else
2095 func_basename "$file"
2096 destfile="$func_basename_result"
2097 destfile="$destdir/$destfile"
2098 fi
2099
2100 # Deduce the name of the destination old-style object file.
2101 case $destfile in
2102 *.lo)
2103 func_lo2o "$destfile"
2104 staticdest=$func_lo2o_result
2105 ;;
2106 *.$objext)
2107 staticdest="$destfile"
2108 destfile=
2109 ;;
2110 *)
2111 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2112 ;;
2113 esac
2114
2115 # Install the libtool object if requested.
2116 test -n "$destfile" && \
2117 func_show_eval "$install_prog $file $destfile" 'exit $?'
2118
2119 # Install the old object if enabled.
2120 if test "$build_old_libs" = yes; then
2121 # Deduce the name of the old-style object file.
2122 func_lo2o "$file"
2123 staticobj=$func_lo2o_result
2124 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2125 fi
2126 exit $EXIT_SUCCESS
2127 ;;
2128
2129 *)
2130 # Figure out destination file name, if it wasn't already specified.
2131 if test -n "$destname"; then
2132 destfile="$destdir/$destname"
2133 else
2134 func_basename "$file"
2135 destfile="$func_basename_result"
2136 destfile="$destdir/$destfile"
2137 fi
2138
2139 # If the file is missing, and there is a .exe on the end, strip it
2140 # because it is most likely a libtool script we actually want to
2141 # install
2142 stripped_ext=""
2143 case $file in
2144 *.exe)
2145 if test ! -f "$file"; then
2146 func_stripname '' '.exe' "$file"
2147 file=$func_stripname_result
2148 stripped_ext=".exe"
2149 fi
2150 ;;
2151 esac
2152
2153 # Do a test to see if this is really a libtool program.
2154 case $host in
2155 *cygwin* | *mingw*)
2156 if func_ltwrapper_executable_p "$file"; then
2157 func_ltwrapper_scriptname "$file"
2158 wrapper=$func_ltwrapper_scriptname_result
2159 else
2160 func_stripname '' '.exe' "$file"
2161 wrapper=$func_stripname_result
2162 fi
2163 ;;
2164 *)
2165 wrapper=$file
2166 ;;
2167 esac
2168 if func_ltwrapper_script_p "$wrapper"; then
2169 notinst_deplibs=
2170 relink_command=
2171
2172 func_source "$wrapper"
2173
2174 # Check the variables that should have been set.
2175 test -z "$generated_by_libtool_version" && \
2176 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2177
2178 finalize=yes
2179 for lib in $notinst_deplibs; do
2180 # Check to see that each library is installed.
2181 libdir=
2182 if test -f "$lib"; then
2183 func_source "$lib"
2184 fi
2185 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2186 if test -n "$libdir" && test ! -f "$libfile"; then
2187 func_warning "\`$lib' has not been installed in \`$libdir'"
2188 finalize=no
2189 fi
2190 done
2191
2192 relink_command=
2193 func_source "$wrapper"
2194
2195 outputname=
2196 if test "$fast_install" = no && test -n "$relink_command"; then
2197 $opt_dry_run || {
2198 if test "$finalize" = yes; then
2199 tmpdir=`func_mktempdir`
2200 func_basename "$file$stripped_ext"
2201 file="$func_basename_result"
2202 outputname="$tmpdir/$file"
2203 # Replace the output file specification.
2204 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2205
2206 $opt_silent || {
2207 func_quote_for_expand "$relink_command"
2208 eval "func_echo $func_quote_for_expand_result"
2209 }
2210 if eval "$relink_command"; then :
2211 else
2212 func_error "error: relink \`$file' with the above command before installing it"
2213 $opt_dry_run || ${RM}r "$tmpdir"
2214 continue
2215 fi
2216 file="$outputname"
2217 else
2218 func_warning "cannot relink \`$file'"
2219 fi
2220 }
2221 else
2222 # Install the binary that we compiled earlier.
2223 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2224 fi
2225 fi
2226
2227 # remove .exe since cygwin /usr/bin/install will append another
2228 # one anyway
2229 case $install_prog,$host in
2230 */usr/bin/install*,*cygwin*)
2231 case $file:$destfile in
2232 *.exe:*.exe)
2233 # this is ok
2234 ;;
2235 *.exe:*)
2236 destfile=$destfile.exe
2237 ;;
2238 *:*.exe)
2239 func_stripname '' '.exe' "$destfile"
2240 destfile=$func_stripname_result
2241 ;;
2242 esac
2243 ;;
2244 esac
2245 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2246 $opt_dry_run || if test -n "$outputname"; then
2247 ${RM}r "$tmpdir"
2248 fi
2249 ;;
2250 esac
2251 done
2252
2253 for file in $staticlibs; do
2254 func_basename "$file"
2255 name="$func_basename_result"
2256
2257 # Set up the ranlib parameters.
2258 oldlib="$destdir/$name"
2259
2260 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2261
2262 if test -n "$stripme" && test -n "$old_striplib"; then
2263 func_show_eval "$old_striplib $oldlib" 'exit $?'
2264 fi
2265
2266 # Do each command in the postinstall commands.
2267 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2268 done
2269
2270 test -n "$future_libdirs" && \
2271 func_warning "remember to run \`$progname --finish$future_libdirs'"
2272
2273 if test -n "$current_libdirs"; then
2274 # Maybe just do a dry run.
2275 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2276 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2277 else
2278 exit $EXIT_SUCCESS
2279 fi
2280 }
2281
2282 test "$mode" = install && func_mode_install ${1+"$@"}
2283
2284
2285 # func_generate_dlsyms outputname originator pic_p
2286 # Extract symbols from dlprefiles and create ${outputname}S.o with
2287 # a dlpreopen symbol table.
2288 func_generate_dlsyms ()
2289 {
2290 $opt_debug
2291 my_outputname="$1"
2292 my_originator="$2"
2293 my_pic_p="${3-no}"
2294 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2295 my_dlsyms=
2296
2297 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2298 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2299 my_dlsyms="${my_outputname}S.c"
2300 else
2301 func_error "not configured to extract global symbols from dlpreopened files"
2302 fi
2303 fi
2304
2305 if test -n "$my_dlsyms"; then
2306 case $my_dlsyms in
2307 "") ;;
2308 *.c)
2309 # Discover the nlist of each of the dlfiles.
2310 nlist="$output_objdir/${my_outputname}.nm"
2311
2312 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2313
2314 # Parse the name list into a source file.
2315 func_verbose "creating $output_objdir/$my_dlsyms"
2316
2317 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2318 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2319 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2320
2321 #ifdef __cplusplus
2322 extern \"C\" {
2323 #endif
2324
2325 /* External symbol declarations for the compiler. */\
2326 "
2327
2328 if test "$dlself" = yes; then
2329 func_verbose "generating symbol list for \`$output'"
2330
2331 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2332
2333 # Add our own program objects to the symbol list.
2334 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2335 for progfile in $progfiles; do
2336 func_verbose "extracting global C symbols from \`$progfile'"
2337 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2338 done
2339
2340 if test -n "$exclude_expsyms"; then
2341 $opt_dry_run || {
2342 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2343 eval '$MV "$nlist"T "$nlist"'
2344 }
2345 fi
2346
2347 if test -n "$export_symbols_regex"; then
2348 $opt_dry_run || {
2349 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2350 eval '$MV "$nlist"T "$nlist"'
2351 }
2352 fi
2353
2354 # Prepare the list of exported symbols
2355 if test -z "$export_symbols"; then
2356 export_symbols="$output_objdir/$outputname.exp"
2357 $opt_dry_run || {
2358 $RM $export_symbols
2359 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2360 case $host in
2361 *cygwin* | *mingw* | *cegcc* )
2362 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2363 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2364 ;;
2365 esac
2366 }
2367 else
2368 $opt_dry_run || {
2369 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2370 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2371 eval '$MV "$nlist"T "$nlist"'
2372 case $host in
2373 *cygwin | *mingw* | *cegcc* )
2374 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2375 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2376 ;;
2377 esac
2378 }
2379 fi
2380 fi
2381
2382 for dlprefile in $dlprefiles; do
2383 func_verbose "extracting global C symbols from \`$dlprefile'"
2384 func_basename "$dlprefile"
2385 name="$func_basename_result"
2386 $opt_dry_run || {
2387 eval '$ECHO ": $name " >> "$nlist"'
2388 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2389 }
2390 done
2391
2392 $opt_dry_run || {
2393 # Make sure we have at least an empty file.
2394 test -f "$nlist" || : > "$nlist"
2395
2396 if test -n "$exclude_expsyms"; then
2397 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2398 $MV "$nlist"T "$nlist"
2399 fi
2400
2401 # Try sorting and uniquifying the output.
2402 if $GREP -v "^: " < "$nlist" |
2403 if sort -k 3 </dev/null >/dev/null 2>&1; then
2404 sort -k 3
2405 else
2406 sort +2
2407 fi |
2408 uniq > "$nlist"S; then
2409 :
2410 else
2411 $GREP -v "^: " < "$nlist" > "$nlist"S
2412 fi
2413
2414 if test -f "$nlist"S; then
2415 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2416 else
2417 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2418 fi
2419
2420 $ECHO >> "$output_objdir/$my_dlsyms" "\
2421
2422 /* The mapping between symbol names and symbols. */
2423 typedef struct {
2424 const char *name;
2425 void *address;
2426 } lt_dlsymlist;
2427 "
2428 case $host in
2429 *cygwin* | *mingw* | *cegcc* )
2430 $ECHO >> "$output_objdir/$my_dlsyms" "\
2431 /* DATA imports from DLLs on WIN32 con't be const, because
2432 runtime relocations are performed -- see ld's documentation
2433 on pseudo-relocs. */"
2434 lt_dlsym_const= ;;
2435 *osf5*)
2436 echo >> "$output_objdir/$my_dlsyms" "\
2437 /* This system does not cope well with relocations in const data */"
2438 lt_dlsym_const= ;;
2439 *)
2440 lt_dlsym_const=const ;;
2441 esac
2442
2443 $ECHO >> "$output_objdir/$my_dlsyms" "\
2444 extern $lt_dlsym_const lt_dlsymlist
2445 lt_${my_prefix}_LTX_preloaded_symbols[];
2446 $lt_dlsym_const lt_dlsymlist
2447 lt_${my_prefix}_LTX_preloaded_symbols[] =
2448 {\
2449 { \"$my_originator\", (void *) 0 },"
2450
2451 case $need_lib_prefix in
2452 no)
2453 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2454 ;;
2455 *)
2456 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2457 ;;
2458 esac
2459 $ECHO >> "$output_objdir/$my_dlsyms" "\
2460 {0, (void *) 0}
2461 };
2462
2463 /* This works around a problem in FreeBSD linker */
2464 #ifdef FREEBSD_WORKAROUND
2465 static const void *lt_preloaded_setup() {
2466 return lt_${my_prefix}_LTX_preloaded_symbols;
2467 }
2468 #endif
2469
2470 #ifdef __cplusplus
2471 }
2472 #endif\
2473 "
2474 } # !$opt_dry_run
2475
2476 pic_flag_for_symtable=
2477 case "$compile_command " in
2478 *" -static "*) ;;
2479 *)
2480 case $host in
2481 # compiling the symbol table file with pic_flag works around
2482 # a FreeBSD bug that causes programs to crash when -lm is
2483 # linked before any other PIC object. But we must not use
2484 # pic_flag when linking with -static. The problem exists in
2485 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2486 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2487 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2488 *-*-hpux*)
2489 pic_flag_for_symtable=" $pic_flag" ;;
2490 *)
2491 if test "X$my_pic_p" != Xno; then
2492 pic_flag_for_symtable=" $pic_flag"
2493 fi
2494 ;;
2495 esac
2496 ;;
2497 esac
2498 symtab_cflags=
2499 for arg in $LTCFLAGS; do
2500 case $arg in
2501 -pie | -fpie | -fPIE) ;;
2502 *) symtab_cflags="$symtab_cflags $arg" ;;
2503 esac
2504 done
2505
2506 # Now compile the dynamic symbol file.
2507 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2508
2509 # Clean up the generated files.
2510 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2511
2512 # Transform the symbol file into the correct name.
2513 symfileobj="$output_objdir/${my_outputname}S.$objext"
2514 case $host in
2515 *cygwin* | *mingw* | *cegcc* )
2516 if test -f "$output_objdir/$my_outputname.def"; then
2517 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2518 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2519 else
2520 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2521 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2522 fi
2523 ;;
2524 *)
2525 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2527 ;;
2528 esac
2529 ;;
2530 *)
2531 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2532 ;;
2533 esac
2534 else
2535 # We keep going just in case the user didn't refer to
2536 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2537 # really was required.
2538
2539 # Nullify the symbol file.
2540 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2541 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2542 fi
2543 }
2544
2545 # func_win32_libid arg
2546 # return the library type of file 'arg'
2547 #
2548 # Need a lot of goo to handle *both* DLLs and import libs
2549 # Has to be a shell function in order to 'eat' the argument
2550 # that is supplied when $file_magic_command is called.
2551 func_win32_libid ()
2552 {
2553 $opt_debug
2554 win32_libid_type="unknown"
2555 win32_fileres=`file -L $1 2>/dev/null`
2556 case $win32_fileres in
2557 *ar\ archive\ import\ library*) # definitely import
2558 win32_libid_type="x86 archive import"
2559 ;;
2560 *ar\ archive*) # could be an import, or static
2561 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2562 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null ; then
2563 win32_nmres=`eval $NM -f posix -A $1 |
2564 $SED -n -e '
2565 1,100{
2566 / I /{
2567 s,.*,import,
2568 p
2569 q
2570 }
2571 }'`
2572 case $win32_nmres in
2573 import*) win32_libid_type="x86 archive import";;
2574 *) win32_libid_type="x86 archive static";;
2575 esac
2576 fi
2577 ;;
2578 *DLL*)
2579 win32_libid_type="x86 DLL"
2580 ;;
2581 *executable*) # but shell scripts are "executable" too...
2582 case $win32_fileres in
2583 *MS\ Windows\ PE\ Intel*)
2584 win32_libid_type="x86 DLL"
2585 ;;
2586 esac
2587 ;;
2588 esac
2589 $ECHO "$win32_libid_type"
2590 }
2591
2592
2593
2594 # func_extract_an_archive dir oldlib
2595 func_extract_an_archive ()
2596 {
2597 $opt_debug
2598 f_ex_an_ar_dir="$1"; shift
2599 f_ex_an_ar_oldlib="$1"
2600 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2601 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2602 :
2603 else
2604 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2605 fi
2606 }
2607
2608
2609 # func_extract_archives gentop oldlib ...
2610 func_extract_archives ()
2611 {
2612 $opt_debug
2613 my_gentop="$1"; shift
2614 my_oldlibs=${1+"$@"}
2615 my_oldobjs=""
2616 my_xlib=""
2617 my_xabs=""
2618 my_xdir=""
2619
2620 for my_xlib in $my_oldlibs; do
2621 # Extract the objects.
2622 case $my_xlib in
2623 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2624 *) my_xabs=`pwd`"/$my_xlib" ;;
2625 esac
2626 func_basename "$my_xlib"
2627 my_xlib="$func_basename_result"
2628 my_xlib_u=$my_xlib
2629 while :; do
2630 case " $extracted_archives " in
2631 *" $my_xlib_u "*)
2632 func_arith $extracted_serial + 1
2633 extracted_serial=$func_arith_result
2634 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2635 *) break ;;
2636 esac
2637 done
2638 extracted_archives="$extracted_archives $my_xlib_u"
2639 my_xdir="$my_gentop/$my_xlib_u"
2640
2641 func_mkdir_p "$my_xdir"
2642
2643 case $host in
2644 *-darwin*)
2645 func_verbose "Extracting $my_xabs"
2646 # Do not bother doing anything if just a dry run
2647 $opt_dry_run || {
2648 darwin_orig_dir=`pwd`
2649 cd $my_xdir || exit $?
2650 darwin_archive=$my_xabs
2651 darwin_curdir=`pwd`
2652 darwin_base_archive=`basename "$darwin_archive"`
2653 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2654 if test -n "$darwin_arches"; then
2655 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2656 darwin_arch=
2657 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2658 for darwin_arch in $darwin_arches ; do
2659 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2660 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2661 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2662 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2663 cd "$darwin_curdir"
2664 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2665 done # $darwin_arches
2666 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2667 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2668 darwin_file=
2669 darwin_files=
2670 for darwin_file in $darwin_filelist; do
2671 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2672 $LIPO -create -output "$darwin_file" $darwin_files
2673 done # $darwin_filelist
2674 $RM -rf unfat-$$
2675 cd "$darwin_orig_dir"
2676 else
2677 cd $darwin_orig_dir
2678 func_extract_an_archive "$my_xdir" "$my_xabs"
2679 fi # $darwin_arches
2680 } # !$opt_dry_run
2681 ;;
2682 *)
2683 func_extract_an_archive "$my_xdir" "$my_xabs"
2684 ;;
2685 esac
2686 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2687 done
2688
2689 func_extract_archives_result="$my_oldobjs"
2690 }
2691
2692
2693
2694 # func_emit_wrapper_part1 [arg=no]
2695 #
2696 # Emit the first part of a libtool wrapper script on stdout.
2697 # For more information, see the description associated with
2698 # func_emit_wrapper(), below.
2699 func_emit_wrapper_part1 ()
2700 {
2701 func_emit_wrapper_part1_arg1=no
2702 if test -n "$1" ; then
2703 func_emit_wrapper_part1_arg1=$1
2704 fi
2705
2706 $ECHO "\
2707 #! $SHELL
2708
2709 # $output - temporary wrapper script for $objdir/$outputname
2710 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2711 #
2712 # The $output program cannot be directly executed until all the libtool
2713 # libraries that it depends on are installed.
2714 #
2715 # This wrapper script should never be moved out of the build directory.
2716 # If it is, it will not operate correctly.
2717
2718 # Sed substitution that helps us do robust quoting. It backslashifies
2719 # metacharacters that are still active within double-quoted strings.
2720 Xsed='${SED} -e 1s/^X//'
2721 sed_quote_subst='$sed_quote_subst'
2722
2723 # Be Bourne compatible
2724 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2725 emulate sh
2726 NULLCMD=:
2727 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2728 # is contrary to our usage. Disable this feature.
2729 alias -g '\${1+\"\$@\"}'='\"\$@\"'
2730 setopt NO_GLOB_SUBST
2731 else
2732 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2733 fi
2734 BIN_SH=xpg4; export BIN_SH # for Tru64
2735 DUALCASE=1; export DUALCASE # for MKS sh
2736
2737 # The HP-UX ksh and POSIX shell print the target directory to stdout
2738 # if CDPATH is set.
2739 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2740
2741 relink_command=\"$relink_command\"
2742
2743 # This environment variable determines our operation mode.
2744 if test \"\$libtool_install_magic\" = \"$magic\"; then
2745 # install mode needs the following variables:
2746 generated_by_libtool_version='$macro_version'
2747 notinst_deplibs='$notinst_deplibs'
2748 else
2749 # When we are sourced in execute mode, \$file and \$ECHO are already set.
2750 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2751 ECHO=\"$qecho\"
2752 file=\"\$0\"
2753 # Make sure echo works.
2754 if test \"X\$1\" = X--no-reexec; then
2755 # Discard the --no-reexec flag, and continue.
2756 shift
2757 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2758 # Yippee, \$ECHO works!
2759 :
2760 else
2761 # Restart under the correct shell, and then maybe \$ECHO will work.
2762 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2763 fi
2764 fi\
2765 "
2766 $ECHO "\
2767
2768 # Find the directory that this script lives in.
2769 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2770 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2771
2772 # Follow symbolic links until we get to the real thisdir.
2773 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2774 while test -n \"\$file\"; do
2775 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2776
2777 # If there was a directory component, then change thisdir.
2778 if test \"x\$destdir\" != \"x\$file\"; then
2779 case \"\$destdir\" in
2780 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2781 *) thisdir=\"\$thisdir/\$destdir\" ;;
2782 esac
2783 fi
2784
2785 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2786 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2787 done
2788 "
2789 }
2790 # end: func_emit_wrapper_part1
2791
2792 # func_emit_wrapper_part2 [arg=no]
2793 #
2794 # Emit the second part of a libtool wrapper script on stdout.
2795 # For more information, see the description associated with
2796 # func_emit_wrapper(), below.
2797 func_emit_wrapper_part2 ()
2798 {
2799 func_emit_wrapper_part2_arg1=no
2800 if test -n "$1" ; then
2801 func_emit_wrapper_part2_arg1=$1
2802 fi
2803
2804 $ECHO "\
2805
2806 # Usually 'no', except on cygwin/mingw when embedded into
2807 # the cwrapper.
2808 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2809 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2810 # special case for '.'
2811 if test \"\$thisdir\" = \".\"; then
2812 thisdir=\`pwd\`
2813 fi
2814 # remove .libs from thisdir
2815 case \"\$thisdir\" in
2816 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2817 $objdir ) thisdir=. ;;
2818 esac
2819 fi
2820
2821 # Try to get the absolute directory name.
2822 absdir=\`cd \"\$thisdir\" && pwd\`
2823 test -n \"\$absdir\" && thisdir=\"\$absdir\"
2824 "
2825
2826 if test "$fast_install" = yes; then
2827 $ECHO "\
2828 program=lt-'$outputname'$exeext
2829 progdir=\"\$thisdir/$objdir\"
2830
2831 if test ! -f \"\$progdir/\$program\" ||
2832 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2833 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2834
2835 file=\"\$\$-\$program\"
2836
2837 if test ! -d \"\$progdir\"; then
2838 $MKDIR \"\$progdir\"
2839 else
2840 $RM \"\$progdir/\$file\"
2841 fi"
2842
2843 $ECHO "\
2844
2845 # relink executable if necessary
2846 if test -n \"\$relink_command\"; then
2847 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2848 else
2849 $ECHO \"\$relink_command_output\" >&2
2850 $RM \"\$progdir/\$file\"
2851 exit 1
2852 fi
2853 fi
2854
2855 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2856 { $RM \"\$progdir/\$program\";
2857 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2858 $RM \"\$progdir/\$file\"
2859 fi"
2860 else
2861 $ECHO "\
2862 program='$outputname'
2863 progdir=\"\$thisdir/$objdir\"
2864 "
2865 fi
2866
2867 $ECHO "\
2868
2869 if test -f \"\$progdir/\$program\"; then"
2870
2871 # Export our shlibpath_var if we have one.
2872 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2873 $ECHO "\
2874 # Add our own library path to $shlibpath_var
2875 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2876
2877 # Some systems cannot cope with colon-terminated $shlibpath_var
2878 # The second colon is a workaround for a bug in BeOS R4 sed
2879 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2880
2881 export $shlibpath_var
2882 "
2883 fi
2884
2885 # fixup the dll searchpath if we need to.
2886 if test -n "$dllsearchpath"; then
2887 $ECHO "\
2888 # Add the dll search path components to the executable PATH
2889 PATH=$dllsearchpath:\$PATH
2890 "
2891 fi
2892
2893 $ECHO "\
2894 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2895 # Run the actual program with our arguments.
2896 "
2897 case $host in
2898 # Backslashes separate directories on plain windows
2899 *-*-mingw | *-*-os2* | *-cegcc*)
2900 $ECHO "\
2901 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2902 "
2903 ;;
2904
2905 *)
2906 $ECHO "\
2907 exec \"\$progdir/\$program\" \${1+\"\$@\"}
2908 "
2909 ;;
2910 esac
2911 $ECHO "\
2912 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2913 exit 1
2914 fi
2915 else
2916 # The program doesn't exist.
2917 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2918 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2919 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2920 exit 1
2921 fi
2922 fi\
2923 "
2924 }
2925 # end: func_emit_wrapper_part2
2926
2927
2928 # func_emit_wrapper [arg=no]
2929 #
2930 # Emit a libtool wrapper script on stdout.
2931 # Don't directly open a file because we may want to
2932 # incorporate the script contents within a cygwin/mingw
2933 # wrapper executable. Must ONLY be called from within
2934 # func_mode_link because it depends on a number of variables
2935 # set therein.
2936 #
2937 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2938 # variable will take. If 'yes', then the emitted script
2939 # will assume that the directory in which it is stored is
2940 # the $objdir directory. This is a cygwin/mingw-specific
2941 # behavior.
2942 func_emit_wrapper ()
2943 {
2944 func_emit_wrapper_arg1=no
2945 if test -n "$1" ; then
2946 func_emit_wrapper_arg1=$1
2947 fi
2948
2949 # split this up so that func_emit_cwrapperexe_src
2950 # can call each part independently.
2951 func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2952 func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2953 }
2954
2955
2956 # func_to_host_path arg
2957 #
2958 # Convert paths to host format when used with build tools.
2959 # Intended for use with "native" mingw (where libtool itself
2960 # is running under the msys shell), or in the following cross-
2961 # build environments:
2962 # $build $host
2963 # mingw (msys) mingw [e.g. native]
2964 # cygwin mingw
2965 # *nix + wine mingw
2966 # where wine is equipped with the `winepath' executable.
2967 # In the native mingw case, the (msys) shell automatically
2968 # converts paths for any non-msys applications it launches,
2969 # but that facility isn't available from inside the cwrapper.
2970 # Similar accommodations are necessary for $host mingw and
2971 # $build cygwin. Calling this function does no harm for other
2972 # $host/$build combinations not listed above.
2973 #
2974 # ARG is the path (on $build) that should be converted to
2975 # the proper representation for $host. The result is stored
2976 # in $func_to_host_path_result.
2977 func_to_host_path ()
2978 {
2979 func_to_host_path_result="$1"
2980 if test -n "$1" ; then
2981 case $host in
2982 *mingw* )
2983 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2984 case $build in
2985 *mingw* ) # actually, msys
2986 # awkward: cmd appends spaces to result
2987 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2988 func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2989 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2990 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2991 $SED -e "$lt_sed_naive_backslashify"`
2992 ;;
2993 *cygwin* )
2994 func_to_host_path_tmp1=`cygpath -w "$1"`
2995 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2996 $SED -e "$lt_sed_naive_backslashify"`
2997 ;;
2998 * )
2999 # Unfortunately, winepath does not exit with a non-zero
3000 # error code, so we are forced to check the contents of
3001 # stdout. On the other hand, if the command is not
3002 # found, the shell will set an exit code of 127 and print
3003 # *an error message* to stdout. So we must check for both
3004 # error code of zero AND non-empty stdout, which explains
3005 # the odd construction:
3006 func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3007 if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3008 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3009 $SED -e "$lt_sed_naive_backslashify"`
3010 else
3011 # Allow warning below.
3012 func_to_host_path_result=""
3013 fi
3014 ;;
3015 esac
3016 if test -z "$func_to_host_path_result" ; then
3017 #func_error "Could not determine host path corresponding to"
3018 #func_error " '$1'"
3019 #func_error "Continuing, but uninstalled executables may not work."
3020 # Fallback:
3021 func_to_host_path_result="$1"
3022 fi
3023 ;;
3024 esac
3025 fi
3026 }
3027 # end: func_to_host_path
3028
3029 # func_to_host_pathlist arg
3030 #
3031 # Convert pathlists to host format when used with build tools.
3032 # See func_to_host_path(), above. This function supports the
3033 # following $build/$host combinations (but does no harm for
3034 # combinations not listed here):
3035 # $build $host
3036 # mingw (msys) mingw [e.g. native]
3037 # cygwin mingw
3038 # *nix + wine mingw
3039 #
3040 # Path separators are also converted from $build format to
3041 # $host format. If ARG begins or ends with a path separator
3042 # character, it is preserved (but converted to $host format)
3043 # on output.
3044 #
3045 # ARG is a pathlist (on $build) that should be converted to
3046 # the proper representation on $host. The result is stored
3047 # in $func_to_host_pathlist_result.
3048 func_to_host_pathlist ()
3049 {
3050 func_to_host_pathlist_result="$1"
3051 if test -n "$1" ; then
3052 case $host in
3053 *mingw* )
3054 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3055 # Remove leading and trailing path separator characters from
3056 # ARG. msys behavior is inconsistent here, cygpath turns them
3057 # into '.;' and ';.', and winepath ignores them completely.
3058 func_to_host_pathlist_tmp2="$1"
3059 # Once set for this call, this variable should not be
3060 # reassigned. It is used in tha fallback case.
3061 func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3062 $SED -e 's|^:*||' -e 's|:*$||'`
3063 case $build in
3064 *mingw* ) # Actually, msys.
3065 # Awkward: cmd appends spaces to result.
3066 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3067 func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3068 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3069 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3070 $SED -e "$lt_sed_naive_backslashify"`
3071 ;;
3072 *cygwin* )
3073 func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3074 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3075 $SED -e "$lt_sed_naive_backslashify"`
3076 ;;
3077 * )
3078 # unfortunately, winepath doesn't convert pathlists
3079 func_to_host_pathlist_result=""
3080 func_to_host_pathlist_oldIFS=$IFS
3081 IFS=:
3082 for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3083 IFS=$func_to_host_pathlist_oldIFS
3084 if test -n "$func_to_host_pathlist_f" ; then
3085 func_to_host_path "$func_to_host_pathlist_f"
3086 if test -n "$func_to_host_path_result" ; then
3087 if test -z "$func_to_host_pathlist_result" ; then
3088 func_to_host_pathlist_result="$func_to_host_path_result"
3089 else
3090 func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3091 fi
3092 fi
3093 fi
3094 IFS=:
3095 done
3096 IFS=$func_to_host_pathlist_oldIFS
3097 ;;
3098 esac
3099 if test -z "$func_to_host_pathlist_result" ; then
3100 func_error "Could not determine the host path(s) corresponding to"
3101 func_error " '$1'"
3102 func_error "Continuing, but uninstalled executables may not work."
3103 # Fallback. This may break if $1 contains DOS-style drive
3104 # specifications. The fix is not to complicate the expression
3105 # below, but for the user to provide a working wine installation
3106 # with winepath so that path translation in the cross-to-mingw
3107 # case works properly.
3108 lt_replace_pathsep_nix_to_dos="s|:|;|g"
3109 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3110 $SED -e "$lt_replace_pathsep_nix_to_dos"`
3111 fi
3112 # Now, add the leading and trailing path separators back
3113 case "$1" in
3114 :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3115 ;;
3116 esac
3117 case "$1" in
3118 *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3119 ;;
3120 esac
3121 ;;
3122 esac
3123 fi
3124 }
3125 # end: func_to_host_pathlist
3126
3127 # func_emit_cwrapperexe_src
3128 # emit the source code for a wrapper executable on stdout
3129 # Must ONLY be called from within func_mode_link because
3130 # it depends on a number of variable set therein.
3131 func_emit_cwrapperexe_src ()
3132 {
3133 cat <<EOF
3134
3135 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3136 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3137
3138 The $output program cannot be directly executed until all the libtool
3139 libraries that it depends on are installed.
3140
3141 This wrapper executable should never be moved out of the build directory.
3142 If it is, it will not operate correctly.
3143
3144 Currently, it simply execs the wrapper *script* "$SHELL $output",
3145 but could eventually absorb all of the scripts functionality and
3146 exec $objdir/$outputname directly.
3147 */
3148 EOF
3149 cat <<"EOF"
3150 #include <stdio.h>
3151 #include <stdlib.h>
3152 #ifdef _MSC_VER
3153 # include <direct.h>
3154 # include <process.h>
3155 # include <io.h>
3156 # define setmode _setmode
3157 #else
3158 # include <unistd.h>
3159 # include <stdint.h>
3160 # ifdef __CYGWIN__
3161 # include <io.h>
3162 # define HAVE_SETENV
3163 # ifdef __STRICT_ANSI__
3164 char *realpath (const char *, char *);
3165 int putenv (char *);
3166 int setenv (const char *, const char *, int);
3167 # endif
3168 # endif
3169 #endif
3170 #include <malloc.h>
3171 #include <stdarg.h>
3172 #include <assert.h>
3173 #include <string.h>
3174 #include <ctype.h>
3175 #include <errno.h>
3176 #include <fcntl.h>
3177 #include <sys/stat.h>
3178
3179 #if defined(PATH_MAX)
3180 # define LT_PATHMAX PATH_MAX
3181 #elif defined(MAXPATHLEN)
3182 # define LT_PATHMAX MAXPATHLEN
3183 #else
3184 # define LT_PATHMAX 1024
3185 #endif
3186
3187 #ifndef S_IXOTH
3188 # define S_IXOTH 0
3189 #endif
3190 #ifndef S_IXGRP
3191 # define S_IXGRP 0
3192 #endif
3193
3194 #ifdef _MSC_VER
3195 # define S_IXUSR _S_IEXEC
3196 # define stat _stat
3197 # ifndef _INTPTR_T_DEFINED
3198 # define intptr_t int
3199 # endif
3200 #endif
3201
3202 #ifndef DIR_SEPARATOR
3203 # define DIR_SEPARATOR '/'
3204 # define PATH_SEPARATOR ':'
3205 #endif
3206
3207 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3208 defined (__OS2__)
3209 # define HAVE_DOS_BASED_FILE_SYSTEM
3210 # define FOPEN_WB "wb"
3211 # ifndef DIR_SEPARATOR_2
3212 # define DIR_SEPARATOR_2 '\\'
3213 # endif
3214 # ifndef PATH_SEPARATOR_2
3215 # define PATH_SEPARATOR_2 ';'
3216 # endif
3217 #endif
3218
3219 #ifndef DIR_SEPARATOR_2
3220 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3221 #else /* DIR_SEPARATOR_2 */
3222 # define IS_DIR_SEPARATOR(ch) \
3223 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3224 #endif /* DIR_SEPARATOR_2 */
3225
3226 #ifndef PATH_SEPARATOR_2
3227 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3228 #else /* PATH_SEPARATOR_2 */
3229 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3230 #endif /* PATH_SEPARATOR_2 */
3231
3232 #ifdef __CYGWIN__
3233 # define FOPEN_WB "wb"
3234 #endif
3235
3236 #ifndef FOPEN_WB
3237 # define FOPEN_WB "w"
3238 #endif
3239 #ifndef _O_BINARY
3240 # define _O_BINARY 0
3241 #endif
3242
3243 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3244 #define XFREE(stale) do { \
3245 if (stale) { free ((void *) stale); stale = 0; } \
3246 } while (0)
3247
3248 #undef LTWRAPPER_DEBUGPRINTF
3249 #if defined DEBUGWRAPPER
3250 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3251 static void
3252 ltwrapper_debugprintf (const char *fmt, ...)
3253 {
3254 va_list args;
3255 va_start (args, fmt);
3256 (void) vfprintf (stderr, fmt, args);
3257 va_end (args);
3258 }
3259 #else
3260 # define LTWRAPPER_DEBUGPRINTF(args)
3261 #endif
3262
3263 const char *program_name = NULL;
3264
3265 void *xmalloc (size_t num);
3266 char *xstrdup (const char *string);
3267 const char *base_name (const char *name);
3268 char *find_executable (const char *wrapper);
3269 char *chase_symlinks (const char *pathspec);
3270 int make_executable (const char *path);
3271 int check_executable (const char *path);
3272 char *strendzap (char *str, const char *pat);
3273 void lt_fatal (const char *message, ...);
3274 void lt_setenv (const char *name, const char *value);
3275 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
3276 void lt_opt_process_env_set (const char *arg);
3277 void lt_opt_process_env_prepend (const char *arg);
3278 void lt_opt_process_env_append (const char *arg);
3279 int lt_split_name_value (const char *arg, char** name, char** value);
3280 void lt_update_exe_path (const char *name, const char *value);
3281 void lt_update_lib_path (const char *name, const char *value);
3282
3283 static const char *script_text_part1 =
3284 EOF
3285
3286 func_emit_wrapper_part1 yes |
3287 $SED -e 's/\([\\"]\)/\\\1/g' \
3288 -e 's/^/ "/' -e 's/$/\\n"/'
3289 echo ";"
3290 cat <<EOF
3291
3292 static const char *script_text_part2 =
3293 EOF
3294 func_emit_wrapper_part2 yes |
3295 $SED -e 's/\([\\"]\)/\\\1/g' \
3296 -e 's/^/ "/' -e 's/$/\\n"/'
3297 echo ";"
3298
3299 cat <<EOF
3300 const char * MAGIC_EXE = "$magic_exe";
3301 const char * LIB_PATH_VARNAME = "$shlibpath_var";
3302 EOF
3303
3304 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3305 func_to_host_pathlist "$temp_rpath"
3306 cat <<EOF
3307 const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
3308 EOF
3309 else
3310 cat <<"EOF"
3311 const char * LIB_PATH_VALUE = "";
3312 EOF
3313 fi
3314
3315 if test -n "$dllsearchpath"; then
3316 func_to_host_pathlist "$dllsearchpath:"
3317 cat <<EOF
3318 const char * EXE_PATH_VARNAME = "PATH";
3319 const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
3320 EOF
3321 else
3322 cat <<"EOF"
3323 const char * EXE_PATH_VARNAME = "";
3324 const char * EXE_PATH_VALUE = "";
3325 EOF
3326 fi
3327
3328 if test "$fast_install" = yes; then
3329 cat <<EOF
3330 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3331 EOF
3332 else
3333 cat <<EOF
3334 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3335 EOF
3336 fi
3337
3338
3339 cat <<"EOF"
3340
3341 #define LTWRAPPER_OPTION_PREFIX "--lt-"
3342 #define LTWRAPPER_OPTION_PREFIX_LENGTH 5
3343
3344 static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
3345 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3346
3347 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
3348
3349 static const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3350 static const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set";
3351 /* argument is putenv-style "foo=bar", value of foo is set to bar */
3352
3353 static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3354 static const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend";
3355 /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3356
3357 static const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3358 static const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append";
3359 /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3360
3361 #undef main
3362 int
3363 main (int argc, char *argv[])
3364 {
3365 char **newargz;
3366 int newargc;
3367 char *tmp_pathspec;
3368 char *actual_cwrapper_path;
3369 char *actual_cwrapper_name;
3370 char *target_name;
3371 char *lt_argv_zero;
3372 intptr_t rval = 127;
3373
3374 int i;
3375
3376 program_name = (char *) xstrdup (base_name (argv[0]));
3377 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3378 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3379
3380 /* very simple arg parsing; don't want to rely on getopt */
3381 for (i = 1; i < argc; i++)
3382 {
3383 if (strcmp (argv[i], dumpscript_opt) == 0)
3384 {
3385 EOF
3386 case "$host" in
3387 *mingw* | *cygwin* )
3388 # make stdout use "unix" line endings
3389 echo " setmode(1,_O_BINARY);"
3390 ;;
3391 esac
3392
3393 cat <<"EOF"
3394 printf ("%s", script_text_part1);
3395 printf ("%s", script_text_part2);
3396 return 0;
3397 }
3398 }
3399
3400 newargz = XMALLOC (char *, argc + 1);
3401 tmp_pathspec = find_executable (argv[0]);
3402 if (tmp_pathspec == NULL)
3403 lt_fatal ("Couldn't find %s", argv[0]);
3404 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3405 tmp_pathspec));
3406
3407 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3408 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3409 actual_cwrapper_path));
3410 XFREE (tmp_pathspec);
3411
3412 actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3413 strendzap (actual_cwrapper_path, actual_cwrapper_name);
3414
3415 /* wrapper name transforms */
3416 strendzap (actual_cwrapper_name, ".exe");
3417 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3418 XFREE (actual_cwrapper_name);
3419 actual_cwrapper_name = tmp_pathspec;
3420 tmp_pathspec = 0;
3421
3422 /* target_name transforms -- use actual target program name; might have lt- prefix */
3423 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3424 strendzap (target_name, ".exe");
3425 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3426 XFREE (target_name);
3427 target_name = tmp_pathspec;
3428 tmp_pathspec = 0;
3429
3430 LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3431 target_name));
3432 EOF
3433
3434 cat <<EOF
3435 newargz[0] =
3436 XMALLOC (char, (strlen (actual_cwrapper_path) +
3437 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3438 strcpy (newargz[0], actual_cwrapper_path);
3439 strcat (newargz[0], "$objdir");
3440 strcat (newargz[0], "/");
3441 EOF
3442
3443 cat <<"EOF"
3444 /* stop here, and copy so we don't have to do this twice */
3445 tmp_pathspec = xstrdup (newargz[0]);
3446
3447 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3448 strcat (newargz[0], actual_cwrapper_name);
3449
3450 /* DO want the lt- prefix here if it exists, so use target_name */
3451 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3452 XFREE (tmp_pathspec);
3453 tmp_pathspec = NULL;
3454 EOF
3455
3456 case $host_os in
3457 mingw*)
3458 cat <<"EOF"
3459 {
3460 char* p;
3461 while ((p = strchr (newargz[0], '\\')) != NULL)
3462 {
3463 *p = '/';
3464 }
3465 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3466 {
3467 *p = '/';
3468 }
3469 }
3470 EOF
3471 ;;
3472 esac
3473
3474 cat <<"EOF"
3475 XFREE (target_name);
3476 XFREE (actual_cwrapper_path);
3477 XFREE (actual_cwrapper_name);
3478
3479 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3480 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
3481 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3482 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3483
3484 newargc=0;
3485 for (i = 1; i < argc; i++)
3486 {
3487 if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3488 {
3489 if (argv[i][env_set_opt_len] == '=')
3490 {
3491 const char *p = argv[i] + env_set_opt_len + 1;
3492 lt_opt_process_env_set (p);
3493 }
3494 else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3495 {
3496 lt_opt_process_env_set (argv[++i]); /* don't copy */
3497 }
3498 else
3499 lt_fatal ("%s missing required argument", env_set_opt);
3500 continue;
3501 }
3502 if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3503 {
3504 if (argv[i][env_prepend_opt_len] == '=')
3505 {
3506 const char *p = argv[i] + env_prepend_opt_len + 1;
3507 lt_opt_process_env_prepend (p);
3508 }
3509 else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3510 {
3511 lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3512 }
3513 else
3514 lt_fatal ("%s missing required argument", env_prepend_opt);
3515 continue;
3516 }
3517 if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3518 {
3519 if (argv[i][env_append_opt_len] == '=')
3520 {
3521 const char *p = argv[i] + env_append_opt_len + 1;
3522 lt_opt_process_env_append (p);
3523 }
3524 else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3525 {
3526 lt_opt_process_env_append (argv[++i]); /* don't copy */
3527 }
3528 else
3529 lt_fatal ("%s missing required argument", env_append_opt);
3530 continue;
3531 }
3532 if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3533 {
3534 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3535 namespace, but it is not one of the ones we know about and
3536 have already dealt with, above (inluding dump-script), then
3537 report an error. Otherwise, targets might begin to believe
3538 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3539 namespace. The first time any user complains about this, we'll
3540 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3541 or a configure.ac-settable value.
3542 */
3543 lt_fatal ("Unrecognized option in %s namespace: '%s'",
3544 ltwrapper_option_prefix, argv[i]);
3545 }
3546 /* otherwise ... */
3547 newargz[++newargc] = xstrdup (argv[i]);
3548 }
3549 newargz[++newargc] = NULL;
3550
3551 LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3552 for (i = 0; i < newargc; i++)
3553 {
3554 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3555 }
3556
3557 EOF
3558
3559 case $host_os in
3560 mingw*)
3561 cat <<"EOF"
3562 /* execv doesn't actually work on mingw as expected on unix */
3563 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3564 if (rval == -1)
3565 {
3566 /* failed to start process */
3567 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3568 return 127;
3569 }
3570 return rval;
3571 EOF
3572 ;;
3573 *)
3574 cat <<"EOF"
3575 execv (lt_argv_zero, newargz);
3576 return rval; /* =127, but avoids unused variable warning */
3577 EOF
3578 ;;
3579 esac
3580
3581 cat <<"EOF"
3582 }
3583
3584 void *
3585 xmalloc (size_t num)
3586 {
3587 void *p = (void *) malloc (num);
3588 if (!p)
3589 lt_fatal ("Memory exhausted");
3590
3591 return p;
3592 }
3593
3594 char *
3595 xstrdup (const char *string)
3596 {
3597 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3598 string) : NULL;
3599 }
3600
3601 const char *
3602 base_name (const char *name)
3603 {
3604 const char *base;
3605
3606 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3607 /* Skip over the disk name in MSDOS pathnames. */
3608 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3609 name += 2;
3610 #endif
3611
3612 for (base = name; *name; name++)
3613 if (IS_DIR_SEPARATOR (*name))
3614 base = name + 1;
3615 return base;
3616 }
3617
3618 int
3619 check_executable (const char *path)
3620 {
3621 struct stat st;
3622
3623 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3624 path ? (*path ? path : "EMPTY!") : "NULL!"));
3625 if ((!path) || (!*path))
3626 return 0;
3627
3628 if ((stat (path, &st) >= 0)
3629 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3630 return 1;
3631 else
3632 return 0;
3633 }
3634
3635 int
3636 make_executable (const char *path)
3637 {
3638 int rval = 0;
3639 struct stat st;
3640
3641 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3642 path ? (*path ? path : "EMPTY!") : "NULL!"));
3643 if ((!path) || (!*path))
3644 return 0;
3645
3646 if (stat (path, &st) >= 0)
3647 {
3648 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3649 }
3650 return rval;
3651 }
3652
3653 /* Searches for the full path of the wrapper. Returns
3654 newly allocated full path name if found, NULL otherwise
3655 Does not chase symlinks, even on platforms that support them.
3656 */
3657 char *
3658 find_executable (const char *wrapper)
3659 {
3660 int has_slash = 0;
3661 const char *p;
3662 const char *p_next;
3663 /* static buffer for getcwd */
3664 char tmp[LT_PATHMAX + 1];
3665 int tmp_len;
3666 char *concat_name;
3667
3668 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3669 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3670
3671 if ((wrapper == NULL) || (*wrapper == '\0'))
3672 return NULL;
3673
3674 /* Absolute path? */
3675 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3676 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3677 {
3678 concat_name = xstrdup (wrapper);
3679 if (check_executable (concat_name))
3680 return concat_name;
3681 XFREE (concat_name);
3682 }
3683 else
3684 {
3685 #endif
3686 if (IS_DIR_SEPARATOR (wrapper[0]))
3687 {
3688 concat_name = xstrdup (wrapper);
3689 if (check_executable (concat_name))
3690 return concat_name;
3691 XFREE (concat_name);
3692 }
3693 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3694 }
3695 #endif
3696
3697 for (p = wrapper; *p; p++)
3698 if (*p == '/')
3699 {
3700 has_slash = 1;
3701 break;
3702 }
3703 if (!has_slash)
3704 {
3705 /* no slashes; search PATH */
3706 const char *path = getenv ("PATH");
3707 if (path != NULL)
3708 {
3709 for (p = path; *p; p = p_next)
3710 {
3711 const char *q;
3712 size_t p_len;
3713 for (q = p; *q; q++)
3714 if (IS_PATH_SEPARATOR (*q))
3715 break;
3716 p_len = q - p;
3717 p_next = (*q == '\0' ? q : q + 1);
3718 if (p_len == 0)
3719 {
3720 /* empty path: current directory */
3721 if (getcwd (tmp, LT_PATHMAX) == NULL)
3722 lt_fatal ("getcwd failed");
3723 tmp_len = strlen (tmp);
3724 concat_name =
3725 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3726 memcpy (concat_name, tmp, tmp_len);
3727 concat_name[tmp_len] = '/';
3728 strcpy (concat_name + tmp_len + 1, wrapper);
3729 }
3730 else
3731 {
3732 concat_name =
3733 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3734 memcpy (concat_name, p, p_len);
3735 concat_name[p_len] = '/';
3736 strcpy (concat_name + p_len + 1, wrapper);
3737 }
3738 if (check_executable (concat_name))
3739 return concat_name;
3740 XFREE (concat_name);
3741 }
3742 }
3743 /* not found in PATH; assume curdir */
3744 }
3745 /* Relative path | not found in path: prepend cwd */
3746 if (getcwd (tmp, LT_PATHMAX) == NULL)
3747 lt_fatal ("getcwd failed");
3748 tmp_len = strlen (tmp);
3749 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3750 memcpy (concat_name, tmp, tmp_len);
3751 concat_name[tmp_len] = '/';
3752 strcpy (concat_name + tmp_len + 1, wrapper);
3753
3754 if (check_executable (concat_name))
3755 return concat_name;
3756 XFREE (concat_name);
3757 return NULL;
3758 }
3759
3760 char *
3761 chase_symlinks (const char *pathspec)
3762 {
3763 #ifndef S_ISLNK
3764 return xstrdup (pathspec);
3765 #else
3766 char buf[LT_PATHMAX];
3767 struct stat s;
3768 char *tmp_pathspec = xstrdup (pathspec);
3769 char *p;
3770 int has_symlinks = 0;
3771 while (strlen (tmp_pathspec) && !has_symlinks)
3772 {
3773 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3774 tmp_pathspec));
3775 if (lstat (tmp_pathspec, &s) == 0)
3776 {
3777 if (S_ISLNK (s.st_mode) != 0)
3778 {
3779 has_symlinks = 1;
3780 break;
3781 }
3782
3783 /* search backwards for last DIR_SEPARATOR */
3784 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3785 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3786 p--;
3787 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3788 {
3789 /* no more DIR_SEPARATORS left */
3790 break;
3791 }
3792 *p = '\0';
3793 }
3794 else
3795 {
3796 char *errstr = strerror (errno);
3797 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3798 }
3799 }
3800 XFREE (tmp_pathspec);
3801
3802 if (!has_symlinks)
3803 {
3804 return xstrdup (pathspec);
3805 }
3806
3807 tmp_pathspec = realpath (pathspec, buf);
3808 if (tmp_pathspec == 0)
3809 {
3810 lt_fatal ("Could not follow symlinks for %s", pathspec);
3811 }
3812 return xstrdup (tmp_pathspec);
3813 #endif
3814 }
3815
3816 char *
3817 strendzap (char *str, const char *pat)
3818 {
3819 size_t len, patlen;
3820
3821 assert (str != NULL);
3822 assert (pat != NULL);
3823
3824 len = strlen (str);
3825 patlen = strlen (pat);
3826
3827 if (patlen <= len)
3828 {
3829 str += len - patlen;
3830 if (strcmp (str, pat) == 0)
3831 *str = '\0';
3832 }
3833 return str;
3834 }
3835
3836 static void
3837 lt_error_core (int exit_status, const char *mode,
3838 const char *message, va_list ap)
3839 {
3840 fprintf (stderr, "%s: %s: ", program_name, mode);
3841 vfprintf (stderr, message, ap);
3842 fprintf (stderr, ".\n");
3843
3844 if (exit_status >= 0)
3845 exit (exit_status);
3846 }
3847
3848 void
3849 lt_fatal (const char *message, ...)
3850 {
3851 va_list ap;
3852 va_start (ap, message);
3853 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3854 va_end (ap);
3855 }
3856
3857 void
3858 lt_setenv (const char *name, const char *value)
3859 {
3860 LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3861 (name ? name : "<NULL>"),
3862 (value ? value : "<NULL>")));
3863 {
3864 #ifdef HAVE_SETENV
3865 /* always make a copy, for consistency with !HAVE_SETENV */
3866 char *str = xstrdup (value);
3867 setenv (name, str, 1);
3868 #else
3869 int len = strlen (name) + 1 + strlen (value) + 1;
3870 char *str = XMALLOC (char, len);
3871 sprintf (str, "%s=%s", name, value);
3872 if (putenv (str) != EXIT_SUCCESS)
3873 {
3874 XFREE (str);
3875 }
3876 #endif
3877 }
3878 }
3879
3880 char *
3881 lt_extend_str (const char *orig_value, const char *add, int to_end)
3882 {
3883 char *new_value;
3884 if (orig_value && *orig_value)
3885 {
3886 int orig_value_len = strlen (orig_value);
3887 int add_len = strlen (add);
3888 new_value = XMALLOC (char, add_len + orig_value_len + 1);
3889 if (to_end)
3890 {
3891 strcpy (new_value, orig_value);
3892 strcpy (new_value + orig_value_len, add);
3893 }
3894 else
3895 {
3896 strcpy (new_value, add);
3897 strcpy (new_value + add_len, orig_value);
3898 }
3899 }
3900 else
3901 {
3902 new_value = xstrdup (add);
3903 }
3904 return new_value;
3905 }
3906
3907 int
3908 lt_split_name_value (const char *arg, char** name, char** value)
3909 {
3910 const char *p;
3911 int len;
3912 if (!arg || !*arg)
3913 return 1;
3914
3915 p = strchr (arg, (int)'=');
3916
3917 if (!p)
3918 return 1;
3919
3920 *value = xstrdup (++p);
3921
3922 len = strlen (arg) - strlen (*value);
3923 *name = XMALLOC (char, len);
3924 strncpy (*name, arg, len-1);
3925 (*name)[len - 1] = '\0';
3926
3927 return 0;
3928 }
3929
3930 void
3931 lt_opt_process_env_set (const char *arg)
3932 {
3933 char *name = NULL;
3934 char *value = NULL;
3935
3936 if (lt_split_name_value (arg, &name, &value) != 0)
3937 {
3938 XFREE (name);
3939 XFREE (value);
3940 lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3941 }
3942
3943 lt_setenv (name, value);
3944 XFREE (name);
3945 XFREE (value);
3946 }
3947
3948 void
3949 lt_opt_process_env_prepend (const char *arg)
3950 {
3951 char *name = NULL;
3952 char *value = NULL;
3953 char *new_value = NULL;
3954
3955 if (lt_split_name_value (arg, &name, &value) != 0)
3956 {
3957 XFREE (name);
3958 XFREE (value);
3959 lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3960 }
3961
3962 new_value = lt_extend_str (getenv (name), value, 0);
3963 lt_setenv (name, new_value);
3964 XFREE (new_value);
3965 XFREE (name);
3966 XFREE (value);
3967 }
3968
3969 void
3970 lt_opt_process_env_append (const char *arg)
3971 {
3972 char *name = NULL;
3973 char *value = NULL;
3974 char *new_value = NULL;
3975
3976 if (lt_split_name_value (arg, &name, &value) != 0)
3977 {
3978 XFREE (name);
3979 XFREE (value);
3980 lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3981 }
3982
3983 new_value = lt_extend_str (getenv (name), value, 1);
3984 lt_setenv (name, new_value);
3985 XFREE (new_value);
3986 XFREE (name);
3987 XFREE (value);
3988 }
3989
3990 void
3991 lt_update_exe_path (const char *name, const char *value)
3992 {
3993 LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3994 (name ? name : "<NULL>"),
3995 (value ? value : "<NULL>")));
3996
3997 if (name && *name && value && *value)
3998 {
3999 char *new_value = lt_extend_str (getenv (name), value, 0);
4000 /* some systems can't cope with a ':'-terminated path #' */
4001 int len = strlen (new_value);
4002 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4003 {
4004 new_value[len-1] = '\0';
4005 }
4006 lt_setenv (name, new_value);
4007 XFREE (new_value);
4008 }
4009 }
4010
4011 void
4012 lt_update_lib_path (const char *name, const char *value)
4013 {
4014 LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4015 (name ? name : "<NULL>"),
4016 (value ? value : "<NULL>")));
4017
4018 if (name && *name && value && *value)
4019 {
4020 char *new_value = lt_extend_str (getenv (name), value, 0);
4021 lt_setenv (name, new_value);
4022 XFREE (new_value);
4023 }
4024 }
4025
4026
4027 EOF
4028 }
4029 # end: func_emit_cwrapperexe_src
4030
4031 # func_mode_link arg...
4032 func_mode_link ()
4033 {
4034 $opt_debug
4035 case $host in
4036 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4037 # It is impossible to link a dll without this setting, and
4038 # we shouldn't force the makefile maintainer to figure out
4039 # which system we are compiling for in order to pass an extra
4040 # flag for every libtool invocation.
4041 # allow_undefined=no
4042
4043 # FIXME: Unfortunately, there are problems with the above when trying
4044 # to make a dll which has undefined symbols, in which case not
4045 # even a static library is built. For now, we need to specify
4046 # -no-undefined on the libtool link line when we can be certain
4047 # that all symbols are satisfied, otherwise we get a static library.
4048 allow_undefined=yes
4049 ;;
4050 *)
4051 allow_undefined=yes
4052 ;;
4053 esac
4054 libtool_args=$nonopt
4055 base_compile="$nonopt $@"
4056 compile_command=$nonopt
4057 finalize_command=$nonopt
4058
4059 compile_rpath=
4060 finalize_rpath=
4061 compile_shlibpath=
4062 finalize_shlibpath=
4063 convenience=
4064 old_convenience=
4065 deplibs=
4066 old_deplibs=
4067 compiler_flags=
4068 linker_flags=
4069 dllsearchpath=
4070 lib_search_path=`pwd`
4071 inst_prefix_dir=
4072 new_inherited_linker_flags=
4073
4074 avoid_version=no
4075 dlfiles=
4076 dlprefiles=
4077 dlself=no
4078 export_dynamic=no
4079 export_symbols=
4080 export_symbols_regex=
4081 generated=
4082 libobjs=
4083 ltlibs=
4084 module=no
4085 no_install=no
4086 objs=
4087 non_pic_objects=
4088 precious_files_regex=
4089 prefer_static_libs=no
4090 preload=no
4091 prev=
4092 prevarg=
4093 release=
4094 rpath=
4095 xrpath=
4096 perm_rpath=
4097 temp_rpath=
4098 thread_safe=no
4099 vinfo=
4100 vinfo_number=no
4101 weak_libs=
4102 single_module="${wl}-single_module"
4103 func_infer_tag $base_compile
4104
4105 # We need to know -static, to get the right output filenames.
4106 for arg
4107 do
4108 case $arg in
4109 -shared)
4110 test "$build_libtool_libs" != yes && \
4111 func_fatal_configuration "can not build a shared library"
4112 build_old_libs=no
4113 break
4114 ;;
4115 -all-static | -static | -static-libtool-libs)
4116 case $arg in
4117 -all-static)
4118 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4119 func_warning "complete static linking is impossible in this configuration"
4120 fi
4121 if test -n "$link_static_flag"; then
4122 dlopen_self=$dlopen_self_static
4123 fi
4124 prefer_static_libs=yes
4125 ;;
4126 -static)
4127 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4128 dlopen_self=$dlopen_self_static
4129 fi
4130 prefer_static_libs=built
4131 ;;
4132 -static-libtool-libs)
4133 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4134 dlopen_self=$dlopen_self_static
4135 fi
4136 prefer_static_libs=yes
4137 ;;
4138 esac
4139 build_libtool_libs=no
4140 build_old_libs=yes
4141 break
4142 ;;
4143 esac
4144 done
4145
4146 # See if our shared archives depend on static archives.
4147 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4148
4149 # Go through the arguments, transforming them on the way.
4150 while test "$#" -gt 0; do
4151 arg="$1"
4152 shift
4153 func_quote_for_eval "$arg"
4154 qarg=$func_quote_for_eval_unquoted_result
4155 func_append libtool_args " $func_quote_for_eval_result"
4156
4157 # If the previous option needs an argument, assign it.
4158 if test -n "$prev"; then
4159 case $prev in
4160 output)
4161 func_append compile_command " @OUTPUT@"
4162 func_append finalize_command " @OUTPUT@"
4163 ;;
4164 esac
4165
4166 case $prev in
4167 dlfiles|dlprefiles)
4168 if test "$preload" = no; then
4169 # Add the symbol object into the linking commands.
4170 func_append compile_command " @SYMFILE@"
4171 func_append finalize_command " @SYMFILE@"
4172 preload=yes
4173 fi
4174 case $arg in
4175 *.la | *.lo) ;; # We handle these cases below.
4176 force)
4177 if test "$dlself" = no; then
4178 dlself=needless
4179 export_dynamic=yes
4180 fi
4181 prev=
4182 continue
4183 ;;
4184 self)
4185 if test "$prev" = dlprefiles; then
4186 dlself=yes
4187 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4188 dlself=yes
4189 else
4190 dlself=needless
4191 export_dynamic=yes
4192 fi
4193 prev=
4194 continue
4195 ;;
4196 *)
4197 if test "$prev" = dlfiles; then
4198 dlfiles="$dlfiles $arg"
4199 else
4200 dlprefiles="$dlprefiles $arg"
4201 fi
4202 prev=
4203 continue
4204 ;;
4205 esac
4206 ;;
4207 expsyms)
4208 export_symbols="$arg"
4209 test -f "$arg" \
4210 || func_fatal_error "symbol file \`$arg' does not exist"
4211 prev=
4212 continue
4213 ;;
4214 expsyms_regex)
4215 export_symbols_regex="$arg"
4216 prev=
4217 continue
4218 ;;
4219 framework)
4220 case $host in
4221 *-*-darwin*)
4222 case "$deplibs " in
4223 *" $qarg.ltframework "*) ;;
4224 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4225 ;;
4226 esac
4227 ;;
4228 esac
4229 prev=
4230 continue
4231 ;;
4232 inst_prefix)
4233 inst_prefix_dir="$arg"
4234 prev=
4235 continue
4236 ;;
4237 objectlist)
4238 if test -f "$arg"; then
4239 save_arg=$arg
4240 moreargs=
4241 for fil in `cat "$save_arg"`
4242 do
4243 # moreargs="$moreargs $fil"
4244 arg=$fil
4245 # A libtool-controlled object.
4246
4247 # Check to see that this really is a libtool object.
4248 if func_lalib_unsafe_p "$arg"; then
4249 pic_object=
4250 non_pic_object=
4251
4252 # Read the .lo file
4253 func_source "$arg"
4254
4255 if test -z "$pic_object" ||
4256 test -z "$non_pic_object" ||
4257 test "$pic_object" = none &&
4258 test "$non_pic_object" = none; then
4259 func_fatal_error "cannot find name of object for \`$arg'"
4260 fi
4261
4262 # Extract subdirectory from the argument.
4263 func_dirname "$arg" "/" ""
4264 xdir="$func_dirname_result"
4265
4266 if test "$pic_object" != none; then
4267 # Prepend the subdirectory the object is found in.
4268 pic_object="$xdir$pic_object"
4269
4270 if test "$prev" = dlfiles; then
4271 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4272 dlfiles="$dlfiles $pic_object"
4273 prev=
4274 continue
4275 else
4276 # If libtool objects are unsupported, then we need to preload.
4277 prev=dlprefiles
4278 fi
4279 fi
4280
4281 # CHECK ME: I think I busted this. -Ossama
4282 if test "$prev" = dlprefiles; then
4283 # Preload the old-style object.
4284 dlprefiles="$dlprefiles $pic_object"
4285 prev=
4286 fi
4287
4288 # A PIC object.
4289 func_append libobjs " $pic_object"
4290 arg="$pic_object"
4291 fi
4292
4293 # Non-PIC object.
4294 if test "$non_pic_object" != none; then
4295 # Prepend the subdirectory the object is found in.
4296 non_pic_object="$xdir$non_pic_object"
4297
4298 # A standard non-PIC object
4299 func_append non_pic_objects " $non_pic_object"
4300 if test -z "$pic_object" || test "$pic_object" = none ; then
4301 arg="$non_pic_object"
4302 fi
4303 else
4304 # If the PIC object exists, use it instead.
4305 # $xdir was prepended to $pic_object above.
4306 non_pic_object="$pic_object"
4307 func_append non_pic_objects " $non_pic_object"
4308 fi
4309 else
4310 # Only an error if not doing a dry-run.
4311 if $opt_dry_run; then
4312 # Extract subdirectory from the argument.
4313 func_dirname "$arg" "/" ""
4314 xdir="$func_dirname_result"
4315
4316 func_lo2o "$arg"
4317 pic_object=$xdir$objdir/$func_lo2o_result
4318 non_pic_object=$xdir$func_lo2o_result
4319 func_append libobjs " $pic_object"
4320 func_append non_pic_objects " $non_pic_object"
4321 else
4322 func_fatal_error "\`$arg' is not a valid libtool object"
4323 fi
4324 fi
4325 done
4326 else
4327 func_fatal_error "link input file \`$arg' does not exist"
4328 fi
4329 arg=$save_arg
4330 prev=
4331 continue
4332 ;;
4333 precious_regex)
4334 precious_files_regex="$arg"
4335 prev=
4336 continue
4337 ;;
4338 release)
4339 release="-$arg"
4340 prev=
4341 continue
4342 ;;
4343 rpath | xrpath)
4344 # We need an absolute path.
4345 case $arg in
4346 [\\/]* | [A-Za-z]:[\\/]*) ;;
4347 *)
4348 func_fatal_error "only absolute run-paths are allowed"
4349 ;;
4350 esac
4351 if test "$prev" = rpath; then
4352 case "$rpath " in
4353 *" $arg "*) ;;
4354 *) rpath="$rpath $arg" ;;
4355 esac
4356 else
4357 case "$xrpath " in
4358 *" $arg "*) ;;
4359 *) xrpath="$xrpath $arg" ;;
4360 esac
4361 fi
4362 prev=
4363 continue
4364 ;;
4365 shrext)
4366 shrext_cmds="$arg"
4367 prev=
4368 continue
4369 ;;
4370 weak)
4371 weak_libs="$weak_libs $arg"
4372 prev=
4373 continue
4374 ;;
4375 xcclinker)
4376 linker_flags="$linker_flags $qarg"
4377 compiler_flags="$compiler_flags $qarg"
4378 prev=
4379 func_append compile_command " $qarg"
4380 func_append finalize_command " $qarg"
4381 continue
4382 ;;
4383 xcompiler)
4384 compiler_flags="$compiler_flags $qarg"
4385 prev=
4386 func_append compile_command " $qarg"
4387 func_append finalize_command " $qarg"
4388 continue
4389 ;;
4390 xlinker)
4391 linker_flags="$linker_flags $qarg"
4392 compiler_flags="$compiler_flags $wl$qarg"
4393 prev=
4394 func_append compile_command " $wl$qarg"
4395 func_append finalize_command " $wl$qarg"
4396 continue
4397 ;;
4398 *)
4399 eval "$prev=\"\$arg\""
4400 prev=
4401 continue
4402 ;;
4403 esac
4404 fi # test -n "$prev"
4405
4406 prevarg="$arg"
4407
4408 case $arg in
4409 -all-static)
4410 if test -n "$link_static_flag"; then
4411 # See comment for -static flag below, for more details.
4412 func_append compile_command " $link_static_flag"
4413 func_append finalize_command " $link_static_flag"
4414 fi
4415 continue
4416 ;;
4417
4418 -allow-undefined)
4419 # FIXME: remove this flag sometime in the future.
4420 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4421 ;;
4422
4423 -avoid-version)
4424 avoid_version=yes
4425 continue
4426 ;;
4427
4428 -dlopen)
4429 prev=dlfiles
4430 continue
4431 ;;
4432
4433 -dlpreopen)
4434 prev=dlprefiles
4435 continue
4436 ;;
4437
4438 -export-dynamic)
4439 export_dynamic=yes
4440 continue
4441 ;;
4442
4443 -export-symbols | -export-symbols-regex)
4444 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4445 func_fatal_error "more than one -exported-symbols argument is not allowed"
4446 fi
4447 if test "X$arg" = "X-export-symbols"; then
4448 prev=expsyms
4449 else
4450 prev=expsyms_regex
4451 fi
4452 continue
4453 ;;
4454
4455 -framework)
4456 prev=framework
4457 continue
4458 ;;
4459
4460 -inst-prefix-dir)
4461 prev=inst_prefix
4462 continue
4463 ;;
4464
4465 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4466 # so, if we see these flags be careful not to treat them like -L
4467 -L[A-Z][A-Z]*:*)
4468 case $with_gcc/$host in
4469 no/*-*-irix* | /*-*-irix*)
4470 func_append compile_command " $arg"
4471 func_append finalize_command " $arg"
4472 ;;
4473 esac
4474 continue
4475 ;;
4476
4477 -L*)
4478 func_stripname '-L' '' "$arg"
4479 dir=$func_stripname_result
4480 if test -z "$dir"; then
4481 if test "$#" -gt 0; then
4482 func_fatal_error "require no space between \`-L' and \`$1'"
4483 else
4484 func_fatal_error "need path for \`-L' option"
4485 fi
4486 fi
4487 # We need an absolute path.
4488 case $dir in
4489 [\\/]* | [A-Za-z]:[\\/]*) ;;
4490 *)
4491 absdir=`cd "$dir" && pwd`
4492 test -z "$absdir" && \
4493 func_fatal_error "cannot determine absolute directory name of \`$dir'"
4494 dir="$absdir"
4495 ;;
4496 esac
4497 case "$deplibs " in
4498 *" -L$dir "*) ;;
4499 *)
4500 deplibs="$deplibs -L$dir"
4501 lib_search_path="$lib_search_path $dir"
4502 ;;
4503 esac
4504 case $host in
4505 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4506 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4507 case :$dllsearchpath: in
4508 *":$dir:"*) ;;
4509 ::) dllsearchpath=$dir;;
4510 *) dllsearchpath="$dllsearchpath:$dir";;
4511 esac
4512 case :$dllsearchpath: in
4513 *":$testbindir:"*) ;;
4514 ::) dllsearchpath=$testbindir;;
4515 *) dllsearchpath="$dllsearchpath:$testbindir";;
4516 esac
4517 ;;
4518 esac
4519 continue
4520 ;;
4521
4522 -l*)
4523 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4524 case $host in
4525 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4526 # These systems don't actually have a C or math library (as such)
4527 continue
4528 ;;
4529 *-*-os2*)
4530 # These systems don't actually have a C library (as such)
4531 test "X$arg" = "X-lc" && continue
4532 ;;
4533 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4534 # Do not include libc due to us having libc/libc_r.
4535 test "X$arg" = "X-lc" && continue
4536 ;;
4537 *-*-rhapsody* | *-*-darwin1.[012])
4538 # Rhapsody C and math libraries are in the System framework
4539 deplibs="$deplibs System.ltframework"
4540 continue
4541 ;;
4542 *-*-sco3.2v5* | *-*-sco5v6*)
4543 # Causes problems with __ctype
4544 test "X$arg" = "X-lc" && continue
4545 ;;
4546 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4547 # Compiler inserts libc in the correct place for threads to work
4548 test "X$arg" = "X-lc" && continue
4549 ;;
4550 esac
4551 elif test "X$arg" = "X-lc_r"; then
4552 case $host in
4553 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4554 # Do not include libc_r directly, use -pthread flag.
4555 continue
4556 ;;
4557 esac
4558 fi
4559 deplibs="$deplibs $arg"
4560 continue
4561 ;;
4562
4563 -module)
4564 module=yes
4565 continue
4566 ;;
4567
4568 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4569 # classes, name mangling, and exception handling.
4570 # Darwin uses the -arch flag to determine output architecture.
4571 -model|-arch|-isysroot)
4572 compiler_flags="$compiler_flags $arg"
4573 func_append compile_command " $arg"
4574 func_append finalize_command " $arg"
4575 prev=xcompiler
4576 continue
4577 ;;
4578
4579 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4580 compiler_flags="$compiler_flags $arg"
4581 func_append compile_command " $arg"
4582 func_append finalize_command " $arg"
4583 case "$new_inherited_linker_flags " in
4584 *" $arg "*) ;;
4585 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4586 esac
4587 continue
4588 ;;
4589
4590 -multi_module)
4591 single_module="${wl}-multi_module"
4592 continue
4593 ;;
4594
4595 -no-fast-install)
4596 fast_install=no
4597 continue
4598 ;;
4599
4600 -no-install)
4601 case $host in
4602 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4603 # The PATH hackery in wrapper scripts is required on Windows
4604 # and Darwin in order for the loader to find any dlls it needs.
4605 func_warning "\`-no-install' is ignored for $host"
4606 func_warning "assuming \`-no-fast-install' instead"
4607 fast_install=no
4608 ;;
4609 *) no_install=yes ;;
4610 esac
4611 continue
4612 ;;
4613
4614 -no-undefined)
4615 allow_undefined=no
4616 continue
4617 ;;
4618
4619 -objectlist)
4620 prev=objectlist
4621 continue
4622 ;;
4623
4624 -o) prev=output ;;
4625
4626 -precious-files-regex)
4627 prev=precious_regex
4628 continue
4629 ;;
4630
4631 -release)
4632 prev=release
4633 continue
4634 ;;
4635
4636 -rpath)
4637 prev=rpath
4638 continue
4639 ;;
4640
4641 -R)
4642 prev=xrpath
4643 continue
4644 ;;
4645
4646 -R*)
4647 func_stripname '-R' '' "$arg"
4648 dir=$func_stripname_result
4649 # We need an absolute path.
4650 case $dir in
4651 [\\/]* | [A-Za-z]:[\\/]*) ;;
4652 *)
4653 func_fatal_error "only absolute run-paths are allowed"
4654 ;;
4655 esac
4656 case "$xrpath " in
4657 *" $dir "*) ;;
4658 *) xrpath="$xrpath $dir" ;;
4659 esac
4660 continue
4661 ;;
4662
4663 -shared)
4664 # The effects of -shared are defined in a previous loop.
4665 continue
4666 ;;
4667
4668 -shrext)
4669 prev=shrext
4670 continue
4671 ;;
4672
4673 -static | -static-libtool-libs)
4674 # The effects of -static are defined in a previous loop.
4675 # We used to do the same as -all-static on platforms that
4676 # didn't have a PIC flag, but the assumption that the effects
4677 # would be equivalent was wrong. It would break on at least
4678 # Digital Unix and AIX.
4679 continue
4680 ;;
4681
4682 -thread-safe)
4683 thread_safe=yes
4684 continue
4685 ;;
4686
4687 -version-info)
4688 prev=vinfo
4689 continue
4690 ;;
4691
4692 -version-number)
4693 prev=vinfo
4694 vinfo_number=yes
4695 continue
4696 ;;
4697
4698 -weak)
4699 prev=weak
4700 continue
4701 ;;
4702
4703 -Wc,*)
4704 func_stripname '-Wc,' '' "$arg"
4705 args=$func_stripname_result
4706 arg=
4707 save_ifs="$IFS"; IFS=','
4708 for flag in $args; do
4709 IFS="$save_ifs"
4710 func_quote_for_eval "$flag"
4711 arg="$arg $wl$func_quote_for_eval_result"
4712 compiler_flags="$compiler_flags $func_quote_for_eval_result"
4713 done
4714 IFS="$save_ifs"
4715 func_stripname ' ' '' "$arg"
4716 arg=$func_stripname_result
4717 ;;
4718
4719 -Wl,*)
4720 func_stripname '-Wl,' '' "$arg"
4721 args=$func_stripname_result
4722 arg=
4723 save_ifs="$IFS"; IFS=','
4724 for flag in $args; do
4725 IFS="$save_ifs"
4726 func_quote_for_eval "$flag"
4727 arg="$arg $wl$func_quote_for_eval_result"
4728 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4729 linker_flags="$linker_flags $func_quote_for_eval_result"
4730 done
4731 IFS="$save_ifs"
4732 func_stripname ' ' '' "$arg"
4733 arg=$func_stripname_result
4734 ;;
4735
4736 -Xcompiler)
4737 prev=xcompiler
4738 continue
4739 ;;
4740
4741 -Xlinker)
4742 prev=xlinker
4743 continue
4744 ;;
4745
4746 -XCClinker)
4747 prev=xcclinker
4748 continue
4749 ;;
4750
4751 # -msg_* for osf cc
4752 -msg_*)
4753 func_quote_for_eval "$arg"
4754 arg="$func_quote_for_eval_result"
4755 ;;
4756
4757 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4758 # -r[0-9][0-9]* specifies the processor on the SGI compiler
4759 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4760 # +DA*, +DD* enable 64-bit mode on the HP compiler
4761 # -q* pass through compiler args for the IBM compiler
4762 # -m*, -t[45]*, -txscale* pass through architecture-specific
4763 # compiler args for GCC
4764 # -F/path gives path to uninstalled frameworks, gcc on darwin
4765 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4766 # @file GCC response files
4767 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4768 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4769 func_quote_for_eval "$arg"
4770 arg="$func_quote_for_eval_result"
4771 func_append compile_command " $arg"
4772 func_append finalize_command " $arg"
4773 compiler_flags="$compiler_flags $arg"
4774 continue
4775 ;;
4776
4777 # Some other compiler flag.
4778 -* | +*)
4779 func_quote_for_eval "$arg"
4780 arg="$func_quote_for_eval_result"
4781 ;;
4782
4783 *.$objext)
4784 # A standard object.
4785 objs="$objs $arg"
4786 ;;
4787
4788 *.lo)
4789 # A libtool-controlled object.
4790
4791 # Check to see that this really is a libtool object.
4792 if func_lalib_unsafe_p "$arg"; then
4793 pic_object=
4794 non_pic_object=
4795
4796 # Read the .lo file
4797 func_source "$arg"
4798
4799 if test -z "$pic_object" ||
4800 test -z "$non_pic_object" ||
4801 test "$pic_object" = none &&
4802 test "$non_pic_object" = none; then
4803 func_fatal_error "cannot find name of object for \`$arg'"
4804 fi
4805
4806 # Extract subdirectory from the argument.
4807 func_dirname "$arg" "/" ""
4808 xdir="$func_dirname_result"
4809
4810 if test "$pic_object" != none; then
4811 # Prepend the subdirectory the object is found in.
4812 pic_object="$xdir$pic_object"
4813
4814 if test "$prev" = dlfiles; then
4815 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4816 dlfiles="$dlfiles $pic_object"
4817 prev=
4818 continue
4819 else
4820 # If libtool objects are unsupported, then we need to preload.
4821 prev=dlprefiles
4822 fi
4823 fi
4824
4825 # CHECK ME: I think I busted this. -Ossama
4826 if test "$prev" = dlprefiles; then
4827 # Preload the old-style object.
4828 dlprefiles="$dlprefiles $pic_object"
4829 prev=
4830 fi
4831
4832 # A PIC object.
4833 func_append libobjs " $pic_object"
4834 arg="$pic_object"
4835 fi
4836
4837 # Non-PIC object.
4838 if test "$non_pic_object" != none; then
4839 # Prepend the subdirectory the object is found in.
4840 non_pic_object="$xdir$non_pic_object"
4841
4842 # A standard non-PIC object
4843 func_append non_pic_objects " $non_pic_object"
4844 if test -z "$pic_object" || test "$pic_object" = none ; then
4845 arg="$non_pic_object"
4846 fi
4847 else
4848 # If the PIC object exists, use it instead.
4849 # $xdir was prepended to $pic_object above.
4850 non_pic_object="$pic_object"
4851 func_append non_pic_objects " $non_pic_object"
4852 fi
4853 else
4854 # Only an error if not doing a dry-run.
4855 if $opt_dry_run; then
4856 # Extract subdirectory from the argument.
4857 func_dirname "$arg" "/" ""
4858 xdir="$func_dirname_result"
4859
4860 func_lo2o "$arg"
4861 pic_object=$xdir$objdir/$func_lo2o_result
4862 non_pic_object=$xdir$func_lo2o_result
4863 func_append libobjs " $pic_object"
4864 func_append non_pic_objects " $non_pic_object"
4865 else
4866 func_fatal_error "\`$arg' is not a valid libtool object"
4867 fi
4868 fi
4869 ;;
4870
4871 *.$libext)
4872 # An archive.
4873 deplibs="$deplibs $arg"
4874 old_deplibs="$old_deplibs $arg"
4875 continue
4876 ;;
4877
4878 *.la)
4879 # A libtool-controlled library.
4880
4881 if test "$prev" = dlfiles; then
4882 # This library was specified with -dlopen.
4883 dlfiles="$dlfiles $arg"
4884 prev=
4885 elif test "$prev" = dlprefiles; then
4886 # The library was specified with -dlpreopen.
4887 dlprefiles="$dlprefiles $arg"
4888 prev=
4889 else
4890 deplibs="$deplibs $arg"
4891 fi
4892 continue
4893 ;;
4894
4895 # Some other compiler argument.
4896 *)
4897 # Unknown arguments in both finalize_command and compile_command need
4898 # to be aesthetically quoted because they are evaled later.
4899 func_quote_for_eval "$arg"
4900 arg="$func_quote_for_eval_result"
4901 ;;
4902 esac # arg
4903
4904 # Now actually substitute the argument into the commands.
4905 if test -n "$arg"; then
4906 func_append compile_command " $arg"
4907 func_append finalize_command " $arg"
4908 fi
4909 done # argument parsing loop
4910
4911 test -n "$prev" && \
4912 func_fatal_help "the \`$prevarg' option requires an argument"
4913
4914 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4915 eval arg=\"$export_dynamic_flag_spec\"
4916 func_append compile_command " $arg"
4917 func_append finalize_command " $arg"
4918 fi
4919
4920 oldlibs=
4921 # calculate the name of the file, without its directory
4922 func_basename "$output"
4923 outputname="$func_basename_result"
4924 libobjs_save="$libobjs"
4925
4926 if test -n "$shlibpath_var"; then
4927 # get the directories listed in $shlibpath_var
4928 eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4929 else
4930 shlib_search_path=
4931 fi
4932 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4933 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4934
4935 func_dirname "$output" "/" ""
4936 output_objdir="$func_dirname_result$objdir"
4937 # Create the object directory.
4938 func_mkdir_p "$output_objdir"
4939
4940 # Determine the type of output
4941 case $output in
4942 "")
4943 func_fatal_help "you must specify an output file"
4944 ;;
4945 *.$libext) linkmode=oldlib ;;
4946 *.lo | *.$objext) linkmode=obj ;;
4947 *.la) linkmode=lib ;;
4948 *) linkmode=prog ;; # Anything else should be a program.
4949 esac
4950
4951 specialdeplibs=
4952
4953 libs=
4954 # Find all interdependent deplibs by searching for libraries
4955 # that are linked more than once (e.g. -la -lb -la)
4956 for deplib in $deplibs; do
4957 if $opt_duplicate_deps ; then
4958 case "$libs " in
4959 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4960 esac
4961 fi
4962 libs="$libs $deplib"
4963 done
4964
4965 if test "$linkmode" = lib; then
4966 libs="$predeps $libs $compiler_lib_search_path $postdeps"
4967
4968 # Compute libraries that are listed more than once in $predeps
4969 # $postdeps and mark them as special (i.e., whose duplicates are
4970 # not to be eliminated).
4971 pre_post_deps=
4972 if $opt_duplicate_compiler_generated_deps; then
4973 for pre_post_dep in $predeps $postdeps; do
4974 case "$pre_post_deps " in
4975 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4976 esac
4977 pre_post_deps="$pre_post_deps $pre_post_dep"
4978 done
4979 fi
4980 pre_post_deps=
4981 fi
4982
4983 deplibs=
4984 newdependency_libs=
4985 newlib_search_path=
4986 need_relink=no # whether we're linking any uninstalled libtool libraries
4987 notinst_deplibs= # not-installed libtool libraries
4988 notinst_path= # paths that contain not-installed libtool libraries
4989
4990 case $linkmode in
4991 lib)
4992 passes="conv dlpreopen link"
4993 for file in $dlfiles $dlprefiles; do
4994 case $file in
4995 *.la) ;;
4996 *)
4997 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
4998 ;;
4999 esac
5000 done
5001 ;;
5002 prog)
5003 compile_deplibs=
5004 finalize_deplibs=
5005 alldeplibs=no
5006 newdlfiles=
5007 newdlprefiles=
5008 passes="conv scan dlopen dlpreopen link"
5009 ;;
5010 *) passes="conv"
5011 ;;
5012 esac
5013
5014 for pass in $passes; do
5015 # The preopen pass in lib mode reverses $deplibs; put it back here
5016 # so that -L comes before libs that need it for instance...
5017 if test "$linkmode,$pass" = "lib,link"; then
5018 ## FIXME: Find the place where the list is rebuilt in the wrong
5019 ## order, and fix it there properly
5020 tmp_deplibs=
5021 for deplib in $deplibs; do
5022 tmp_deplibs="$deplib $tmp_deplibs"
5023 done
5024 deplibs="$tmp_deplibs"
5025 fi
5026
5027 if test "$linkmode,$pass" = "lib,link" ||
5028 test "$linkmode,$pass" = "prog,scan"; then
5029 libs="$deplibs"
5030 deplibs=
5031 fi
5032 if test "$linkmode" = prog; then
5033 case $pass in
5034 dlopen) libs="$dlfiles" ;;
5035 dlpreopen) libs="$dlprefiles" ;;
5036 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5037 esac
5038 fi
5039 if test "$linkmode,$pass" = "lib,dlpreopen"; then
5040 # Collect and forward deplibs of preopened libtool libs
5041 for lib in $dlprefiles; do
5042 # Ignore non-libtool-libs
5043 dependency_libs=
5044 case $lib in
5045 *.la) func_source "$lib" ;;
5046 esac
5047
5048 # Collect preopened libtool deplibs, except any this library
5049 # has declared as weak libs
5050 for deplib in $dependency_libs; do
5051 deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5052 case " $weak_libs " in
5053 *" $deplib_base "*) ;;
5054 *) deplibs="$deplibs $deplib" ;;
5055 esac
5056 done
5057 done
5058 libs="$dlprefiles"
5059 fi
5060 if test "$pass" = dlopen; then
5061 # Collect dlpreopened libraries
5062 save_deplibs="$deplibs"
5063 deplibs=
5064 fi
5065
5066 for deplib in $libs; do
5067 lib=
5068 found=no
5069 case $deplib in
5070 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5071 if test "$linkmode,$pass" = "prog,link"; then
5072 compile_deplibs="$deplib $compile_deplibs"
5073 finalize_deplibs="$deplib $finalize_deplibs"
5074 else
5075 compiler_flags="$compiler_flags $deplib"
5076 if test "$linkmode" = lib ; then
5077 case "$new_inherited_linker_flags " in
5078 *" $deplib "*) ;;
5079 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5080 esac
5081 fi
5082 fi
5083 continue
5084 ;;
5085 -l*)
5086 if test "$linkmode" != lib && test "$linkmode" != prog; then
5087 func_warning "\`-l' is ignored for archives/objects"
5088 continue
5089 fi
5090 func_stripname '-l' '' "$deplib"
5091 name=$func_stripname_result
5092 if test "$linkmode" = lib; then
5093 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5094 else
5095 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5096 fi
5097 for searchdir in $searchdirs; do
5098 for search_ext in .la $std_shrext .so .a; do
5099 # Search the libtool library
5100 lib="$searchdir/lib${name}${search_ext}"
5101 if test -f "$lib"; then
5102 if test "$search_ext" = ".la"; then
5103 found=yes
5104 else
5105 found=no
5106 fi
5107 break 2
5108 fi
5109 done
5110 done
5111 if test "$found" != yes; then
5112 # deplib doesn't seem to be a libtool library
5113 if test "$linkmode,$pass" = "prog,link"; then
5114 compile_deplibs="$deplib $compile_deplibs"
5115 finalize_deplibs="$deplib $finalize_deplibs"
5116 else
5117 deplibs="$deplib $deplibs"
5118 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5119 fi
5120 continue
5121 else # deplib is a libtool library
5122 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5123 # We need to do some special things here, and not later.
5124 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5125 case " $predeps $postdeps " in
5126 *" $deplib "*)
5127 if func_lalib_p "$lib"; then
5128 library_names=
5129 old_library=
5130 func_source "$lib"
5131 for l in $old_library $library_names; do
5132 ll="$l"
5133 done
5134 if test "X$ll" = "X$old_library" ; then # only static version available
5135 found=no
5136 func_dirname "$lib" "" "."
5137 ladir="$func_dirname_result"
5138 lib=$ladir/$old_library
5139 if test "$linkmode,$pass" = "prog,link"; then
5140 compile_deplibs="$deplib $compile_deplibs"
5141 finalize_deplibs="$deplib $finalize_deplibs"
5142 else
5143 deplibs="$deplib $deplibs"
5144 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5145 fi
5146 continue
5147 fi
5148 fi
5149 ;;
5150 *) ;;
5151 esac
5152 fi
5153 fi
5154 ;; # -l
5155 *.ltframework)
5156 if test "$linkmode,$pass" = "prog,link"; then
5157 compile_deplibs="$deplib $compile_deplibs"
5158 finalize_deplibs="$deplib $finalize_deplibs"
5159 else
5160 deplibs="$deplib $deplibs"
5161 if test "$linkmode" = lib ; then
5162 case "$new_inherited_linker_flags " in
5163 *" $deplib "*) ;;
5164 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5165 esac
5166 fi
5167 fi
5168 continue
5169 ;;
5170 -L*)
5171 case $linkmode in
5172 lib)
5173 deplibs="$deplib $deplibs"
5174 test "$pass" = conv && continue
5175 newdependency_libs="$deplib $newdependency_libs"
5176 func_stripname '-L' '' "$deplib"
5177 newlib_search_path="$newlib_search_path $func_stripname_result"
5178 ;;
5179 prog)
5180 if test "$pass" = conv; then
5181 deplibs="$deplib $deplibs"
5182 continue
5183 fi
5184 if test "$pass" = scan; then
5185 deplibs="$deplib $deplibs"
5186 else
5187 compile_deplibs="$deplib $compile_deplibs"
5188 finalize_deplibs="$deplib $finalize_deplibs"
5189 fi
5190 func_stripname '-L' '' "$deplib"
5191 newlib_search_path="$newlib_search_path $func_stripname_result"
5192 ;;
5193 *)
5194 func_warning "\`-L' is ignored for archives/objects"
5195 ;;
5196 esac # linkmode
5197 continue
5198 ;; # -L
5199 -R*)
5200 if test "$pass" = link; then
5201 func_stripname '-R' '' "$deplib"
5202 dir=$func_stripname_result
5203 # Make sure the xrpath contains only unique directories.
5204 case "$xrpath " in
5205 *" $dir "*) ;;
5206 *) xrpath="$xrpath $dir" ;;
5207 esac
5208 fi
5209 deplibs="$deplib $deplibs"
5210 continue
5211 ;;
5212 *.la) lib="$deplib" ;;
5213 *.$libext)
5214 if test "$pass" = conv; then
5215 deplibs="$deplib $deplibs"
5216 continue
5217 fi
5218 case $linkmode in
5219 lib)
5220 # Linking convenience modules into shared libraries is allowed,
5221 # but linking other static libraries is non-portable.
5222 case " $dlpreconveniencelibs " in
5223 *" $deplib "*) ;;
5224 *)
5225 valid_a_lib=no
5226 case $deplibs_check_method in
5227 match_pattern*)
5228 set dummy $deplibs_check_method; shift
5229 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5230 if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5231 | $EGREP "$match_pattern_regex" > /dev/null; then
5232 valid_a_lib=yes
5233 fi
5234 ;;
5235 pass_all)
5236 valid_a_lib=yes
5237 ;;
5238 esac
5239 if test "$valid_a_lib" != yes; then
5240 $ECHO
5241 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
5242 $ECHO "*** I have the capability to make that library automatically link in when"
5243 $ECHO "*** you link to this library. But I can only do this if you have a"
5244 $ECHO "*** shared version of the library, which you do not appear to have"
5245 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
5246 $ECHO "*** that it is just a static archive that I should not use here."
5247 else
5248 $ECHO
5249 $ECHO "*** Warning: Linking the shared library $output against the"
5250 $ECHO "*** static library $deplib is not portable!"
5251 deplibs="$deplib $deplibs"
5252 fi
5253 ;;
5254 esac
5255 continue
5256 ;;
5257 prog)
5258 if test "$pass" != link; then
5259 deplibs="$deplib $deplibs"
5260 else
5261 compile_deplibs="$deplib $compile_deplibs"
5262 finalize_deplibs="$deplib $finalize_deplibs"
5263 fi
5264 continue
5265 ;;
5266 esac # linkmode
5267 ;; # *.$libext
5268 *.lo | *.$objext)
5269 if test "$pass" = conv; then
5270 deplibs="$deplib $deplibs"
5271 elif test "$linkmode" = prog; then
5272 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5273 # If there is no dlopen support or we're linking statically,
5274 # we need to preload.
5275 newdlprefiles="$newdlprefiles $deplib"
5276 compile_deplibs="$deplib $compile_deplibs"
5277 finalize_deplibs="$deplib $finalize_deplibs"
5278 else
5279 newdlfiles="$newdlfiles $deplib"
5280 fi
5281 fi
5282 continue
5283 ;;
5284 %DEPLIBS%)
5285 alldeplibs=yes
5286 continue
5287 ;;
5288 esac # case $deplib
5289
5290 if test "$found" = yes || test -f "$lib"; then :
5291 else
5292 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5293 fi
5294
5295 # Check to see that this really is a libtool archive.
5296 func_lalib_unsafe_p "$lib" \
5297 || func_fatal_error "\`$lib' is not a valid libtool archive"
5298
5299 func_dirname "$lib" "" "."
5300 ladir="$func_dirname_result"
5301
5302 dlname=
5303 dlopen=
5304 dlpreopen=
5305 libdir=
5306 library_names=
5307 old_library=
5308 inherited_linker_flags=
5309 # If the library was installed with an old release of libtool,
5310 # it will not redefine variables installed, or shouldnotlink
5311 installed=yes
5312 shouldnotlink=no
5313 avoidtemprpath=
5314
5315
5316 # Read the .la file
5317 func_source "$lib"
5318
5319 # Convert "-framework foo" to "foo.ltframework"
5320 if test -n "$inherited_linker_flags"; then
5321 tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5322 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5323 case " $new_inherited_linker_flags " in
5324 *" $tmp_inherited_linker_flag "*) ;;
5325 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5326 esac
5327 done
5328 fi
5329 dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5330 if test "$linkmode,$pass" = "lib,link" ||
5331 test "$linkmode,$pass" = "prog,scan" ||
5332 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5333 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5334 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5335 fi
5336
5337 if test "$pass" = conv; then
5338 # Only check for convenience libraries
5339 deplibs="$lib $deplibs"
5340 if test -z "$libdir"; then
5341 if test -z "$old_library"; then
5342 func_fatal_error "cannot find name of link library for \`$lib'"
5343 fi
5344 # It is a libtool convenience library, so add in its objects.
5345 convenience="$convenience $ladir/$objdir/$old_library"
5346 old_convenience="$old_convenience $ladir/$objdir/$old_library"
5347 elif test "$linkmode" != prog && test "$linkmode" != lib; then
5348 func_fatal_error "\`$lib' is not a convenience library"
5349 fi
5350 tmp_libs=
5351 for deplib in $dependency_libs; do
5352 deplibs="$deplib $deplibs"
5353 if $opt_duplicate_deps ; then
5354 case "$tmp_libs " in
5355 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5356 esac
5357 fi
5358 tmp_libs="$tmp_libs $deplib"
5359 done
5360 continue
5361 fi # $pass = conv
5362
5363
5364 # Get the name of the library we link against.
5365 linklib=
5366 for l in $old_library $library_names; do
5367 linklib="$l"
5368 done
5369 if test -z "$linklib"; then
5370 func_fatal_error "cannot find name of link library for \`$lib'"
5371 fi
5372
5373 # This library was specified with -dlopen.
5374 if test "$pass" = dlopen; then
5375 if test -z "$libdir"; then
5376 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5377 fi
5378 if test -z "$dlname" ||
5379 test "$dlopen_support" != yes ||
5380 test "$build_libtool_libs" = no; then
5381 # If there is no dlname, no dlopen support or we're linking
5382 # statically, we need to preload. We also need to preload any
5383 # dependent libraries so libltdl's deplib preloader doesn't
5384 # bomb out in the load deplibs phase.
5385 dlprefiles="$dlprefiles $lib $dependency_libs"
5386 else
5387 newdlfiles="$newdlfiles $lib"
5388 fi
5389 continue
5390 fi # $pass = dlopen
5391
5392 # We need an absolute path.
5393 case $ladir in
5394 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5395 *)
5396 abs_ladir=`cd "$ladir" && pwd`
5397 if test -z "$abs_ladir"; then
5398 func_warning "cannot determine absolute directory name of \`$ladir'"
5399 func_warning "passing it literally to the linker, although it might fail"
5400 abs_ladir="$ladir"
5401 fi
5402 ;;
5403 esac
5404 func_basename "$lib"
5405 laname="$func_basename_result"
5406
5407 # Find the relevant object directory and library name.
5408 if test "X$installed" = Xyes; then
5409 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5410 func_warning "library \`$lib' was moved."
5411 dir="$ladir"
5412 absdir="$abs_ladir"
5413 libdir="$abs_ladir"
5414 else
5415 dir="$libdir"
5416 absdir="$libdir"
5417 fi
5418 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5419 else
5420 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5421 dir="$ladir"
5422 absdir="$abs_ladir"
5423 # Remove this search path later
5424 notinst_path="$notinst_path $abs_ladir"
5425 else
5426 dir="$ladir/$objdir"
5427 absdir="$abs_ladir/$objdir"
5428 # Remove this search path later
5429 notinst_path="$notinst_path $abs_ladir"
5430 fi
5431 fi # $installed = yes
5432 func_stripname 'lib' '.la' "$laname"
5433 name=$func_stripname_result
5434
5435 # This library was specified with -dlpreopen.
5436 if test "$pass" = dlpreopen; then
5437 if test -z "$libdir" && test "$linkmode" = prog; then
5438 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5439 fi
5440 # Prefer using a static library (so that no silly _DYNAMIC symbols
5441 # are required to link).
5442 if test -n "$old_library"; then
5443 newdlprefiles="$newdlprefiles $dir/$old_library"
5444 # Keep a list of preopened convenience libraries to check
5445 # that they are being used correctly in the link pass.
5446 test -z "$libdir" && \
5447 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5448 # Otherwise, use the dlname, so that lt_dlopen finds it.
5449 elif test -n "$dlname"; then
5450 newdlprefiles="$newdlprefiles $dir/$dlname"
5451 else
5452 newdlprefiles="$newdlprefiles $dir/$linklib"
5453 fi
5454 fi # $pass = dlpreopen
5455
5456 if test -z "$libdir"; then
5457 # Link the convenience library
5458 if test "$linkmode" = lib; then
5459 deplibs="$dir/$old_library $deplibs"
5460 elif test "$linkmode,$pass" = "prog,link"; then
5461 compile_deplibs="$dir/$old_library $compile_deplibs"
5462 finalize_deplibs="$dir/$old_library $finalize_deplibs"
5463 else
5464 deplibs="$lib $deplibs" # used for prog,scan pass
5465 fi
5466 continue
5467 fi
5468
5469
5470 if test "$linkmode" = prog && test "$pass" != link; then
5471 newlib_search_path="$newlib_search_path $ladir"
5472 deplibs="$lib $deplibs"
5473
5474 linkalldeplibs=no
5475 if test "$link_all_deplibs" != no || test -z "$library_names" ||
5476 test "$build_libtool_libs" = no; then
5477 linkalldeplibs=yes
5478 fi
5479
5480 tmp_libs=
5481 for deplib in $dependency_libs; do
5482 case $deplib in
5483 -L*) func_stripname '-L' '' "$deplib"
5484 newlib_search_path="$newlib_search_path $func_stripname_result"
5485 ;;
5486 esac
5487 # Need to link against all dependency_libs?
5488 if test "$linkalldeplibs" = yes; then
5489 deplibs="$deplib $deplibs"
5490 else
5491 # Need to hardcode shared library paths
5492 # or/and link against static libraries
5493 newdependency_libs="$deplib $newdependency_libs"
5494 fi
5495 if $opt_duplicate_deps ; then
5496 case "$tmp_libs " in
5497 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5498 esac
5499 fi
5500 tmp_libs="$tmp_libs $deplib"
5501 done # for deplib
5502 continue
5503 fi # $linkmode = prog...
5504
5505 if test "$linkmode,$pass" = "prog,link"; then
5506 if test -n "$library_names" &&
5507 { { test "$prefer_static_libs" = no ||
5508 test "$prefer_static_libs,$installed" = "built,yes"; } ||
5509 test -z "$old_library"; }; then
5510 # We need to hardcode the library path
5511 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5512 # Make sure the rpath contains only unique directories.
5513 case "$temp_rpath:" in
5514 *"$absdir:"*) ;;
5515 *) temp_rpath="$temp_rpath$absdir:" ;;
5516 esac
5517 fi
5518
5519 # Hardcode the library path.
5520 # Skip directories that are in the system default run-time
5521 # search path.
5522 case " $sys_lib_dlsearch_path " in
5523 *" $absdir "*) ;;
5524 *)
5525 case "$compile_rpath " in
5526 *" $absdir "*) ;;
5527 *) compile_rpath="$compile_rpath $absdir"
5528 esac
5529 ;;
5530 esac
5531 case " $sys_lib_dlsearch_path " in
5532 *" $libdir "*) ;;
5533 *)
5534 case "$finalize_rpath " in
5535 *" $libdir "*) ;;
5536 *) finalize_rpath="$finalize_rpath $libdir"
5537 esac
5538 ;;
5539 esac
5540 fi # $linkmode,$pass = prog,link...
5541
5542 if test "$alldeplibs" = yes &&
5543 { test "$deplibs_check_method" = pass_all ||
5544 { test "$build_libtool_libs" = yes &&
5545 test -n "$library_names"; }; }; then
5546 # We only need to search for static libraries
5547 continue
5548 fi
5549 fi
5550
5551 link_static=no # Whether the deplib will be linked statically
5552 use_static_libs=$prefer_static_libs
5553 if test "$use_static_libs" = built && test "$installed" = yes; then
5554 use_static_libs=no
5555 fi
5556 if test -n "$library_names" &&
5557 { test "$use_static_libs" = no || test -z "$old_library"; }; then
5558 case $host in
5559 *cygwin* | *mingw* | *cegcc*)
5560 # No point in relinking DLLs because paths are not encoded
5561 notinst_deplibs="$notinst_deplibs $lib"
5562 need_relink=no
5563 ;;
5564 *)
5565 if test "$installed" = no; then
5566 notinst_deplibs="$notinst_deplibs $lib"
5567 need_relink=yes
5568 fi
5569 ;;
5570 esac
5571 # This is a shared library
5572
5573 # Warn about portability, can't link against -module's on some
5574 # systems (darwin). Don't bleat about dlopened modules though!
5575 dlopenmodule=""
5576 for dlpremoduletest in $dlprefiles; do
5577 if test "X$dlpremoduletest" = "X$lib"; then
5578 dlopenmodule="$dlpremoduletest"
5579 break
5580 fi
5581 done
5582 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5583 $ECHO
5584 if test "$linkmode" = prog; then
5585 $ECHO "*** Warning: Linking the executable $output against the loadable module"
5586 else
5587 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5588 fi
5589 $ECHO "*** $linklib is not portable!"
5590 fi
5591 if test "$linkmode" = lib &&
5592 test "$hardcode_into_libs" = yes; then
5593 # Hardcode the library path.
5594 # Skip directories that are in the system default run-time
5595 # search path.
5596 case " $sys_lib_dlsearch_path " in
5597 *" $absdir "*) ;;
5598 *)
5599 case "$compile_rpath " in
5600 *" $absdir "*) ;;
5601 *) compile_rpath="$compile_rpath $absdir"
5602 esac
5603 ;;
5604 esac
5605 case " $sys_lib_dlsearch_path " in
5606 *" $libdir "*) ;;
5607 *)
5608 case "$finalize_rpath " in
5609 *" $libdir "*) ;;
5610 *) finalize_rpath="$finalize_rpath $libdir"
5611 esac
5612 ;;
5613 esac
5614 fi
5615
5616 if test -n "$old_archive_from_expsyms_cmds"; then
5617 # figure out the soname
5618 set dummy $library_names
5619 shift
5620 realname="$1"
5621 shift
5622 libname=`eval "\\$ECHO \"$libname_spec\""`
5623 # use dlname if we got it. it's perfectly good, no?
5624 if test -n "$dlname"; then
5625 soname="$dlname"
5626 elif test -n "$soname_spec"; then
5627 # bleh windows
5628 case $host in
5629 *cygwin* | mingw* | *cegcc*)
5630 func_arith $current - $age
5631 major=$func_arith_result
5632 versuffix="-$major"
5633 ;;
5634 esac
5635 eval soname=\"$soname_spec\"
5636 else
5637 soname="$realname"
5638 fi
5639
5640 # Make a new name for the extract_expsyms_cmds to use
5641 soroot="$soname"
5642 func_basename "$soroot"
5643 soname="$func_basename_result"
5644 func_stripname 'lib' '.dll' "$soname"
5645 newlib=libimp-$func_stripname_result.a
5646
5647 # If the library has no export list, then create one now
5648 if test -f "$output_objdir/$soname-def"; then :
5649 else
5650 func_verbose "extracting exported symbol list from \`$soname'"
5651 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5652 fi
5653
5654 # Create $newlib
5655 if test -f "$output_objdir/$newlib"; then :; else
5656 func_verbose "generating import library for \`$soname'"
5657 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5658 fi
5659 # make sure the library variables are pointing to the new library
5660 dir=$output_objdir
5661 linklib=$newlib
5662 fi # test -n "$old_archive_from_expsyms_cmds"
5663
5664 if test "$linkmode" = prog || test "$mode" != relink; then
5665 add_shlibpath=
5666 add_dir=
5667 add=
5668 lib_linked=yes
5669 case $hardcode_action in
5670 immediate | unsupported)
5671 if test "$hardcode_direct" = no; then
5672 add="$dir/$linklib"
5673 case $host in
5674 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5675 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5676 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5677 *-*-unixware7*) add_dir="-L$dir" ;;
5678 *-*-darwin* )
5679 # if the lib is a (non-dlopened) module then we can not
5680 # link against it, someone is ignoring the earlier warnings
5681 if /usr/bin/file -L $add 2> /dev/null |
5682 $GREP ": [^:]* bundle" >/dev/null ; then
5683 if test "X$dlopenmodule" != "X$lib"; then
5684 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5685 if test -z "$old_library" ; then
5686 $ECHO
5687 $ECHO "*** And there doesn't seem to be a static archive available"
5688 $ECHO "*** The link will probably fail, sorry"
5689 else
5690 add="$dir/$old_library"
5691 fi
5692 elif test -n "$old_library"; then
5693 add="$dir/$old_library"
5694 fi
5695 fi
5696 esac
5697 elif test "$hardcode_minus_L" = no; then
5698 case $host in
5699 *-*-sunos*) add_shlibpath="$dir" ;;
5700 esac
5701 add_dir="-L$dir"
5702 add="-l$name"
5703 elif test "$hardcode_shlibpath_var" = no; then
5704 add_shlibpath="$dir"
5705 add="-l$name"
5706 else
5707 lib_linked=no
5708 fi
5709 ;;
5710 relink)
5711 if test "$hardcode_direct" = yes &&
5712 test "$hardcode_direct_absolute" = no; then
5713 add="$dir/$linklib"
5714 elif test "$hardcode_minus_L" = yes; then
5715 add_dir="-L$dir"
5716 # Try looking first in the location we're being installed to.
5717 if test -n "$inst_prefix_dir"; then
5718 case $libdir in
5719 [\\/]*)
5720 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5721 ;;
5722 esac
5723 fi
5724 add="-l$name"
5725 elif test "$hardcode_shlibpath_var" = yes; then
5726 add_shlibpath="$dir"
5727 add="-l$name"
5728 else
5729 lib_linked=no
5730 fi
5731 ;;
5732 *) lib_linked=no ;;
5733 esac
5734
5735 if test "$lib_linked" != yes; then
5736 func_fatal_configuration "unsupported hardcode properties"
5737 fi
5738
5739 if test -n "$add_shlibpath"; then
5740 case :$compile_shlibpath: in
5741 *":$add_shlibpath:"*) ;;
5742 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5743 esac
5744 fi
5745 if test "$linkmode" = prog; then
5746 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5747 test -n "$add" && compile_deplibs="$add $compile_deplibs"
5748 else
5749 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5750 test -n "$add" && deplibs="$add $deplibs"
5751 if test "$hardcode_direct" != yes &&
5752 test "$hardcode_minus_L" != yes &&
5753 test "$hardcode_shlibpath_var" = yes; then
5754 case :$finalize_shlibpath: in
5755 *":$libdir:"*) ;;
5756 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5757 esac
5758 fi
5759 fi
5760 fi
5761
5762 if test "$linkmode" = prog || test "$mode" = relink; then
5763 add_shlibpath=
5764 add_dir=
5765 add=
5766 # Finalize command for both is simple: just hardcode it.
5767 if test "$hardcode_direct" = yes &&
5768 test "$hardcode_direct_absolute" = no; then
5769 add="$libdir/$linklib"
5770 elif test "$hardcode_minus_L" = yes; then
5771 add_dir="-L$libdir"
5772 add="-l$name"
5773 elif test "$hardcode_shlibpath_var" = yes; then
5774 case :$finalize_shlibpath: in
5775 *":$libdir:"*) ;;
5776 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5777 esac
5778 add="-l$name"
5779 elif test "$hardcode_automatic" = yes; then
5780 if test -n "$inst_prefix_dir" &&
5781 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5782 add="$inst_prefix_dir$libdir/$linklib"
5783 else
5784 add="$libdir/$linklib"
5785 fi
5786 else
5787 # We cannot seem to hardcode it, guess we'll fake it.
5788 add_dir="-L$libdir"
5789 # Try looking first in the location we're being installed to.
5790 if test -n "$inst_prefix_dir"; then
5791 case $libdir in
5792 [\\/]*)
5793 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5794 ;;
5795 esac
5796 fi
5797 add="-l$name"
5798 fi
5799
5800 if test "$linkmode" = prog; then
5801 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5802 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5803 else
5804 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5805 test -n "$add" && deplibs="$add $deplibs"
5806 fi
5807 fi
5808 elif test "$linkmode" = prog; then
5809 # Here we assume that one of hardcode_direct or hardcode_minus_L
5810 # is not unsupported. This is valid on all known static and
5811 # shared platforms.
5812 if test "$hardcode_direct" != unsupported; then
5813 test -n "$old_library" && linklib="$old_library"
5814 compile_deplibs="$dir/$linklib $compile_deplibs"
5815 finalize_deplibs="$dir/$linklib $finalize_deplibs"
5816 else
5817 compile_deplibs="-l$name -L$dir $compile_deplibs"
5818 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5819 fi
5820 elif test "$build_libtool_libs" = yes; then
5821 # Not a shared library
5822 if test "$deplibs_check_method" != pass_all; then
5823 # We're trying link a shared library against a static one
5824 # but the system doesn't support it.
5825
5826 # Just print a warning and add the library to dependency_libs so
5827 # that the program can be linked against the static library.
5828 $ECHO
5829 $ECHO "*** Warning: This system can not link to static lib archive $lib."
5830 $ECHO "*** I have the capability to make that library automatically link in when"
5831 $ECHO "*** you link to this library. But I can only do this if you have a"
5832 $ECHO "*** shared version of the library, which you do not appear to have."
5833 if test "$module" = yes; then
5834 $ECHO "*** But as you try to build a module library, libtool will still create "
5835 $ECHO "*** a static module, that should work as long as the dlopening application"
5836 $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5837 if test -z "$global_symbol_pipe"; then
5838 $ECHO
5839 $ECHO "*** However, this would only work if libtool was able to extract symbol"
5840 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5841 $ECHO "*** not find such a program. So, this module is probably useless."
5842 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5843 fi
5844 if test "$build_old_libs" = no; then
5845 build_libtool_libs=module
5846 build_old_libs=yes
5847 else
5848 build_libtool_libs=no
5849 fi
5850 fi
5851 else
5852 deplibs="$dir/$old_library $deplibs"
5853 link_static=yes
5854 fi
5855 fi # link shared/static library?
5856
5857 if test "$linkmode" = lib; then
5858 if test -n "$dependency_libs" &&
5859 { test "$hardcode_into_libs" != yes ||
5860 test "$build_old_libs" = yes ||
5861 test "$link_static" = yes; }; then
5862 # Extract -R from dependency_libs
5863 temp_deplibs=
5864 for libdir in $dependency_libs; do
5865 case $libdir in
5866 -R*) func_stripname '-R' '' "$libdir"
5867 temp_xrpath=$func_stripname_result
5868 case " $xrpath " in
5869 *" $temp_xrpath "*) ;;
5870 *) xrpath="$xrpath $temp_xrpath";;
5871 esac;;
5872 *) temp_deplibs="$temp_deplibs $libdir";;
5873 esac
5874 done
5875 dependency_libs="$temp_deplibs"
5876 fi
5877
5878 newlib_search_path="$newlib_search_path $absdir"
5879 # Link against this library
5880 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5881 # ... and its dependency_libs
5882 tmp_libs=
5883 for deplib in $dependency_libs; do
5884 newdependency_libs="$deplib $newdependency_libs"
5885 if $opt_duplicate_deps ; then
5886 case "$tmp_libs " in
5887 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5888 esac
5889 fi
5890 tmp_libs="$tmp_libs $deplib"
5891 done
5892
5893 if test "$link_all_deplibs" != no; then
5894 # Add the search paths of all dependency libraries
5895 for deplib in $dependency_libs; do
5896 case $deplib in
5897 -L*) path="$deplib" ;;
5898 *.la)
5899 func_dirname "$deplib" "" "."
5900 dir="$func_dirname_result"
5901 # We need an absolute path.
5902 case $dir in
5903 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5904 *)
5905 absdir=`cd "$dir" && pwd`
5906 if test -z "$absdir"; then
5907 func_warning "cannot determine absolute directory name of \`$dir'"
5908 absdir="$dir"
5909 fi
5910 ;;
5911 esac
5912 if $GREP "^installed=no" $deplib > /dev/null; then
5913 case $host in
5914 *-*-darwin*)
5915 depdepl=
5916 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5917 if test -n "$deplibrary_names" ; then
5918 for tmp in $deplibrary_names ; do
5919 depdepl=$tmp
5920 done
5921 if test -f "$absdir/$objdir/$depdepl" ; then
5922 depdepl="$absdir/$objdir/$depdepl"
5923 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5924 if test -z "$darwin_install_name"; then
5925 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5926 fi
5927 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5928 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5929 path=
5930 fi
5931 fi
5932 ;;
5933 *)
5934 path="-L$absdir/$objdir"
5935 ;;
5936 esac
5937 else
5938 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5939 test -z "$libdir" && \
5940 func_fatal_error "\`$deplib' is not a valid libtool archive"
5941 test "$absdir" != "$libdir" && \
5942 func_warning "\`$deplib' seems to be moved"
5943
5944 path="-L$absdir"
5945 fi
5946 ;;
5947 esac
5948 case " $deplibs " in
5949 *" $path "*) ;;
5950 *) deplibs="$path $deplibs" ;;
5951 esac
5952 done
5953 fi # link_all_deplibs != no
5954 fi # linkmode = lib
5955 done # for deplib in $libs
5956 if test "$pass" = link; then
5957 if test "$linkmode" = "prog"; then
5958 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5959 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5960 else
5961 compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5962 fi
5963 fi
5964 dependency_libs="$newdependency_libs"
5965 if test "$pass" = dlpreopen; then
5966 # Link the dlpreopened libraries before other libraries
5967 for deplib in $save_deplibs; do
5968 deplibs="$deplib $deplibs"
5969 done
5970 fi
5971 if test "$pass" != dlopen; then
5972 if test "$pass" != conv; then
5973 # Make sure lib_search_path contains only unique directories.
5974 lib_search_path=
5975 for dir in $newlib_search_path; do
5976 case "$lib_search_path " in
5977 *" $dir "*) ;;
5978 *) lib_search_path="$lib_search_path $dir" ;;
5979 esac
5980 done
5981 newlib_search_path=
5982 fi
5983
5984 if test "$linkmode,$pass" != "prog,link"; then
5985 vars="deplibs"
5986 else
5987 vars="compile_deplibs finalize_deplibs"
5988 fi
5989 for var in $vars dependency_libs; do
5990 # Add libraries to $var in reverse order
5991 eval tmp_libs=\"\$$var\"
5992 new_libs=
5993 for deplib in $tmp_libs; do
5994 # FIXME: Pedantically, this is the right thing to do, so
5995 # that some nasty dependency loop isn't accidentally
5996 # broken:
5997 #new_libs="$deplib $new_libs"
5998 # Pragmatically, this seems to cause very few problems in
5999 # practice:
6000 case $deplib in
6001 -L*) new_libs="$deplib $new_libs" ;;
6002 -R*) ;;
6003 *)
6004 # And here is the reason: when a library appears more
6005 # than once as an explicit dependence of a library, or
6006 # is implicitly linked in more than once by the
6007 # compiler, it is considered special, and multiple
6008 # occurrences thereof are not removed. Compare this
6009 # with having the same library being listed as a
6010 # dependency of multiple other libraries: in this case,
6011 # we know (pedantically, we assume) the library does not
6012 # need to be listed more than once, so we keep only the
6013 # last copy. This is not always right, but it is rare
6014 # enough that we require users that really mean to play
6015 # such unportable linking tricks to link the library
6016 # using -Wl,-lname, so that libtool does not consider it
6017 # for duplicate removal.
6018 case " $specialdeplibs " in
6019 *" $deplib "*) new_libs="$deplib $new_libs" ;;
6020 *)
6021 case " $new_libs " in
6022 *" $deplib "*) ;;
6023 *) new_libs="$deplib $new_libs" ;;
6024 esac
6025 ;;
6026 esac
6027 ;;
6028 esac
6029 done
6030 tmp_libs=
6031 for deplib in $new_libs; do
6032 case $deplib in
6033 -L*)
6034 case " $tmp_libs " in
6035 *" $deplib "*) ;;
6036 *) tmp_libs="$tmp_libs $deplib" ;;
6037 esac
6038 ;;
6039 *) tmp_libs="$tmp_libs $deplib" ;;
6040 esac
6041 done
6042 eval $var=\"$tmp_libs\"
6043 done # for var
6044 fi
6045 # Last step: remove runtime libs from dependency_libs
6046 # (they stay in deplibs)
6047 tmp_libs=
6048 for i in $dependency_libs ; do
6049 case " $predeps $postdeps $compiler_lib_search_path " in
6050 *" $i "*)
6051 i=""
6052 ;;
6053 esac
6054 if test -n "$i" ; then
6055 tmp_libs="$tmp_libs $i"
6056 fi
6057 done
6058 dependency_libs=$tmp_libs
6059 done # for pass
6060 if test "$linkmode" = prog; then
6061 dlfiles="$newdlfiles"
6062 fi
6063 if test "$linkmode" = prog || test "$linkmode" = lib; then
6064 dlprefiles="$newdlprefiles"
6065 fi
6066
6067 case $linkmode in
6068 oldlib)
6069 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6070 func_warning "\`-dlopen' is ignored for archives"
6071 fi
6072
6073 case " $deplibs" in
6074 *\ -l* | *\ -L*)
6075 func_warning "\`-l' and \`-L' are ignored for archives" ;;
6076 esac
6077
6078 test -n "$rpath" && \
6079 func_warning "\`-rpath' is ignored for archives"
6080
6081 test -n "$xrpath" && \
6082 func_warning "\`-R' is ignored for archives"
6083
6084 test -n "$vinfo" && \
6085 func_warning "\`-version-info/-version-number' is ignored for archives"
6086
6087 test -n "$release" && \
6088 func_warning "\`-release' is ignored for archives"
6089
6090 test -n "$export_symbols$export_symbols_regex" && \
6091 func_warning "\`-export-symbols' is ignored for archives"
6092
6093 # Now set the variables for building old libraries.
6094 build_libtool_libs=no
6095 oldlibs="$output"
6096 objs="$objs$old_deplibs"
6097 ;;
6098
6099 lib)
6100 # Make sure we only generate libraries of the form `libNAME.la'.
6101 case $outputname in
6102 lib*)
6103 func_stripname 'lib' '.la' "$outputname"
6104 name=$func_stripname_result
6105 eval shared_ext=\"$shrext_cmds\"
6106 eval libname=\"$libname_spec\"
6107 ;;
6108 *)
6109 test "$module" = no && \
6110 func_fatal_help "libtool library \`$output' must begin with \`lib'"
6111
6112 if test "$need_lib_prefix" != no; then
6113 # Add the "lib" prefix for modules if required
6114 func_stripname '' '.la' "$outputname"
6115 name=$func_stripname_result
6116 eval shared_ext=\"$shrext_cmds\"
6117 eval libname=\"$libname_spec\"
6118 else
6119 func_stripname '' '.la' "$outputname"
6120 libname=$func_stripname_result
6121 fi
6122 ;;
6123 esac
6124
6125 if test -n "$objs"; then
6126 if test "$deplibs_check_method" != pass_all; then
6127 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6128 else
6129 $ECHO
6130 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6131 $ECHO "*** objects $objs is not portable!"
6132 libobjs="$libobjs $objs"
6133 fi
6134 fi
6135
6136 test "$dlself" != no && \
6137 func_warning "\`-dlopen self' is ignored for libtool libraries"
6138
6139 set dummy $rpath
6140 shift
6141 test "$#" -gt 1 && \
6142 func_warning "ignoring multiple \`-rpath's for a libtool library"
6143
6144 install_libdir="$1"
6145
6146 oldlibs=
6147 if test -z "$rpath"; then
6148 if test "$build_libtool_libs" = yes; then
6149 # Building a libtool convenience library.
6150 # Some compilers have problems with a `.al' extension so
6151 # convenience libraries should have the same extension an
6152 # archive normally would.
6153 oldlibs="$output_objdir/$libname.$libext $oldlibs"
6154 build_libtool_libs=convenience
6155 build_old_libs=yes
6156 fi
6157
6158 test -n "$vinfo" && \
6159 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6160
6161 test -n "$release" && \
6162 func_warning "\`-release' is ignored for convenience libraries"
6163 else
6164
6165 # Parse the version information argument.
6166 save_ifs="$IFS"; IFS=':'
6167 set dummy $vinfo 0 0 0
6168 shift
6169 IFS="$save_ifs"
6170
6171 test -n "$7" && \
6172 func_fatal_help "too many parameters to \`-version-info'"
6173
6174 # convert absolute version numbers to libtool ages
6175 # this retains compatibility with .la files and attempts
6176 # to make the code below a bit more comprehensible
6177
6178 case $vinfo_number in
6179 yes)
6180 number_major="$1"
6181 number_minor="$2"
6182 number_revision="$3"
6183 #
6184 # There are really only two kinds -- those that
6185 # use the current revision as the major version
6186 # and those that subtract age and use age as
6187 # a minor version. But, then there is irix
6188 # which has an extra 1 added just for fun
6189 #
6190 case $version_type in
6191 darwin|linux|osf|windows|none)
6192 func_arith $number_major + $number_minor
6193 current=$func_arith_result
6194 age="$number_minor"
6195 revision="$number_revision"
6196 ;;
6197 freebsd-aout|freebsd-elf|sunos)
6198 current="$number_major"
6199 revision="$number_minor"
6200 age="0"
6201 ;;
6202 irix|nonstopux)
6203 func_arith $number_major + $number_minor
6204 current=$func_arith_result
6205 age="$number_minor"
6206 revision="$number_minor"
6207 lt_irix_increment=no
6208 ;;
6209 esac
6210 ;;
6211 no)
6212 current="$1"
6213 revision="$2"
6214 age="$3"
6215 ;;
6216 esac
6217
6218 # Check that each of the things are valid numbers.
6219 case $current in
6220 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]) ;;
6221 *)
6222 func_error "CURRENT \`$current' must be a nonnegative integer"
6223 func_fatal_error "\`$vinfo' is not valid version information"
6224 ;;
6225 esac
6226
6227 case $revision in
6228 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]) ;;
6229 *)
6230 func_error "REVISION \`$revision' must be a nonnegative integer"
6231 func_fatal_error "\`$vinfo' is not valid version information"
6232 ;;
6233 esac
6234
6235 case $age in
6236 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]) ;;
6237 *)
6238 func_error "AGE \`$age' must be a nonnegative integer"
6239 func_fatal_error "\`$vinfo' is not valid version information"
6240 ;;
6241 esac
6242
6243 if test "$age" -gt "$current"; then
6244 func_error "AGE \`$age' is greater than the current interface number \`$current'"
6245 func_fatal_error "\`$vinfo' is not valid version information"
6246 fi
6247
6248 # Calculate the version variables.
6249 major=
6250 versuffix=
6251 verstring=
6252 case $version_type in
6253 none) ;;
6254
6255 darwin)
6256 # Like Linux, but with the current version available in
6257 # verstring for coding it into the library header
6258 func_arith $current - $age
6259 major=.$func_arith_result
6260 versuffix="$major.$age.$revision"
6261 # Darwin ld doesn't like 0 for these options...
6262 func_arith $current + 1
6263 minor_current=$func_arith_result
6264 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6265 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6266 ;;
6267
6268 freebsd-aout)
6269 major=".$current"
6270 versuffix=".$current.$revision";
6271 ;;
6272
6273 freebsd-elf)
6274 major=".$current"
6275 versuffix=".$current"
6276 ;;
6277
6278 irix | nonstopux)
6279 if test "X$lt_irix_increment" = "Xno"; then
6280 func_arith $current - $age
6281 else
6282 func_arith $current - $age + 1
6283 fi
6284 major=$func_arith_result
6285
6286 case $version_type in
6287 nonstopux) verstring_prefix=nonstopux ;;
6288 *) verstring_prefix=sgi ;;
6289 esac
6290 verstring="$verstring_prefix$major.$revision"
6291
6292 # Add in all the interfaces that we are compatible with.
6293 loop=$revision
6294 while test "$loop" -ne 0; do
6295 func_arith $revision - $loop
6296 iface=$func_arith_result
6297 func_arith $loop - 1
6298 loop=$func_arith_result
6299 verstring="$verstring_prefix$major.$iface:$verstring"
6300 done
6301
6302 # Before this point, $major must not contain `.'.
6303 major=.$major
6304 versuffix="$major.$revision"
6305 ;;
6306
6307 linux)
6308 func_arith $current - $age
6309 major=.$func_arith_result
6310 versuffix="$major.$age.$revision"
6311 ;;
6312
6313 osf)
6314 func_arith $current - $age
6315 major=.$func_arith_result
6316 versuffix=".$current.$age.$revision"
6317 verstring="$current.$age.$revision"
6318
6319 # Add in all the interfaces that we are compatible with.
6320 loop=$age
6321 while test "$loop" -ne 0; do
6322 func_arith $current - $loop
6323 iface=$func_arith_result
6324 func_arith $loop - 1
6325 loop=$func_arith_result
6326 verstring="$verstring:${iface}.0"
6327 done
6328
6329 # Make executables depend on our current version.
6330 verstring="$verstring:${current}.0"
6331 ;;
6332
6333 qnx)
6334 major=".$current"
6335 versuffix=".$current"
6336 ;;
6337
6338 sunos)
6339 major=".$current"
6340 versuffix=".$current.$revision"
6341 ;;
6342
6343 windows)
6344 # Use '-' rather than '.', since we only want one
6345 # extension on DOS 8.3 filesystems.
6346 func_arith $current - $age
6347 major=$func_arith_result
6348 versuffix="-$major"
6349 ;;
6350
6351 *)
6352 func_fatal_configuration "unknown library version type \`$version_type'"
6353 ;;
6354 esac
6355
6356 # Clear the version info if we defaulted, and they specified a release.
6357 if test -z "$vinfo" && test -n "$release"; then
6358 major=
6359 case $version_type in
6360 darwin)
6361 # we can't check for "0.0" in archive_cmds due to quoting
6362 # problems, so we reset it completely
6363 verstring=
6364 ;;
6365 *)
6366 verstring="0.0"
6367 ;;
6368 esac
6369 if test "$need_version" = no; then
6370 versuffix=
6371 else
6372 versuffix=".0.0"
6373 fi
6374 fi
6375
6376 # Remove version info from name if versioning should be avoided
6377 if test "$avoid_version" = yes && test "$need_version" = no; then
6378 major=
6379 versuffix=
6380 verstring=""
6381 fi
6382
6383 # Check to see if the archive will have undefined symbols.
6384 if test "$allow_undefined" = yes; then
6385 if test "$allow_undefined_flag" = unsupported; then
6386 func_warning "undefined symbols not allowed in $host shared libraries"
6387 build_libtool_libs=no
6388 build_old_libs=yes
6389 fi
6390 else
6391 # Don't allow undefined symbols.
6392 allow_undefined_flag="$no_undefined_flag"
6393 fi
6394
6395 fi
6396
6397 func_generate_dlsyms "$libname" "$libname" "yes"
6398 libobjs="$libobjs $symfileobj"
6399 test "X$libobjs" = "X " && libobjs=
6400
6401 if test "$mode" != relink; then
6402 # Remove our outputs, but don't remove object files since they
6403 # may have been created when compiling PIC objects.
6404 removelist=
6405 tempremovelist=`$ECHO "$output_objdir/*"`
6406 for p in $tempremovelist; do
6407 case $p in
6408 *.$objext | *.gcno)
6409 ;;
6410 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6411 if test "X$precious_files_regex" != "X"; then
6412 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6413 then
6414 continue
6415 fi
6416 fi
6417 removelist="$removelist $p"
6418 ;;
6419 *) ;;
6420 esac
6421 done
6422 test -n "$removelist" && \
6423 func_show_eval "${RM}r \$removelist"
6424 fi
6425
6426 # Now set the variables for building old libraries.
6427 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6428 oldlibs="$oldlibs $output_objdir/$libname.$libext"
6429
6430 # Transform .lo files to .o files.
6431 oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6432 fi
6433
6434 # Eliminate all temporary directories.
6435 #for path in $notinst_path; do
6436 # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6437 # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6438 # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6439 #done
6440
6441 if test -n "$xrpath"; then
6442 # If the user specified any rpath flags, then add them.
6443 temp_xrpath=
6444 for libdir in $xrpath; do
6445 temp_xrpath="$temp_xrpath -R$libdir"
6446 case "$finalize_rpath " in
6447 *" $libdir "*) ;;
6448 *) finalize_rpath="$finalize_rpath $libdir" ;;
6449 esac
6450 done
6451 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6452 dependency_libs="$temp_xrpath $dependency_libs"
6453 fi
6454 fi
6455
6456 # Make sure dlfiles contains only unique files that won't be dlpreopened
6457 old_dlfiles="$dlfiles"
6458 dlfiles=
6459 for lib in $old_dlfiles; do
6460 case " $dlprefiles $dlfiles " in
6461 *" $lib "*) ;;
6462 *) dlfiles="$dlfiles $lib" ;;
6463 esac
6464 done
6465
6466 # Make sure dlprefiles contains only unique files
6467 old_dlprefiles="$dlprefiles"
6468 dlprefiles=
6469 for lib in $old_dlprefiles; do
6470 case "$dlprefiles " in
6471 *" $lib "*) ;;
6472 *) dlprefiles="$dlprefiles $lib" ;;
6473 esac
6474 done
6475
6476 if test "$build_libtool_libs" = yes; then
6477 if test -n "$rpath"; then
6478 case $host in
6479 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6480 # these systems don't actually have a c library (as such)!
6481 ;;
6482 *-*-rhapsody* | *-*-darwin1.[012])
6483 # Rhapsody C library is in the System framework
6484 deplibs="$deplibs System.ltframework"
6485 ;;
6486 *-*-netbsd*)
6487 # Don't link with libc until the a.out ld.so is fixed.
6488 ;;
6489 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6490 # Do not include libc due to us having libc/libc_r.
6491 ;;
6492 *-*-sco3.2v5* | *-*-sco5v6*)
6493 # Causes problems with __ctype
6494 ;;
6495 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6496 # Compiler inserts libc in the correct place for threads to work
6497 ;;
6498 *)
6499 # Add libc to deplibs on all other systems if necessary.
6500 if test "$build_libtool_need_lc" = "yes"; then
6501 deplibs="$deplibs -lc"
6502 fi
6503 ;;
6504 esac
6505 fi
6506
6507 # Transform deplibs into only deplibs that can be linked in shared.
6508 name_save=$name
6509 libname_save=$libname
6510 release_save=$release
6511 versuffix_save=$versuffix
6512 major_save=$major
6513 # I'm not sure if I'm treating the release correctly. I think
6514 # release should show up in the -l (ie -lgmp5) so we don't want to
6515 # add it in twice. Is that correct?
6516 release=""
6517 versuffix=""
6518 major=""
6519 newdeplibs=
6520 droppeddeps=no
6521 case $deplibs_check_method in
6522 pass_all)
6523 # Don't check for shared/static. Everything works.
6524 # This might be a little naive. We might want to check
6525 # whether the library exists or not. But this is on
6526 # osf3 & osf4 and I'm not really sure... Just
6527 # implementing what was already the behavior.
6528 newdeplibs=$deplibs
6529 ;;
6530 test_compile)
6531 # This code stresses the "libraries are programs" paradigm to its
6532 # limits. Maybe even breaks it. We compile a program, linking it
6533 # against the deplibs as a proxy for the library. Then we can check
6534 # whether they linked in statically or dynamically with ldd.
6535 $opt_dry_run || $RM conftest.c
6536 cat > conftest.c <<EOF
6537 int main() { return 0; }
6538 EOF
6539 $opt_dry_run || $RM conftest
6540 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6541 ldd_output=`ldd conftest`
6542 for i in $deplibs; do
6543 case $i in
6544 -l*)
6545 func_stripname -l '' "$i"
6546 name=$func_stripname_result
6547 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6548 case " $predeps $postdeps " in
6549 *" $i "*)
6550 newdeplibs="$newdeplibs $i"
6551 i=""
6552 ;;
6553 esac
6554 fi
6555 if test -n "$i" ; then
6556 libname=`eval "\\$ECHO \"$libname_spec\""`
6557 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6558 set dummy $deplib_matches; shift
6559 deplib_match=$1
6560 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6561 newdeplibs="$newdeplibs $i"
6562 else
6563 droppeddeps=yes
6564 $ECHO
6565 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6566 $ECHO "*** I have the capability to make that library automatically link in when"
6567 $ECHO "*** you link to this library. But I can only do this if you have a"
6568 $ECHO "*** shared version of the library, which I believe you do not have"
6569 $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6570 $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6571 fi
6572 fi
6573 ;;
6574 *)
6575 newdeplibs="$newdeplibs $i"
6576 ;;
6577 esac
6578 done
6579 else
6580 # Error occurred in the first compile. Let's try to salvage
6581 # the situation: Compile a separate program for each library.
6582 for i in $deplibs; do
6583 case $i in
6584 -l*)
6585 func_stripname -l '' "$i"
6586 name=$func_stripname_result
6587 $opt_dry_run || $RM conftest
6588 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6589 ldd_output=`ldd conftest`
6590 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6591 case " $predeps $postdeps " in
6592 *" $i "*)
6593 newdeplibs="$newdeplibs $i"
6594 i=""
6595 ;;
6596 esac
6597 fi
6598 if test -n "$i" ; then
6599 libname=`eval "\\$ECHO \"$libname_spec\""`
6600 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6601 set dummy $deplib_matches; shift
6602 deplib_match=$1
6603 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6604 newdeplibs="$newdeplibs $i"
6605 else
6606 droppeddeps=yes
6607 $ECHO
6608 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6609 $ECHO "*** I have the capability to make that library automatically link in when"
6610 $ECHO "*** you link to this library. But I can only do this if you have a"
6611 $ECHO "*** shared version of the library, which you do not appear to have"
6612 $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6613 $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6614 fi
6615 fi
6616 else
6617 droppeddeps=yes
6618 $ECHO
6619 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
6620 $ECHO "*** make it link in! You will probably need to install it or some"
6621 $ECHO "*** library that it depends on before this library will be fully"
6622 $ECHO "*** functional. Installing it before continuing would be even better."
6623 fi
6624 ;;
6625 *)
6626 newdeplibs="$newdeplibs $i"
6627 ;;
6628 esac
6629 done
6630 fi
6631 ;;
6632 file_magic*)
6633 set dummy $deplibs_check_method; shift
6634 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6635 for a_deplib in $deplibs; do
6636 case $a_deplib in
6637 -l*)
6638 func_stripname -l '' "$a_deplib"
6639 name=$func_stripname_result
6640 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6641 case " $predeps $postdeps " in
6642 *" $a_deplib "*)
6643 newdeplibs="$newdeplibs $a_deplib"
6644 a_deplib=""
6645 ;;
6646 esac
6647 fi
6648 if test -n "$a_deplib" ; then
6649 libname=`eval "\\$ECHO \"$libname_spec\""`
6650 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6651 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6652 for potent_lib in $potential_libs; do
6653 # Follow soft links.
6654 if ls -lLd "$potent_lib" 2>/dev/null |
6655 $GREP " -> " >/dev/null; then
6656 continue
6657 fi
6658 # The statement above tries to avoid entering an
6659 # endless loop below, in case of cyclic links.
6660 # We might still enter an endless loop, since a link
6661 # loop can be closed while we follow links,
6662 # but so what?
6663 potlib="$potent_lib"
6664 while test -h "$potlib" 2>/dev/null; do
6665 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6666 case $potliblink in
6667 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6668 *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6669 esac
6670 done
6671 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6672 $SED -e 10q |
6673 $EGREP "$file_magic_regex" > /dev/null; then
6674 newdeplibs="$newdeplibs $a_deplib"
6675 a_deplib=""
6676 break 2
6677 fi
6678 done
6679 done
6680 fi
6681 if test -n "$a_deplib" ; then
6682 droppeddeps=yes
6683 $ECHO
6684 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6685 $ECHO "*** I have the capability to make that library automatically link in when"
6686 $ECHO "*** you link to this library. But I can only do this if you have a"
6687 $ECHO "*** shared version of the library, which you do not appear to have"
6688 $ECHO "*** because I did check the linker path looking for a file starting"
6689 if test -z "$potlib" ; then
6690 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6691 else
6692 $ECHO "*** with $libname and none of the candidates passed a file format test"
6693 $ECHO "*** using a file magic. Last file checked: $potlib"
6694 fi
6695 fi
6696 ;;
6697 *)
6698 # Add a -L argument.
6699 newdeplibs="$newdeplibs $a_deplib"
6700 ;;
6701 esac
6702 done # Gone through all deplibs.
6703 ;;
6704 match_pattern*)
6705 set dummy $deplibs_check_method; shift
6706 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6707 for a_deplib in $deplibs; do
6708 case $a_deplib in
6709 -l*)
6710 func_stripname -l '' "$a_deplib"
6711 name=$func_stripname_result
6712 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6713 case " $predeps $postdeps " in
6714 *" $a_deplib "*)
6715 newdeplibs="$newdeplibs $a_deplib"
6716 a_deplib=""
6717 ;;
6718 esac
6719 fi
6720 if test -n "$a_deplib" ; then
6721 libname=`eval "\\$ECHO \"$libname_spec\""`
6722 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6723 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6724 for potent_lib in $potential_libs; do
6725 potlib="$potent_lib" # see symlink-check above in file_magic test
6726 if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6727 $EGREP "$match_pattern_regex" > /dev/null; then
6728 newdeplibs="$newdeplibs $a_deplib"
6729 a_deplib=""
6730 break 2
6731 fi
6732 done
6733 done
6734 fi
6735 if test -n "$a_deplib" ; then
6736 droppeddeps=yes
6737 $ECHO
6738 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6739 $ECHO "*** I have the capability to make that library automatically link in when"
6740 $ECHO "*** you link to this library. But I can only do this if you have a"
6741 $ECHO "*** shared version of the library, which you do not appear to have"
6742 $ECHO "*** because I did check the linker path looking for a file starting"
6743 if test -z "$potlib" ; then
6744 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6745 else
6746 $ECHO "*** with $libname and none of the candidates passed a file format test"
6747 $ECHO "*** using a regex pattern. Last file checked: $potlib"
6748 fi
6749 fi
6750 ;;
6751 *)
6752 # Add a -L argument.
6753 newdeplibs="$newdeplibs $a_deplib"
6754 ;;
6755 esac
6756 done # Gone through all deplibs.
6757 ;;
6758 none | unknown | *)
6759 newdeplibs=""
6760 tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6761 -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6762 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6763 for i in $predeps $postdeps ; do
6764 # can't use Xsed below, because $i might contain '/'
6765 tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6766 done
6767 fi
6768 if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
6769 $GREP . >/dev/null; then
6770 $ECHO
6771 if test "X$deplibs_check_method" = "Xnone"; then
6772 $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6773 else
6774 $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6775 fi
6776 $ECHO "*** All declared inter-library dependencies are being dropped."
6777 droppeddeps=yes
6778 fi
6779 ;;
6780 esac
6781 versuffix=$versuffix_save
6782 major=$major_save
6783 release=$release_save
6784 libname=$libname_save
6785 name=$name_save
6786
6787 case $host in
6788 *-*-rhapsody* | *-*-darwin1.[012])
6789 # On Rhapsody replace the C library with the System framework
6790 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6791 ;;
6792 esac
6793
6794 if test "$droppeddeps" = yes; then
6795 if test "$module" = yes; then
6796 $ECHO
6797 $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6798 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
6799 $ECHO "*** a static module, that should work as long as the dlopening"
6800 $ECHO "*** application is linked with the -dlopen flag."
6801 if test -z "$global_symbol_pipe"; then
6802 $ECHO
6803 $ECHO "*** However, this would only work if libtool was able to extract symbol"
6804 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6805 $ECHO "*** not find such a program. So, this module is probably useless."
6806 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6807 fi
6808 if test "$build_old_libs" = no; then
6809 oldlibs="$output_objdir/$libname.$libext"
6810 build_libtool_libs=module
6811 build_old_libs=yes
6812 else
6813 build_libtool_libs=no
6814 fi
6815 else
6816 $ECHO "*** The inter-library dependencies that have been dropped here will be"
6817 $ECHO "*** automatically added whenever a program is linked with this library"
6818 $ECHO "*** or is declared to -dlopen it."
6819
6820 if test "$allow_undefined" = no; then
6821 $ECHO
6822 $ECHO "*** Since this library must not contain undefined symbols,"
6823 $ECHO "*** because either the platform does not support them or"
6824 $ECHO "*** it was explicitly requested with -no-undefined,"
6825 $ECHO "*** libtool will only create a static version of it."
6826 if test "$build_old_libs" = no; then
6827 oldlibs="$output_objdir/$libname.$libext"
6828 build_libtool_libs=module
6829 build_old_libs=yes
6830 else
6831 build_libtool_libs=no
6832 fi
6833 fi
6834 fi
6835 fi
6836 # Done checking deplibs!
6837 deplibs=$newdeplibs
6838 fi
6839 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6840 case $host in
6841 *-*-darwin*)
6842 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6843 new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6844 deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6845 ;;
6846 esac
6847
6848 # move library search paths that coincide with paths to not yet
6849 # installed libraries to the beginning of the library search list
6850 new_libs=
6851 for path in $notinst_path; do
6852 case " $new_libs " in
6853 *" -L$path/$objdir "*) ;;
6854 *)
6855 case " $deplibs " in
6856 *" -L$path/$objdir "*)
6857 new_libs="$new_libs -L$path/$objdir" ;;
6858 esac
6859 ;;
6860 esac
6861 done
6862 for deplib in $deplibs; do
6863 case $deplib in
6864 -L*)
6865 case " $new_libs " in
6866 *" $deplib "*) ;;
6867 *) new_libs="$new_libs $deplib" ;;
6868 esac
6869 ;;
6870 *) new_libs="$new_libs $deplib" ;;
6871 esac
6872 done
6873 deplibs="$new_libs"
6874
6875 # All the library-specific variables (install_libdir is set above).
6876 library_names=
6877 old_library=
6878 dlname=
6879
6880 # Test again, we may have decided not to build it any more
6881 if test "$build_libtool_libs" = yes; then
6882 if test "$hardcode_into_libs" = yes; then
6883 # Hardcode the library paths
6884 hardcode_libdirs=
6885 dep_rpath=
6886 rpath="$finalize_rpath"
6887 test "$mode" != relink && rpath="$compile_rpath$rpath"
6888 for libdir in $rpath; do
6889 if test -n "$hardcode_libdir_flag_spec"; then
6890 if test -n "$hardcode_libdir_separator"; then
6891 if test -z "$hardcode_libdirs"; then
6892 hardcode_libdirs="$libdir"
6893 else
6894 # Just accumulate the unique libdirs.
6895 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6896 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6897 ;;
6898 *)
6899 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6900 ;;
6901 esac
6902 fi
6903 else
6904 eval flag=\"$hardcode_libdir_flag_spec\"
6905 dep_rpath="$dep_rpath $flag"
6906 fi
6907 elif test -n "$runpath_var"; then
6908 case "$perm_rpath " in
6909 *" $libdir "*) ;;
6910 *) perm_rpath="$perm_rpath $libdir" ;;
6911 esac
6912 fi
6913 done
6914 # Substitute the hardcoded libdirs into the rpath.
6915 if test -n "$hardcode_libdir_separator" &&
6916 test -n "$hardcode_libdirs"; then
6917 libdir="$hardcode_libdirs"
6918 if test -n "$hardcode_libdir_flag_spec_ld"; then
6919 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6920 else
6921 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6922 fi
6923 fi
6924 if test -n "$runpath_var" && test -n "$perm_rpath"; then
6925 # We should set the runpath_var.
6926 rpath=
6927 for dir in $perm_rpath; do
6928 rpath="$rpath$dir:"
6929 done
6930 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6931 fi
6932 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6933 fi
6934
6935 shlibpath="$finalize_shlibpath"
6936 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6937 if test -n "$shlibpath"; then
6938 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6939 fi
6940
6941 # Get the real and link names of the library.
6942 eval shared_ext=\"$shrext_cmds\"
6943 eval library_names=\"$library_names_spec\"
6944 set dummy $library_names
6945 shift
6946 realname="$1"
6947 shift
6948
6949 if test -n "$soname_spec"; then
6950 eval soname=\"$soname_spec\"
6951 else
6952 soname="$realname"
6953 fi
6954 if test -z "$dlname"; then
6955 dlname=$soname
6956 fi
6957
6958 lib="$output_objdir/$realname"
6959 linknames=
6960 for link
6961 do
6962 linknames="$linknames $link"
6963 done
6964
6965 # Use standard objects if they are pic
6966 test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6967 test "X$libobjs" = "X " && libobjs=
6968
6969 delfiles=
6970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6971 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6972 export_symbols="$output_objdir/$libname.uexp"
6973 delfiles="$delfiles $export_symbols"
6974 fi
6975
6976 orig_export_symbols=
6977 case $host_os in
6978 cygwin* | mingw* | cegcc*)
6979 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6980 # exporting using user supplied symfile
6981 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6982 # and it's NOT already a .def file. Must figure out
6983 # which of the given symbols are data symbols and tag
6984 # them as such. So, trigger use of export_symbols_cmds.
6985 # export_symbols gets reassigned inside the "prepare
6986 # the list of exported symbols" if statement, so the
6987 # include_expsyms logic still works.
6988 orig_export_symbols="$export_symbols"
6989 export_symbols=
6990 always_export_symbols=yes
6991 fi
6992 fi
6993 ;;
6994 esac
6995
6996 # Prepare the list of exported symbols
6997 if test -z "$export_symbols"; then
6998 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
6999 func_verbose "generating symbol list for \`$libname.la'"
7000 export_symbols="$output_objdir/$libname.exp"
7001 $opt_dry_run || $RM $export_symbols
7002 cmds=$export_symbols_cmds
7003 save_ifs="$IFS"; IFS='~'
7004 for cmd in $cmds; do
7005 IFS="$save_ifs"
7006 eval cmd=\"$cmd\"
7007 func_len " $cmd"
7008 len=$func_len_result
7009 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7010 func_show_eval "$cmd" 'exit $?'
7011 skipped_export=false
7012 else
7013 # The command line is too long to execute in one step.
7014 func_verbose "using reloadable object file for export list..."
7015 skipped_export=:
7016 # Break out early, otherwise skipped_export may be
7017 # set to false by a later but shorter cmd.
7018 break
7019 fi
7020 done
7021 IFS="$save_ifs"
7022 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7023 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7024 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7025 fi
7026 fi
7027 fi
7028
7029 if test -n "$export_symbols" && test -n "$include_expsyms"; then
7030 tmp_export_symbols="$export_symbols"
7031 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7032 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7033 fi
7034
7035 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7036 # The given exports_symbols file has to be filtered, so filter it.
7037 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7038 # FIXME: $output_objdir/$libname.filter potentially contains lots of
7039 # 's' commands which not all seds can handle. GNU sed should be fine
7040 # though. Also, the filter scales superlinearly with the number of
7041 # global variables. join(1) would be nice here, but unfortunately
7042 # isn't a blessed tool.
7043 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7044 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7045 export_symbols=$output_objdir/$libname.def
7046 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7047 fi
7048
7049 tmp_deplibs=
7050 for test_deplib in $deplibs; do
7051 case " $convenience " in
7052 *" $test_deplib "*) ;;
7053 *)
7054 tmp_deplibs="$tmp_deplibs $test_deplib"
7055 ;;
7056 esac
7057 done
7058 deplibs="$tmp_deplibs"
7059
7060 if test -n "$convenience"; then
7061 if test -n "$whole_archive_flag_spec" &&
7062 test "$compiler_needs_object" = yes &&
7063 test -z "$libobjs"; then
7064 # extract the archives, so we have objects to list.
7065 # TODO: could optimize this to just extract one archive.
7066 whole_archive_flag_spec=
7067 fi
7068 if test -n "$whole_archive_flag_spec"; then
7069 save_libobjs=$libobjs
7070 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7071 test "X$libobjs" = "X " && libobjs=
7072 else
7073 gentop="$output_objdir/${outputname}x"
7074 generated="$generated $gentop"
7075
7076 func_extract_archives $gentop $convenience
7077 libobjs="$libobjs $func_extract_archives_result"
7078 test "X$libobjs" = "X " && libobjs=
7079 fi
7080 fi
7081
7082 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7083 eval flag=\"$thread_safe_flag_spec\"
7084 linker_flags="$linker_flags $flag"
7085 fi
7086
7087 # Make a backup of the uninstalled library when relinking
7088 if test "$mode" = relink; then
7089 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7090 fi
7091
7092 # Do each of the archive commands.
7093 if test "$module" = yes && test -n "$module_cmds" ; then
7094 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7095 eval test_cmds=\"$module_expsym_cmds\"
7096 cmds=$module_expsym_cmds
7097 else
7098 eval test_cmds=\"$module_cmds\"
7099 cmds=$module_cmds
7100 fi
7101 else
7102 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7103 eval test_cmds=\"$archive_expsym_cmds\"
7104 cmds=$archive_expsym_cmds
7105 else
7106 eval test_cmds=\"$archive_cmds\"
7107 cmds=$archive_cmds
7108 fi
7109 fi
7110
7111 if test "X$skipped_export" != "X:" &&
7112 func_len " $test_cmds" &&
7113 len=$func_len_result &&
7114 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7115 :
7116 else
7117 # The command line is too long to link in one step, link piecewise
7118 # or, if using GNU ld and skipped_export is not :, use a linker
7119 # script.
7120
7121 # Save the value of $output and $libobjs because we want to
7122 # use them later. If we have whole_archive_flag_spec, we
7123 # want to use save_libobjs as it was before
7124 # whole_archive_flag_spec was expanded, because we can't
7125 # assume the linker understands whole_archive_flag_spec.
7126 # This may have to be revisited, in case too many
7127 # convenience libraries get linked in and end up exceeding
7128 # the spec.
7129 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7130 save_libobjs=$libobjs
7131 fi
7132 save_output=$output
7133 output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7134
7135 # Clear the reloadable object creation command queue and
7136 # initialize k to one.
7137 test_cmds=
7138 concat_cmds=
7139 objlist=
7140 last_robj=
7141 k=1
7142
7143 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7144 output=${output_objdir}/${output_la}.lnkscript
7145 func_verbose "creating GNU ld script: $output"
7146 $ECHO 'INPUT (' > $output
7147 for obj in $save_libobjs
7148 do
7149 $ECHO "$obj" >> $output
7150 done
7151 $ECHO ')' >> $output
7152 delfiles="$delfiles $output"
7153 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7154 output=${output_objdir}/${output_la}.lnk
7155 func_verbose "creating linker input file list: $output"
7156 : > $output
7157 set x $save_libobjs
7158 shift
7159 firstobj=
7160 if test "$compiler_needs_object" = yes; then
7161 firstobj="$1 "
7162 shift
7163 fi
7164 for obj
7165 do
7166 $ECHO "$obj" >> $output
7167 done
7168 delfiles="$delfiles $output"
7169 output=$firstobj\"$file_list_spec$output\"
7170 else
7171 if test -n "$save_libobjs"; then
7172 func_verbose "creating reloadable object files..."
7173 output=$output_objdir/$output_la-${k}.$objext
7174 eval test_cmds=\"$reload_cmds\"
7175 func_len " $test_cmds"
7176 len0=$func_len_result
7177 len=$len0
7178
7179 # Loop over the list of objects to be linked.
7180 for obj in $save_libobjs
7181 do
7182 func_len " $obj"
7183 func_arith $len + $func_len_result
7184 len=$func_arith_result
7185 if test "X$objlist" = X ||
7186 test "$len" -lt "$max_cmd_len"; then
7187 func_append objlist " $obj"
7188 else
7189 # The command $test_cmds is almost too long, add a
7190 # command to the queue.
7191 if test "$k" -eq 1 ; then
7192 # The first file doesn't have a previous command to add.
7193 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7194 else
7195 # All subsequent reloadable object files will link in
7196 # the last one created.
7197 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7198 fi
7199 last_robj=$output_objdir/$output_la-${k}.$objext
7200 func_arith $k + 1
7201 k=$func_arith_result
7202 output=$output_objdir/$output_la-${k}.$objext
7203 objlist=$obj
7204 func_len " $last_robj"
7205 func_arith $len0 + $func_len_result
7206 len=$func_arith_result
7207 fi
7208 done
7209 # Handle the remaining objects by creating one last
7210 # reloadable object file. All subsequent reloadable object
7211 # files will link in the last one created.
7212 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7213 eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7214 if test -n "$last_robj"; then
7215 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7216 fi
7217 delfiles="$delfiles $output"
7218
7219 else
7220 output=
7221 fi
7222
7223 if ${skipped_export-false}; then
7224 func_verbose "generating symbol list for \`$libname.la'"
7225 export_symbols="$output_objdir/$libname.exp"
7226 $opt_dry_run || $RM $export_symbols
7227 libobjs=$output
7228 # Append the command to create the export file.
7229 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7230 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7231 if test -n "$last_robj"; then
7232 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7233 fi
7234 fi
7235
7236 test -n "$save_libobjs" &&
7237 func_verbose "creating a temporary reloadable object file: $output"
7238
7239 # Loop through the commands generated above and execute them.
7240 save_ifs="$IFS"; IFS='~'
7241 for cmd in $concat_cmds; do
7242 IFS="$save_ifs"
7243 $opt_silent || {
7244 func_quote_for_expand "$cmd"
7245 eval "func_echo $func_quote_for_expand_result"
7246 }
7247 $opt_dry_run || eval "$cmd" || {
7248 lt_exit=$?
7249
7250 # Restore the uninstalled library and exit
7251 if test "$mode" = relink; then
7252 ( cd "$output_objdir" && \
7253 $RM "${realname}T" && \
7254 $MV "${realname}U" "$realname" )
7255 fi
7256
7257 exit $lt_exit
7258 }
7259 done
7260 IFS="$save_ifs"
7261
7262 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7263 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7264 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7265 fi
7266 fi
7267
7268 if ${skipped_export-false}; then
7269 if test -n "$export_symbols" && test -n "$include_expsyms"; then
7270 tmp_export_symbols="$export_symbols"
7271 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7272 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7273 fi
7274
7275 if test -n "$orig_export_symbols"; then
7276 # The given exports_symbols file has to be filtered, so filter it.
7277 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7278 # FIXME: $output_objdir/$libname.filter potentially contains lots of
7279 # 's' commands which not all seds can handle. GNU sed should be fine
7280 # though. Also, the filter scales superlinearly with the number of
7281 # global variables. join(1) would be nice here, but unfortunately
7282 # isn't a blessed tool.
7283 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7284 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7285 export_symbols=$output_objdir/$libname.def
7286 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7287 fi
7288 fi
7289
7290 libobjs=$output
7291 # Restore the value of output.
7292 output=$save_output
7293
7294 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7295 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7296 test "X$libobjs" = "X " && libobjs=
7297 fi
7298 # Expand the library linking commands again to reset the
7299 # value of $libobjs for piecewise linking.
7300
7301 # Do each of the archive commands.
7302 if test "$module" = yes && test -n "$module_cmds" ; then
7303 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7304 cmds=$module_expsym_cmds
7305 else
7306 cmds=$module_cmds
7307 fi
7308 else
7309 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7310 cmds=$archive_expsym_cmds
7311 else
7312 cmds=$archive_cmds
7313 fi
7314 fi
7315 fi
7316
7317 if test -n "$delfiles"; then
7318 # Append the command to remove temporary files to $cmds.
7319 eval cmds=\"\$cmds~\$RM $delfiles\"
7320 fi
7321
7322 # Add any objects from preloaded convenience libraries
7323 if test -n "$dlprefiles"; then
7324 gentop="$output_objdir/${outputname}x"
7325 generated="$generated $gentop"
7326
7327 func_extract_archives $gentop $dlprefiles
7328 libobjs="$libobjs $func_extract_archives_result"
7329 test "X$libobjs" = "X " && libobjs=
7330 fi
7331
7332 save_ifs="$IFS"; IFS='~'
7333 for cmd in $cmds; do
7334 IFS="$save_ifs"
7335 eval cmd=\"$cmd\"
7336 $opt_silent || {
7337 func_quote_for_expand "$cmd"
7338 eval "func_echo $func_quote_for_expand_result"
7339 }
7340 $opt_dry_run || eval "$cmd" || {
7341 lt_exit=$?
7342
7343 # Restore the uninstalled library and exit
7344 if test "$mode" = relink; then
7345 ( cd "$output_objdir" && \
7346 $RM "${realname}T" && \
7347 $MV "${realname}U" "$realname" )
7348 fi
7349
7350 exit $lt_exit
7351 }
7352 done
7353 IFS="$save_ifs"
7354
7355 # Restore the uninstalled library and exit
7356 if test "$mode" = relink; then
7357 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7358
7359 if test -n "$convenience"; then
7360 if test -z "$whole_archive_flag_spec"; then
7361 func_show_eval '${RM}r "$gentop"'
7362 fi
7363 fi
7364
7365 exit $EXIT_SUCCESS
7366 fi
7367
7368 # Create links to the real library.
7369 for linkname in $linknames; do
7370 if test "$realname" != "$linkname"; then
7371 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7372 fi
7373 done
7374
7375 # If -module or -export-dynamic was specified, set the dlname.
7376 if test "$module" = yes || test "$export_dynamic" = yes; then
7377 # On all known operating systems, these are identical.
7378 dlname="$soname"
7379 fi
7380 fi
7381 ;;
7382
7383 obj)
7384 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7385 func_warning "\`-dlopen' is ignored for objects"
7386 fi
7387
7388 case " $deplibs" in
7389 *\ -l* | *\ -L*)
7390 func_warning "\`-l' and \`-L' are ignored for objects" ;;
7391 esac
7392
7393 test -n "$rpath" && \
7394 func_warning "\`-rpath' is ignored for objects"
7395
7396 test -n "$xrpath" && \
7397 func_warning "\`-R' is ignored for objects"
7398
7399 test -n "$vinfo" && \
7400 func_warning "\`-version-info' is ignored for objects"
7401
7402 test -n "$release" && \
7403 func_warning "\`-release' is ignored for objects"
7404
7405 case $output in
7406 *.lo)
7407 test -n "$objs$old_deplibs" && \
7408 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7409
7410 libobj=$output
7411 func_lo2o "$libobj"
7412 obj=$func_lo2o_result
7413 ;;
7414 *)
7415 libobj=
7416 obj="$output"
7417 ;;
7418 esac
7419
7420 # Delete the old objects.
7421 $opt_dry_run || $RM $obj $libobj
7422
7423 # Objects from convenience libraries. This assumes
7424 # single-version convenience libraries. Whenever we create
7425 # different ones for PIC/non-PIC, this we'll have to duplicate
7426 # the extraction.
7427 reload_conv_objs=
7428 gentop=
7429 # reload_cmds runs $LD directly, so let us get rid of
7430 # -Wl from whole_archive_flag_spec and hope we can get by with
7431 # turning comma into space..
7432 wl=
7433
7434 if test -n "$convenience"; then
7435 if test -n "$whole_archive_flag_spec"; then
7436 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7437 reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7438 else
7439 gentop="$output_objdir/${obj}x"
7440 generated="$generated $gentop"
7441
7442 func_extract_archives $gentop $convenience
7443 reload_conv_objs="$reload_objs $func_extract_archives_result"
7444 fi
7445 fi
7446
7447 # Create the old-style object.
7448 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
7449
7450 output="$obj"
7451 func_execute_cmds "$reload_cmds" 'exit $?'
7452
7453 # Exit if we aren't doing a library object file.
7454 if test -z "$libobj"; then
7455 if test -n "$gentop"; then
7456 func_show_eval '${RM}r "$gentop"'
7457 fi
7458
7459 exit $EXIT_SUCCESS
7460 fi
7461
7462 if test "$build_libtool_libs" != yes; then
7463 if test -n "$gentop"; then
7464 func_show_eval '${RM}r "$gentop"'
7465 fi
7466
7467 # Create an invalid libtool object if no PIC, so that we don't
7468 # accidentally link it into a program.
7469 # $show "echo timestamp > $libobj"
7470 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7471 exit $EXIT_SUCCESS
7472 fi
7473
7474 if test -n "$pic_flag" || test "$pic_mode" != default; then
7475 # Only do commands if we really have different PIC objects.
7476 reload_objs="$libobjs $reload_conv_objs"
7477 output="$libobj"
7478 func_execute_cmds "$reload_cmds" 'exit $?'
7479 fi
7480
7481 if test -n "$gentop"; then
7482 func_show_eval '${RM}r "$gentop"'
7483 fi
7484
7485 exit $EXIT_SUCCESS
7486 ;;
7487
7488 prog)
7489 case $host in
7490 *cygwin*) func_stripname '' '.exe' "$output"
7491 output=$func_stripname_result.exe;;
7492 esac
7493 test -n "$vinfo" && \
7494 func_warning "\`-version-info' is ignored for programs"
7495
7496 test -n "$release" && \
7497 func_warning "\`-release' is ignored for programs"
7498
7499 test "$preload" = yes \
7500 && test "$dlopen_support" = unknown \
7501 && test "$dlopen_self" = unknown \
7502 && test "$dlopen_self_static" = unknown && \
7503 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7504
7505 case $host in
7506 *-*-rhapsody* | *-*-darwin1.[012])
7507 # On Rhapsody replace the C library is the System framework
7508 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7509 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7510 ;;
7511 esac
7512
7513 case $host in
7514 *-*-darwin*)
7515 # Don't allow lazy linking, it breaks C++ global constructors
7516 # But is supposedly fixed on 10.4 or later (yay!).
7517 if test "$tagname" = CXX ; then
7518 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7519 10.[0123])
7520 compile_command="$compile_command ${wl}-bind_at_load"
7521 finalize_command="$finalize_command ${wl}-bind_at_load"
7522 ;;
7523 esac
7524 fi
7525 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7526 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7527 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7528 ;;
7529 esac
7530
7531
7532 # move library search paths that coincide with paths to not yet
7533 # installed libraries to the beginning of the library search list
7534 new_libs=
7535 for path in $notinst_path; do
7536 case " $new_libs " in
7537 *" -L$path/$objdir "*) ;;
7538 *)
7539 case " $compile_deplibs " in
7540 *" -L$path/$objdir "*)
7541 new_libs="$new_libs -L$path/$objdir" ;;
7542 esac
7543 ;;
7544 esac
7545 done
7546 for deplib in $compile_deplibs; do
7547 case $deplib in
7548 -L*)
7549 case " $new_libs " in
7550 *" $deplib "*) ;;
7551 *) new_libs="$new_libs $deplib" ;;
7552 esac
7553 ;;
7554 *) new_libs="$new_libs $deplib" ;;
7555 esac
7556 done
7557 compile_deplibs="$new_libs"
7558
7559
7560 compile_command="$compile_command $compile_deplibs"
7561 finalize_command="$finalize_command $finalize_deplibs"
7562
7563 if test -n "$rpath$xrpath"; then
7564 # If the user specified any rpath flags, then add them.
7565 for libdir in $rpath $xrpath; do
7566 # This is the magic to use -rpath.
7567 case "$finalize_rpath " in
7568 *" $libdir "*) ;;
7569 *) finalize_rpath="$finalize_rpath $libdir" ;;
7570 esac
7571 done
7572 fi
7573
7574 # Now hardcode the library paths
7575 rpath=
7576 hardcode_libdirs=
7577 for libdir in $compile_rpath $finalize_rpath; do
7578 if test -n "$hardcode_libdir_flag_spec"; then
7579 if test -n "$hardcode_libdir_separator"; then
7580 if test -z "$hardcode_libdirs"; then
7581 hardcode_libdirs="$libdir"
7582 else
7583 # Just accumulate the unique libdirs.
7584 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7585 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7586 ;;
7587 *)
7588 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7589 ;;
7590 esac
7591 fi
7592 else
7593 eval flag=\"$hardcode_libdir_flag_spec\"
7594 rpath="$rpath $flag"
7595 fi
7596 elif test -n "$runpath_var"; then
7597 case "$perm_rpath " in
7598 *" $libdir "*) ;;
7599 *) perm_rpath="$perm_rpath $libdir" ;;
7600 esac
7601 fi
7602 case $host in
7603 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7604 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7605 case :$dllsearchpath: in
7606 *":$libdir:"*) ;;
7607 ::) dllsearchpath=$libdir;;
7608 *) dllsearchpath="$dllsearchpath:$libdir";;
7609 esac
7610 case :$dllsearchpath: in
7611 *":$testbindir:"*) ;;
7612 ::) dllsearchpath=$testbindir;;
7613 *) dllsearchpath="$dllsearchpath:$testbindir";;
7614 esac
7615 ;;
7616 esac
7617 done
7618 # Substitute the hardcoded libdirs into the rpath.
7619 if test -n "$hardcode_libdir_separator" &&
7620 test -n "$hardcode_libdirs"; then
7621 libdir="$hardcode_libdirs"
7622 eval rpath=\" $hardcode_libdir_flag_spec\"
7623 fi
7624 compile_rpath="$rpath"
7625
7626 rpath=
7627 hardcode_libdirs=
7628 for libdir in $finalize_rpath; do
7629 if test -n "$hardcode_libdir_flag_spec"; then
7630 if test -n "$hardcode_libdir_separator"; then
7631 if test -z "$hardcode_libdirs"; then
7632 hardcode_libdirs="$libdir"
7633 else
7634 # Just accumulate the unique libdirs.
7635 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7636 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7637 ;;
7638 *)
7639 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7640 ;;
7641 esac
7642 fi
7643 else
7644 eval flag=\"$hardcode_libdir_flag_spec\"
7645 rpath="$rpath $flag"
7646 fi
7647 elif test -n "$runpath_var"; then
7648 case "$finalize_perm_rpath " in
7649 *" $libdir "*) ;;
7650 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7651 esac
7652 fi
7653 done
7654 # Substitute the hardcoded libdirs into the rpath.
7655 if test -n "$hardcode_libdir_separator" &&
7656 test -n "$hardcode_libdirs"; then
7657 libdir="$hardcode_libdirs"
7658 eval rpath=\" $hardcode_libdir_flag_spec\"
7659 fi
7660 finalize_rpath="$rpath"
7661
7662 if test -n "$libobjs" && test "$build_old_libs" = yes; then
7663 # Transform all the library objects into standard objects.
7664 compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7665 finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7666 fi
7667
7668 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7669
7670 # template prelinking step
7671 if test -n "$prelink_cmds"; then
7672 func_execute_cmds "$prelink_cmds" 'exit $?'
7673 fi
7674
7675 wrappers_required=yes
7676 case $host in
7677 *cygwin* | *mingw* )
7678 if test "$build_libtool_libs" != yes; then
7679 wrappers_required=no
7680 fi
7681 ;;
7682 *cegcc)
7683 # Disable wrappers for cegcc, we are cross compiling anyway.
7684 wrappers_required=no
7685 ;;
7686 *)
7687 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7688 wrappers_required=no
7689 fi
7690 ;;
7691 esac
7692 if test "$wrappers_required" = no; then
7693 # Replace the output file specification.
7694 compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7695 link_command="$compile_command$compile_rpath"
7696
7697 # We have no uninstalled library dependencies, so finalize right now.
7698 exit_status=0
7699 func_show_eval "$link_command" 'exit_status=$?'
7700
7701 # Delete the generated files.
7702 if test -f "$output_objdir/${outputname}S.${objext}"; then
7703 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7704 fi
7705
7706 exit $exit_status
7707 fi
7708
7709 if test -n "$compile_shlibpath$finalize_shlibpath"; then
7710 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7711 fi
7712 if test -n "$finalize_shlibpath"; then
7713 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7714 fi
7715
7716 compile_var=
7717 finalize_var=
7718 if test -n "$runpath_var"; then
7719 if test -n "$perm_rpath"; then
7720 # We should set the runpath_var.
7721 rpath=
7722 for dir in $perm_rpath; do
7723 rpath="$rpath$dir:"
7724 done
7725 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7726 fi
7727 if test -n "$finalize_perm_rpath"; then
7728 # We should set the runpath_var.
7729 rpath=
7730 for dir in $finalize_perm_rpath; do
7731 rpath="$rpath$dir:"
7732 done
7733 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7734 fi
7735 fi
7736
7737 if test "$no_install" = yes; then
7738 # We don't need to create a wrapper script.
7739 link_command="$compile_var$compile_command$compile_rpath"
7740 # Replace the output file specification.
7741 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7742 # Delete the old output file.
7743 $opt_dry_run || $RM $output
7744 # Link the executable and exit
7745 func_show_eval "$link_command" 'exit $?'
7746 exit $EXIT_SUCCESS
7747 fi
7748
7749 if test "$hardcode_action" = relink; then
7750 # Fast installation is not supported
7751 link_command="$compile_var$compile_command$compile_rpath"
7752 relink_command="$finalize_var$finalize_command$finalize_rpath"
7753
7754 func_warning "this platform does not like uninstalled shared libraries"
7755 func_warning "\`$output' will be relinked during installation"
7756 else
7757 if test "$fast_install" != no; then
7758 link_command="$finalize_var$compile_command$finalize_rpath"
7759 if test "$fast_install" = yes; then
7760 relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7761 else
7762 # fast_install is set to needless
7763 relink_command=
7764 fi
7765 else
7766 link_command="$compile_var$compile_command$compile_rpath"
7767 relink_command="$finalize_var$finalize_command$finalize_rpath"
7768 fi
7769 fi
7770
7771 # Replace the output file specification.
7772 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7773
7774 # Delete the old output files.
7775 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7776
7777 func_show_eval "$link_command" 'exit $?'
7778
7779 # Now create the wrapper script.
7780 func_verbose "creating $output"
7781
7782 # Quote the relink command for shipping.
7783 if test -n "$relink_command"; then
7784 # Preserve any variables that may affect compiler behavior
7785 for var in $variables_saved_for_relink; do
7786 if eval test -z \"\${$var+set}\"; then
7787 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7788 elif eval var_value=\$$var; test -z "$var_value"; then
7789 relink_command="$var=; export $var; $relink_command"
7790 else
7791 func_quote_for_eval "$var_value"
7792 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7793 fi
7794 done
7795 relink_command="(cd `pwd`; $relink_command)"
7796 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7797 fi
7798
7799 # Quote $ECHO for shipping.
7800 if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7801 case $progpath in
7802 [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7803 *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7804 esac
7805 qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7806 else
7807 qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7808 fi
7809
7810 # Only actually do things if not in dry run mode.
7811 $opt_dry_run || {
7812 # win32 will think the script is a binary if it has
7813 # a .exe suffix, so we strip it off here.
7814 case $output in
7815 *.exe) func_stripname '' '.exe' "$output"
7816 output=$func_stripname_result ;;
7817 esac
7818 # test for cygwin because mv fails w/o .exe extensions
7819 case $host in
7820 *cygwin*)
7821 exeext=.exe
7822 func_stripname '' '.exe' "$outputname"
7823 outputname=$func_stripname_result ;;
7824 *) exeext= ;;
7825 esac
7826 case $host in
7827 *cygwin* | *mingw* )
7828 func_dirname_and_basename "$output" "" "."
7829 output_name=$func_basename_result
7830 output_path=$func_dirname_result
7831 cwrappersource="$output_path/$objdir/lt-$output_name.c"
7832 cwrapper="$output_path/$output_name.exe"
7833 $RM $cwrappersource $cwrapper
7834 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7835
7836 func_emit_cwrapperexe_src > $cwrappersource
7837
7838 # The wrapper executable is built using the $host compiler,
7839 # because it contains $host paths and files. If cross-
7840 # compiling, it, like the target executable, must be
7841 # executed on the $host or under an emulation environment.
7842 $opt_dry_run || {
7843 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7844 $STRIP $cwrapper
7845 }
7846
7847 # Now, create the wrapper script for func_source use:
7848 func_ltwrapper_scriptname $cwrapper
7849 $RM $func_ltwrapper_scriptname_result
7850 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7851 $opt_dry_run || {
7852 # note: this script will not be executed, so do not chmod.
7853 if test "x$build" = "x$host" ; then
7854 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7855 else
7856 func_emit_wrapper no > $func_ltwrapper_scriptname_result
7857 fi
7858 }
7859 ;;
7860 * )
7861 $RM $output
7862 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7863
7864 func_emit_wrapper no > $output
7865 chmod +x $output
7866 ;;
7867 esac
7868 }
7869 exit $EXIT_SUCCESS
7870 ;;
7871 esac
7872
7873 # See if we need to build an old-fashioned archive.
7874 for oldlib in $oldlibs; do
7875
7876 if test "$build_libtool_libs" = convenience; then
7877 oldobjs="$libobjs_save $symfileobj"
7878 addlibs="$convenience"
7879 build_libtool_libs=no
7880 else
7881 if test "$build_libtool_libs" = module; then
7882 oldobjs="$libobjs_save"
7883 build_libtool_libs=no
7884 else
7885 oldobjs="$old_deplibs $non_pic_objects"
7886 if test "$preload" = yes && test -f "$symfileobj"; then
7887 oldobjs="$oldobjs $symfileobj"
7888 fi
7889 fi
7890 addlibs="$old_convenience"
7891 fi
7892
7893 if test -n "$addlibs"; then
7894 gentop="$output_objdir/${outputname}x"
7895 generated="$generated $gentop"
7896
7897 func_extract_archives $gentop $addlibs
7898 oldobjs="$oldobjs $func_extract_archives_result"
7899 fi
7900
7901 # Do each command in the archive commands.
7902 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7903 cmds=$old_archive_from_new_cmds
7904 else
7905
7906 # Add any objects from preloaded convenience libraries
7907 if test -n "$dlprefiles"; then
7908 gentop="$output_objdir/${outputname}x"
7909 generated="$generated $gentop"
7910
7911 func_extract_archives $gentop $dlprefiles
7912 oldobjs="$oldobjs $func_extract_archives_result"
7913 fi
7914
7915 # POSIX demands no paths to be encoded in archives. We have
7916 # to avoid creating archives with duplicate basenames if we
7917 # might have to extract them afterwards, e.g., when creating a
7918 # static archive out of a convenience library, or when linking
7919 # the entirety of a libtool archive into another (currently
7920 # not supported by libtool).
7921 if (for obj in $oldobjs
7922 do
7923 func_basename "$obj"
7924 $ECHO "$func_basename_result"
7925 done | sort | sort -uc >/dev/null 2>&1); then
7926 :
7927 else
7928 $ECHO "copying selected object files to avoid basename conflicts..."
7929 gentop="$output_objdir/${outputname}x"
7930 generated="$generated $gentop"
7931 func_mkdir_p "$gentop"
7932 save_oldobjs=$oldobjs
7933 oldobjs=
7934 counter=1
7935 for obj in $save_oldobjs
7936 do
7937 func_basename "$obj"
7938 objbase="$func_basename_result"
7939 case " $oldobjs " in
7940 " ") oldobjs=$obj ;;
7941 *[\ /]"$objbase "*)
7942 while :; do
7943 # Make sure we don't pick an alternate name that also
7944 # overlaps.
7945 newobj=lt$counter-$objbase
7946 func_arith $counter + 1
7947 counter=$func_arith_result
7948 case " $oldobjs " in
7949 *[\ /]"$newobj "*) ;;
7950 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
7951 esac
7952 done
7953 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7954 oldobjs="$oldobjs $gentop/$newobj"
7955 ;;
7956 *) oldobjs="$oldobjs $obj" ;;
7957 esac
7958 done
7959 fi
7960 eval cmds=\"$old_archive_cmds\"
7961
7962 func_len " $cmds"
7963 len=$func_len_result
7964 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7965 cmds=$old_archive_cmds
7966 else
7967 # the command line is too long to link in one step, link in parts
7968 func_verbose "using piecewise archive linking..."
7969 save_RANLIB=$RANLIB
7970 RANLIB=:
7971 objlist=
7972 concat_cmds=
7973 save_oldobjs=$oldobjs
7974 oldobjs=
7975 # Is there a better way of finding the last object in the list?
7976 for obj in $save_oldobjs
7977 do
7978 last_oldobj=$obj
7979 done
7980 eval test_cmds=\"$old_archive_cmds\"
7981 func_len " $test_cmds"
7982 len0=$func_len_result
7983 len=$len0
7984 for obj in $save_oldobjs
7985 do
7986 func_len " $obj"
7987 func_arith $len + $func_len_result
7988 len=$func_arith_result
7989 func_append objlist " $obj"
7990 if test "$len" -lt "$max_cmd_len"; then
7991 :
7992 else
7993 # the above command should be used before it gets too long
7994 oldobjs=$objlist
7995 if test "$obj" = "$last_oldobj" ; then
7996 RANLIB=$save_RANLIB
7997 fi
7998 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7999 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8000 objlist=
8001 len=$len0
8002 fi
8003 done
8004 RANLIB=$save_RANLIB
8005 oldobjs=$objlist
8006 if test "X$oldobjs" = "X" ; then
8007 eval cmds=\"\$concat_cmds\"
8008 else
8009 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8010 fi
8011 fi
8012 fi
8013 func_execute_cmds "$cmds" 'exit $?'
8014 done
8015
8016 test -n "$generated" && \
8017 func_show_eval "${RM}r$generated"
8018
8019 # Now create the libtool archive.
8020 case $output in
8021 *.la)
8022 old_library=
8023 test "$build_old_libs" = yes && old_library="$libname.$libext"
8024 func_verbose "creating $output"
8025
8026 # Preserve any variables that may affect compiler behavior
8027 for var in $variables_saved_for_relink; do
8028 if eval test -z \"\${$var+set}\"; then
8029 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8030 elif eval var_value=\$$var; test -z "$var_value"; then
8031 relink_command="$var=; export $var; $relink_command"
8032 else
8033 func_quote_for_eval "$var_value"
8034 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8035 fi
8036 done
8037 # Quote the link command for shipping.
8038 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8039 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8040 if test "$hardcode_automatic" = yes ; then
8041 relink_command=
8042 fi
8043
8044 # Only create the output if not a dry run.
8045 $opt_dry_run || {
8046 for installed in no yes; do
8047 if test "$installed" = yes; then
8048 if test -z "$install_libdir"; then
8049 break
8050 fi
8051 output="$output_objdir/$outputname"i
8052 # Replace all uninstalled libtool libraries with the installed ones
8053 newdependency_libs=
8054 for deplib in $dependency_libs; do
8055 case $deplib in
8056 *.la)
8057 func_basename "$deplib"
8058 name="$func_basename_result"
8059 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8060 test -z "$libdir" && \
8061 func_fatal_error "\`$deplib' is not a valid libtool archive"
8062 newdependency_libs="$newdependency_libs $libdir/$name"
8063 ;;
8064 *) newdependency_libs="$newdependency_libs $deplib" ;;
8065 esac
8066 done
8067 dependency_libs="$newdependency_libs"
8068 newdlfiles=
8069
8070 for lib in $dlfiles; do
8071 case $lib in
8072 *.la)
8073 func_basename "$lib"
8074 name="$func_basename_result"
8075 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8076 test -z "$libdir" && \
8077 func_fatal_error "\`$lib' is not a valid libtool archive"
8078 newdlfiles="$newdlfiles $libdir/$name"
8079 ;;
8080 *) newdlfiles="$newdlfiles $lib" ;;
8081 esac
8082 done
8083 dlfiles="$newdlfiles"
8084 newdlprefiles=
8085 for lib in $dlprefiles; do
8086 case $lib in
8087 *.la)
8088 # Only pass preopened files to the pseudo-archive (for
8089 # eventual linking with the app. that links it) if we
8090 # didn't already link the preopened objects directly into
8091 # the library:
8092 func_basename "$lib"
8093 name="$func_basename_result"
8094 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8095 test -z "$libdir" && \
8096 func_fatal_error "\`$lib' is not a valid libtool archive"
8097 newdlprefiles="$newdlprefiles $libdir/$name"
8098 ;;
8099 esac
8100 done
8101 dlprefiles="$newdlprefiles"
8102 else
8103 newdlfiles=
8104 for lib in $dlfiles; do
8105 case $lib in
8106 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8107 *) abs=`pwd`"/$lib" ;;
8108 esac
8109 newdlfiles="$newdlfiles $abs"
8110 done
8111 dlfiles="$newdlfiles"
8112 newdlprefiles=
8113 for lib in $dlprefiles; do
8114 case $lib in
8115 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8116 *) abs=`pwd`"/$lib" ;;
8117 esac
8118 newdlprefiles="$newdlprefiles $abs"
8119 done
8120 dlprefiles="$newdlprefiles"
8121 fi
8122 $RM $output
8123 # place dlname in correct position for cygwin
8124 tdlname=$dlname
8125 case $host,$output,$installed,$module,$dlname in
8126 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8127 esac
8128 $ECHO > $output "\
8129 # $outputname - a libtool library file
8130 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8131 #
8132 # Please DO NOT delete this file!
8133 # It is necessary for linking the library.
8134
8135 # The name that we can dlopen(3).
8136 dlname='$tdlname'
8137
8138 # Names of this library.
8139 library_names='$library_names'
8140
8141 # The name of the static archive.
8142 old_library='$old_library'
8143
8144 # Linker flags that can not go in dependency_libs.
8145 inherited_linker_flags='$new_inherited_linker_flags'
8146
8147 # Libraries that this one depends upon.
8148 dependency_libs='$dependency_libs'
8149
8150 # Names of additional weak libraries provided by this library
8151 weak_library_names='$weak_libs'
8152
8153 # Version information for $libname.
8154 current=$current
8155 age=$age
8156 revision=$revision
8157
8158 # Is this an already installed library?
8159 installed=$installed
8160
8161 # Should we warn about portability when linking against -modules?
8162 shouldnotlink=$module
8163
8164 # Files to dlopen/dlpreopen
8165 dlopen='$dlfiles'
8166 dlpreopen='$dlprefiles'
8167
8168 # Directory that this library needs to be installed in:
8169 libdir='$install_libdir'"
8170 if test "$installed" = no && test "$need_relink" = yes; then
8171 $ECHO >> $output "\
8172 relink_command=\"$relink_command\""
8173 fi
8174 done
8175 }
8176
8177 # Do a symbolic link so that the libtool archive can be found in
8178 # LD_LIBRARY_PATH before the program is installed.
8179 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8180 ;;
8181 esac
8182 exit $EXIT_SUCCESS
8183 }
8184
8185 { test "$mode" = link || test "$mode" = relink; } &&
8186 func_mode_link ${1+"$@"}
8187
8188
8189 # func_mode_uninstall arg...
8190 func_mode_uninstall ()
8191 {
8192 $opt_debug
8193 RM="$nonopt"
8194 files=
8195 rmforce=
8196 exit_status=0
8197
8198 # This variable tells wrapper scripts just to set variables rather
8199 # than running their programs.
8200 libtool_install_magic="$magic"
8201
8202 for arg
8203 do
8204 case $arg in
8205 -f) RM="$RM $arg"; rmforce=yes ;;
8206 -*) RM="$RM $arg" ;;
8207 *) files="$files $arg" ;;
8208 esac
8209 done
8210
8211 test -z "$RM" && \
8212 func_fatal_help "you must specify an RM program"
8213
8214 rmdirs=
8215
8216 origobjdir="$objdir"
8217 for file in $files; do
8218 func_dirname "$file" "" "."
8219 dir="$func_dirname_result"
8220 if test "X$dir" = X.; then
8221 objdir="$origobjdir"
8222 else
8223 objdir="$dir/$origobjdir"
8224 fi
8225 func_basename "$file"
8226 name="$func_basename_result"
8227 test "$mode" = uninstall && objdir="$dir"
8228
8229 # Remember objdir for removal later, being careful to avoid duplicates
8230 if test "$mode" = clean; then
8231 case " $rmdirs " in
8232 *" $objdir "*) ;;
8233 *) rmdirs="$rmdirs $objdir" ;;
8234 esac
8235 fi
8236
8237 # Don't error if the file doesn't exist and rm -f was used.
8238 if { test -L "$file"; } >/dev/null 2>&1 ||
8239 { test -h "$file"; } >/dev/null 2>&1 ||
8240 test -f "$file"; then
8241 :
8242 elif test -d "$file"; then
8243 exit_status=1
8244 continue
8245 elif test "$rmforce" = yes; then
8246 continue
8247 fi
8248
8249 rmfiles="$file"
8250
8251 case $name in
8252 *.la)
8253 # Possibly a libtool archive, so verify it.
8254 if func_lalib_p "$file"; then
8255 func_source $dir/$name
8256
8257 # Delete the libtool libraries and symlinks.
8258 for n in $library_names; do
8259 rmfiles="$rmfiles $objdir/$n"
8260 done
8261 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8262
8263 case "$mode" in
8264 clean)
8265 case " $library_names " in
8266 # " " in the beginning catches empty $dlname
8267 *" $dlname "*) ;;
8268 *) rmfiles="$rmfiles $objdir/$dlname" ;;
8269 esac
8270 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8271 ;;
8272 uninstall)
8273 if test -n "$library_names"; then
8274 # Do each command in the postuninstall commands.
8275 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8276 fi
8277
8278 if test -n "$old_library"; then
8279 # Do each command in the old_postuninstall commands.
8280 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8281 fi
8282 # FIXME: should reinstall the best remaining shared library.
8283 ;;
8284 esac
8285 fi
8286 ;;
8287
8288 *.lo)
8289 # Possibly a libtool object, so verify it.
8290 if func_lalib_p "$file"; then
8291
8292 # Read the .lo file
8293 func_source $dir/$name
8294
8295 # Add PIC object to the list of files to remove.
8296 if test -n "$pic_object" &&
8297 test "$pic_object" != none; then
8298 rmfiles="$rmfiles $dir/$pic_object"
8299 fi
8300
8301 # Add non-PIC object to the list of files to remove.
8302 if test -n "$non_pic_object" &&
8303 test "$non_pic_object" != none; then
8304 rmfiles="$rmfiles $dir/$non_pic_object"
8305 fi
8306 fi
8307 ;;
8308
8309 *)
8310 if test "$mode" = clean ; then
8311 noexename=$name
8312 case $file in
8313 *.exe)
8314 func_stripname '' '.exe' "$file"
8315 file=$func_stripname_result
8316 func_stripname '' '.exe' "$name"
8317 noexename=$func_stripname_result
8318 # $file with .exe has already been added to rmfiles,
8319 # add $file without .exe
8320 rmfiles="$rmfiles $file"
8321 ;;
8322 esac
8323 # Do a test to see if this is a libtool program.
8324 if func_ltwrapper_p "$file"; then
8325 if func_ltwrapper_executable_p "$file"; then
8326 func_ltwrapper_scriptname "$file"
8327 relink_command=
8328 func_source $func_ltwrapper_scriptname_result
8329 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8330 else
8331 relink_command=
8332 func_source $dir/$noexename
8333 fi
8334
8335 # note $name still contains .exe if it was in $file originally
8336 # as does the version of $file that was added into $rmfiles
8337 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8338 if test "$fast_install" = yes && test -n "$relink_command"; then
8339 rmfiles="$rmfiles $objdir/lt-$name"
8340 fi
8341 if test "X$noexename" != "X$name" ; then
8342 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8343 fi
8344 fi
8345 fi
8346 ;;
8347 esac
8348 func_show_eval "$RM $rmfiles" 'exit_status=1'
8349 done
8350 objdir="$origobjdir"
8351
8352 # Try to remove the ${objdir}s in the directories where we deleted files
8353 for dir in $rmdirs; do
8354 if test -d "$dir"; then
8355 func_show_eval "rmdir $dir >/dev/null 2>&1"
8356 fi
8357 done
8358
8359 exit $exit_status
8360 }
8361
8362 { test "$mode" = uninstall || test "$mode" = clean; } &&
8363 func_mode_uninstall ${1+"$@"}
8364
8365 test -z "$mode" && {
8366 help="$generic_help"
8367 func_fatal_help "you must specify a MODE"
8368 }
8369
8370 test -z "$exec_cmd" && \
8371 func_fatal_help "invalid operation mode \`$mode'"
8372
8373 if test -n "$exec_cmd"; then
8374 eval exec "$exec_cmd"
8375 exit $EXIT_FAILURE
8376 fi
8377
8378 exit $exit_status
8379
8380
8381 # The TAGs below are defined such that we never get into a situation
8382 # in which we disable both kinds of libraries. Given conflicting
8383 # choices, we go for a static library, that is the most portable,
8384 # since we can't tell whether shared libraries were disabled because
8385 # the user asked for that or because the platform doesn't support
8386 # them. This is particularly important on AIX, because we don't
8387 # support having both static and shared libraries enabled at the same
8388 # time on that platform, so we default to a shared-only configuration.
8389 # If a disable-shared tag is given, we'll fallback to a static-only
8390 # configuration. But we'll never go from static-only to shared-only.
8391
8392 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8393 build_libtool_libs=no
8394 build_old_libs=yes
8395 # ### END LIBTOOL TAG CONFIG: disable-shared
8396
8397 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
8398 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8399 # ### END LIBTOOL TAG CONFIG: disable-static
8400
8401 # Local Variables:
8402 # mode:shell-script
8403 # sh-indentation:2
8404 # End:
8405 # vi:sw=2
8406
+0
-162
build-scripts/mkinstalldirs less more
0 #! /bin/sh
1 # mkinstalldirs --- make directory hierarchy
2
3 scriptversion=2009-04-28.21; # UTC
4
5 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
6 # Created: 1993-05-16
7 # Public domain.
8 #
9 # This file is maintained in Automake, please report
10 # bugs to <bug-automake@gnu.org> or send patches to
11 # <automake-patches@gnu.org>.
12
13 nl='
14 '
15 IFS=" "" $nl"
16 errstatus=0
17 dirmode=
18
19 usage="\
20 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
21
22 Create each directory DIR (with mode MODE, if specified), including all
23 leading file name components.
24
25 Report bugs to <bug-automake@gnu.org>."
26
27 # process command line arguments
28 while test $# -gt 0 ; do
29 case $1 in
30 -h | --help | --h*) # -h for help
31 echo "$usage"
32 exit $?
33 ;;
34 -m) # -m PERM arg
35 shift
36 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
37 dirmode=$1
38 shift
39 ;;
40 --version)
41 echo "$0 $scriptversion"
42 exit $?
43 ;;
44 --) # stop option processing
45 shift
46 break
47 ;;
48 -*) # unknown option
49 echo "$usage" 1>&2
50 exit 1
51 ;;
52 *) # first non-opt arg
53 break
54 ;;
55 esac
56 done
57
58 for file
59 do
60 if test -d "$file"; then
61 shift
62 else
63 break
64 fi
65 done
66
67 case $# in
68 0) exit 0 ;;
69 esac
70
71 # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
72 # mkdir -p a/c at the same time, both will detect that a is missing,
73 # one will create a, then the other will try to create a and die with
74 # a "File exists" error. This is a problem when calling mkinstalldirs
75 # from a parallel make. We use --version in the probe to restrict
76 # ourselves to GNU mkdir, which is thread-safe.
77 case $dirmode in
78 '')
79 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
80 echo "mkdir -p -- $*"
81 exec mkdir -p -- "$@"
82 else
83 # On NextStep and OpenStep, the 'mkdir' command does not
84 # recognize any option. It will interpret all options as
85 # directories to create, and then abort because '.' already
86 # exists.
87 test -d ./-p && rmdir ./-p
88 test -d ./--version && rmdir ./--version
89 fi
90 ;;
91 *)
92 if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
93 test ! -d ./--version; then
94 echo "mkdir -m $dirmode -p -- $*"
95 exec mkdir -m "$dirmode" -p -- "$@"
96 else
97 # Clean up after NextStep and OpenStep mkdir.
98 for d in ./-m ./-p ./--version "./$dirmode";
99 do
100 test -d $d && rmdir $d
101 done
102 fi
103 ;;
104 esac
105
106 for file
107 do
108 case $file in
109 /*) pathcomp=/ ;;
110 *) pathcomp= ;;
111 esac
112 oIFS=$IFS
113 IFS=/
114 set fnord $file
115 shift
116 IFS=$oIFS
117
118 for d
119 do
120 test "x$d" = x && continue
121
122 pathcomp=$pathcomp$d
123 case $pathcomp in
124 -*) pathcomp=./$pathcomp ;;
125 esac
126
127 if test ! -d "$pathcomp"; then
128 echo "mkdir $pathcomp"
129
130 mkdir "$pathcomp" || lasterr=$?
131
132 if test ! -d "$pathcomp"; then
133 errstatus=$lasterr
134 else
135 if test ! -z "$dirmode"; then
136 echo "chmod $dirmode $pathcomp"
137 lasterr=
138 chmod "$dirmode" "$pathcomp" || lasterr=$?
139
140 if test ! -z "$lasterr"; then
141 errstatus=$lasterr
142 fi
143 fi
144 fi
145 fi
146
147 pathcomp=$pathcomp/
148 done
149 done
150
151 exit $errstatus
152
153 # Local Variables:
154 # mode: shell-script
155 # sh-indentation: 2
156 # eval: (add-hook 'write-file-hooks 'time-stamp)
157 # time-stamp-start: "scriptversion="
158 # time-stamp-format: "%:y-%02m-%02d.%02H"
159 # time-stamp-time-zone: "UTC"
160 # time-stamp-end: "; # UTC"
161 # End:
+0
-17164
configure less more
0 #! /bin/sh
1 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69.
3 #
4 #
5 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
6 #
7 #
8 # This configure script is free software; the Free Software Foundation
9 # gives unlimited permission to copy, distribute and modify it.
10 ## -------------------- ##
11 ## M4sh Initialization. ##
12 ## -------------------- ##
13
14 # Be more Bourne compatible
15 DUALCASE=1; export DUALCASE # for MKS sh
16 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
17 emulate sh
18 NULLCMD=:
19 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
20 # is contrary to our usage. Disable this feature.
21 alias -g '${1+"$@"}'='"$@"'
22 setopt NO_GLOB_SUBST
23 else
24 case `(set -o) 2>/dev/null` in #(
25 *posix*) :
26 set -o posix ;; #(
27 *) :
28 ;;
29 esac
30 fi
31
32
33 as_nl='
34 '
35 export as_nl
36 # Printing a long string crashes Solaris 7 /usr/bin/printf.
37 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
38 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
39 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
40 # Prefer a ksh shell builtin over an external printf program on Solaris,
41 # but without wasting forks for bash or zsh.
42 if test -z "$BASH_VERSION$ZSH_VERSION" \
43 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
44 as_echo='print -r --'
45 as_echo_n='print -rn --'
46 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
47 as_echo='printf %s\n'
48 as_echo_n='printf %s'
49 else
50 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
51 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
52 as_echo_n='/usr/ucb/echo -n'
53 else
54 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
55 as_echo_n_body='eval
56 arg=$1;
57 case $arg in #(
58 *"$as_nl"*)
59 expr "X$arg" : "X\\(.*\\)$as_nl";
60 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
61 esac;
62 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
63 '
64 export as_echo_n_body
65 as_echo_n='sh -c $as_echo_n_body as_echo'
66 fi
67 export as_echo_body
68 as_echo='sh -c $as_echo_body as_echo'
69 fi
70
71 # The user is always right.
72 if test "${PATH_SEPARATOR+set}" != set; then
73 PATH_SEPARATOR=:
74 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
75 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
76 PATH_SEPARATOR=';'
77 }
78 fi
79
80
81 # IFS
82 # We need space, tab and new line, in precisely that order. Quoting is
83 # there to prevent editors from complaining about space-tab.
84 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
85 # splitting by setting IFS to empty value.)
86 IFS=" "" $as_nl"
87
88 # Find who we are. Look in the path if we contain no directory separator.
89 as_myself=
90 case $0 in #((
91 *[\\/]* ) as_myself=$0 ;;
92 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
93 for as_dir in $PATH
94 do
95 IFS=$as_save_IFS
96 test -z "$as_dir" && as_dir=.
97 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
98 done
99 IFS=$as_save_IFS
100
101 ;;
102 esac
103 # We did not find ourselves, most probably we were run as `sh COMMAND'
104 # in which case we are not to be found in the path.
105 if test "x$as_myself" = x; then
106 as_myself=$0
107 fi
108 if test ! -f "$as_myself"; then
109 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
110 exit 1
111 fi
112
113 # Unset variables that we do not need and which cause bugs (e.g. in
114 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
115 # suppresses any "Segmentation fault" message there. '((' could
116 # trigger a bug in pdksh 5.2.14.
117 for as_var in BASH_ENV ENV MAIL MAILPATH
118 do eval test x\${$as_var+set} = xset \
119 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
120 done
121 PS1='$ '
122 PS2='> '
123 PS4='+ '
124
125 # NLS nuisances.
126 LC_ALL=C
127 export LC_ALL
128 LANGUAGE=C
129 export LANGUAGE
130
131 # CDPATH.
132 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
133
134 # Use a proper internal environment variable to ensure we don't fall
135 # into an infinite loop, continuously re-executing ourselves.
136 if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
137 _as_can_reexec=no; export _as_can_reexec;
138 # We cannot yet assume a decent shell, so we have to provide a
139 # neutralization value for shells without unset; and this also
140 # works around shells that cannot unset nonexistent variables.
141 # Preserve -v and -x to the replacement shell.
142 BASH_ENV=/dev/null
143 ENV=/dev/null
144 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
145 case $- in # ((((
146 *v*x* | *x*v* ) as_opts=-vx ;;
147 *v* ) as_opts=-v ;;
148 *x* ) as_opts=-x ;;
149 * ) as_opts= ;;
150 esac
151 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
152 # Admittedly, this is quite paranoid, since all the known shells bail
153 # out after a failed `exec'.
154 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
155 as_fn_exit 255
156 fi
157 # We don't want this to propagate to other subprocesses.
158 { _as_can_reexec=; unset _as_can_reexec;}
159 if test "x$CONFIG_SHELL" = x; then
160 as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
161 emulate sh
162 NULLCMD=:
163 # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
164 # is contrary to our usage. Disable this feature.
165 alias -g '\${1+\"\$@\"}'='\"\$@\"'
166 setopt NO_GLOB_SUBST
167 else
168 case \`(set -o) 2>/dev/null\` in #(
169 *posix*) :
170 set -o posix ;; #(
171 *) :
172 ;;
173 esac
174 fi
175 "
176 as_required="as_fn_return () { (exit \$1); }
177 as_fn_success () { as_fn_return 0; }
178 as_fn_failure () { as_fn_return 1; }
179 as_fn_ret_success () { return 0; }
180 as_fn_ret_failure () { return 1; }
181
182 exitcode=0
183 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
184 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
185 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
186 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
187 if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
188
189 else
190 exitcode=1; echo positional parameters were not saved.
191 fi
192 test x\$exitcode = x0 || exit 1
193 test -x / || exit 1"
194 as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
195 as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
196 eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
197 test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
198 test \$(( 1 + 1 )) = 2 || exit 1"
199 if (eval "$as_required") 2>/dev/null; then :
200 as_have_required=yes
201 else
202 as_have_required=no
203 fi
204 if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
205
206 else
207 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
208 as_found=false
209 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
210 do
211 IFS=$as_save_IFS
212 test -z "$as_dir" && as_dir=.
213 as_found=:
214 case $as_dir in #(
215 /*)
216 for as_base in sh bash ksh sh5; do
217 # Try only shells that exist, to save several forks.
218 as_shell=$as_dir/$as_base
219 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
220 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
221 CONFIG_SHELL=$as_shell as_have_required=yes
222 if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
223 break 2
224 fi
225 fi
226 done;;
227 esac
228 as_found=false
229 done
230 $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
231 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
232 CONFIG_SHELL=$SHELL as_have_required=yes
233 fi; }
234 IFS=$as_save_IFS
235
236
237 if test "x$CONFIG_SHELL" != x; then :
238 export CONFIG_SHELL
239 # We cannot yet assume a decent shell, so we have to provide a
240 # neutralization value for shells without unset; and this also
241 # works around shells that cannot unset nonexistent variables.
242 # Preserve -v and -x to the replacement shell.
243 BASH_ENV=/dev/null
244 ENV=/dev/null
245 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
246 case $- in # ((((
247 *v*x* | *x*v* ) as_opts=-vx ;;
248 *v* ) as_opts=-v ;;
249 *x* ) as_opts=-x ;;
250 * ) as_opts= ;;
251 esac
252 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
253 # Admittedly, this is quite paranoid, since all the known shells bail
254 # out after a failed `exec'.
255 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
256 exit 255
257 fi
258
259 if test x$as_have_required = xno; then :
260 $as_echo "$0: This script requires a shell more modern than all"
261 $as_echo "$0: the shells that I found on your system."
262 if test x${ZSH_VERSION+set} = xset ; then
263 $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
264 $as_echo "$0: be upgraded to zsh 4.3.4 or later."
265 else
266 $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
267 $0: including any error possibly output before this
268 $0: message. Then install a modern shell, or manually run
269 $0: the script under such a shell if you do have one."
270 fi
271 exit 1
272 fi
273 fi
274 fi
275 SHELL=${CONFIG_SHELL-/bin/sh}
276 export SHELL
277 # Unset more variables known to interfere with behavior of common tools.
278 CLICOLOR_FORCE= GREP_OPTIONS=
279 unset CLICOLOR_FORCE GREP_OPTIONS
280
281 ## --------------------- ##
282 ## M4sh Shell Functions. ##
283 ## --------------------- ##
284 # as_fn_unset VAR
285 # ---------------
286 # Portably unset VAR.
287 as_fn_unset ()
288 {
289 { eval $1=; unset $1;}
290 }
291 as_unset=as_fn_unset
292
293 # as_fn_set_status STATUS
294 # -----------------------
295 # Set $? to STATUS, without forking.
296 as_fn_set_status ()
297 {
298 return $1
299 } # as_fn_set_status
300
301 # as_fn_exit STATUS
302 # -----------------
303 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
304 as_fn_exit ()
305 {
306 set +e
307 as_fn_set_status $1
308 exit $1
309 } # as_fn_exit
310
311 # as_fn_mkdir_p
312 # -------------
313 # Create "$as_dir" as a directory, including parents if necessary.
314 as_fn_mkdir_p ()
315 {
316
317 case $as_dir in #(
318 -*) as_dir=./$as_dir;;
319 esac
320 test -d "$as_dir" || eval $as_mkdir_p || {
321 as_dirs=
322 while :; do
323 case $as_dir in #(
324 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
325 *) as_qdir=$as_dir;;
326 esac
327 as_dirs="'$as_qdir' $as_dirs"
328 as_dir=`$as_dirname -- "$as_dir" ||
329 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
330 X"$as_dir" : 'X\(//\)[^/]' \| \
331 X"$as_dir" : 'X\(//\)$' \| \
332 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
333 $as_echo X"$as_dir" |
334 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
335 s//\1/
336 q
337 }
338 /^X\(\/\/\)[^/].*/{
339 s//\1/
340 q
341 }
342 /^X\(\/\/\)$/{
343 s//\1/
344 q
345 }
346 /^X\(\/\).*/{
347 s//\1/
348 q
349 }
350 s/.*/./; q'`
351 test -d "$as_dir" && break
352 done
353 test -z "$as_dirs" || eval "mkdir $as_dirs"
354 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
355
356
357 } # as_fn_mkdir_p
358
359 # as_fn_executable_p FILE
360 # -----------------------
361 # Test if FILE is an executable regular file.
362 as_fn_executable_p ()
363 {
364 test -f "$1" && test -x "$1"
365 } # as_fn_executable_p
366 # as_fn_append VAR VALUE
367 # ----------------------
368 # Append the text in VALUE to the end of the definition contained in VAR. Take
369 # advantage of any shell optimizations that allow amortized linear growth over
370 # repeated appends, instead of the typical quadratic growth present in naive
371 # implementations.
372 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
373 eval 'as_fn_append ()
374 {
375 eval $1+=\$2
376 }'
377 else
378 as_fn_append ()
379 {
380 eval $1=\$$1\$2
381 }
382 fi # as_fn_append
383
384 # as_fn_arith ARG...
385 # ------------------
386 # Perform arithmetic evaluation on the ARGs, and store the result in the
387 # global $as_val. Take advantage of shells that can avoid forks. The arguments
388 # must be portable across $(()) and expr.
389 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
390 eval 'as_fn_arith ()
391 {
392 as_val=$(( $* ))
393 }'
394 else
395 as_fn_arith ()
396 {
397 as_val=`expr "$@" || test $? -eq 1`
398 }
399 fi # as_fn_arith
400
401
402 # as_fn_error STATUS ERROR [LINENO LOG_FD]
403 # ----------------------------------------
404 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
405 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
406 # script with STATUS, using 1 if that was 0.
407 as_fn_error ()
408 {
409 as_status=$1; test $as_status -eq 0 && as_status=1
410 if test "$4"; then
411 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
412 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
413 fi
414 $as_echo "$as_me: error: $2" >&2
415 as_fn_exit $as_status
416 } # as_fn_error
417
418 if expr a : '\(a\)' >/dev/null 2>&1 &&
419 test "X`expr 00001 : '.*\(...\)'`" = X001; then
420 as_expr=expr
421 else
422 as_expr=false
423 fi
424
425 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
426 as_basename=basename
427 else
428 as_basename=false
429 fi
430
431 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
432 as_dirname=dirname
433 else
434 as_dirname=false
435 fi
436
437 as_me=`$as_basename -- "$0" ||
438 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
439 X"$0" : 'X\(//\)$' \| \
440 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
441 $as_echo X/"$0" |
442 sed '/^.*\/\([^/][^/]*\)\/*$/{
443 s//\1/
444 q
445 }
446 /^X\/\(\/\/\)$/{
447 s//\1/
448 q
449 }
450 /^X\/\(\/\).*/{
451 s//\1/
452 q
453 }
454 s/.*/./; q'`
455
456 # Avoid depending upon Character Ranges.
457 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
458 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
459 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
460 as_cr_digits='0123456789'
461 as_cr_alnum=$as_cr_Letters$as_cr_digits
462
463
464 as_lineno_1=$LINENO as_lineno_1a=$LINENO
465 as_lineno_2=$LINENO as_lineno_2a=$LINENO
466 eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
467 test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
468 # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
469 sed -n '
470 p
471 /[$]LINENO/=
472 ' <$as_myself |
473 sed '
474 s/[$]LINENO.*/&-/
475 t lineno
476 b
477 :lineno
478 N
479 :loop
480 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
481 t loop
482 s/-\n.*//
483 ' >$as_me.lineno &&
484 chmod +x "$as_me.lineno" ||
485 { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
486
487 # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
488 # already done that, so ensure we don't try to do so again and fall
489 # in an infinite loop. This has already happened in practice.
490 _as_can_reexec=no; export _as_can_reexec
491 # Don't try to exec as it changes $[0], causing all sort of problems
492 # (the dirname of $[0] is not the place where we might find the
493 # original and so on. Autoconf is especially sensitive to this).
494 . "./$as_me.lineno"
495 # Exit status is that of the last command.
496 exit
497 }
498
499 ECHO_C= ECHO_N= ECHO_T=
500 case `echo -n x` in #(((((
501 -n*)
502 case `echo 'xy\c'` in
503 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
504 xy) ECHO_C='\c';;
505 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
506 ECHO_T=' ';;
507 esac;;
508 *)
509 ECHO_N='-n';;
510 esac
511
512 rm -f conf$$ conf$$.exe conf$$.file
513 if test -d conf$$.dir; then
514 rm -f conf$$.dir/conf$$.file
515 else
516 rm -f conf$$.dir
517 mkdir conf$$.dir 2>/dev/null
518 fi
519 if (echo >conf$$.file) 2>/dev/null; then
520 if ln -s conf$$.file conf$$ 2>/dev/null; then
521 as_ln_s='ln -s'
522 # ... but there are two gotchas:
523 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
524 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
525 # In both cases, we have to default to `cp -pR'.
526 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
527 as_ln_s='cp -pR'
528 elif ln conf$$.file conf$$ 2>/dev/null; then
529 as_ln_s=ln
530 else
531 as_ln_s='cp -pR'
532 fi
533 else
534 as_ln_s='cp -pR'
535 fi
536 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
537 rmdir conf$$.dir 2>/dev/null
538
539 if mkdir -p . 2>/dev/null; then
540 as_mkdir_p='mkdir -p "$as_dir"'
541 else
542 test -d ./-p && rmdir ./-p
543 as_mkdir_p=false
544 fi
545
546 as_test_x='test -x'
547 as_executable_p=as_fn_executable_p
548
549 # Sed expression to map a string onto a valid CPP name.
550 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
551
552 # Sed expression to map a string onto a valid variable name.
553 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
554
555
556
557 # Check that we are running under the correct shell.
558 SHELL=${CONFIG_SHELL-/bin/sh}
559
560 case X$lt_ECHO in
561 X*--fallback-echo)
562 # Remove one level of quotation (which was required for Make).
563 ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
564 ;;
565 esac
566
567 ECHO=${lt_ECHO-echo}
568 if test "X$1" = X--no-reexec; then
569 # Discard the --no-reexec flag, and continue.
570 shift
571 elif test "X$1" = X--fallback-echo; then
572 # Avoid inline document here, it may be left over
573 :
574 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
575 # Yippee, $ECHO works!
576 :
577 else
578 # Restart under the correct shell.
579 exec $SHELL "$0" --no-reexec ${1+"$@"}
580 fi
581
582 if test "X$1" = X--fallback-echo; then
583 # used as fallback echo
584 shift
585 cat <<_LT_EOF
586 $*
587 _LT_EOF
588 exit 0
589 fi
590
591 # The HP-UX ksh and POSIX shell print the target directory to stdout
592 # if CDPATH is set.
593 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
594
595 if test -z "$lt_ECHO"; then
596 if test "X${echo_test_string+set}" != Xset; then
597 # find a string as large as possible, as long as the shell can cope with it
598 for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
599 # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
600 if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
601 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
602 then
603 break
604 fi
605 done
606 fi
607
608 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
609 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
610 test "X$echo_testing_string" = "X$echo_test_string"; then
611 :
612 else
613 # The Solaris, AIX, and Digital Unix default echo programs unquote
614 # backslashes. This makes it impossible to quote backslashes using
615 # echo "$something" | sed 's/\\/\\\\/g'
616 #
617 # So, first we look for a working echo in the user's PATH.
618
619 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
620 for dir in $PATH /usr/ucb; do
621 IFS="$lt_save_ifs"
622 if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
623 test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
624 echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
625 test "X$echo_testing_string" = "X$echo_test_string"; then
626 ECHO="$dir/echo"
627 break
628 fi
629 done
630 IFS="$lt_save_ifs"
631
632 if test "X$ECHO" = Xecho; then
633 # We didn't find a better echo, so look for alternatives.
634 if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
635 echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
636 test "X$echo_testing_string" = "X$echo_test_string"; then
637 # This shell has a builtin print -r that does the trick.
638 ECHO='print -r'
639 elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
640 test "X$CONFIG_SHELL" != X/bin/ksh; then
641 # If we have ksh, try running configure again with it.
642 ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
643 export ORIGINAL_CONFIG_SHELL
644 CONFIG_SHELL=/bin/ksh
645 export CONFIG_SHELL
646 exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
647 else
648 # Try using printf.
649 ECHO='printf %s\n'
650 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
651 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
652 test "X$echo_testing_string" = "X$echo_test_string"; then
653 # Cool, printf works
654 :
655 elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
656 test "X$echo_testing_string" = 'X\t' &&
657 echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
658 test "X$echo_testing_string" = "X$echo_test_string"; then
659 CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
660 export CONFIG_SHELL
661 SHELL="$CONFIG_SHELL"
662 export SHELL
663 ECHO="$CONFIG_SHELL $0 --fallback-echo"
664 elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
665 test "X$echo_testing_string" = 'X\t' &&
666 echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
667 test "X$echo_testing_string" = "X$echo_test_string"; then
668 ECHO="$CONFIG_SHELL $0 --fallback-echo"
669 else
670 # maybe with a smaller string...
671 prev=:
672
673 for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
674 if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
675 then
676 break
677 fi
678 prev="$cmd"
679 done
680
681 if test "$prev" != 'sed 50q "$0"'; then
682 echo_test_string=`eval $prev`
683 export echo_test_string
684 exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
685 else
686 # Oops. We lost completely, so just stick with echo.
687 ECHO=echo
688 fi
689 fi
690 fi
691 fi
692 fi
693 fi
694
695 # Copy echo and quote the copy suitably for passing to libtool from
696 # the Makefile, instead of quoting the original, which is used later.
697 lt_ECHO=$ECHO
698 if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
699 lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
700 fi
701
702
703
704
705 test -n "$DJDIR" || exec 7<&0 </dev/null
706 exec 6>&1
707
708 # Name of the host.
709 # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
710 # so uname gets run too.
711 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
712
713 #
714 # Initializations.
715 #
716 ac_default_prefix=/usr/local
717 ac_clean_files=
718 ac_config_libobj_dir=.
719 LIBOBJS=
720 cross_compiling=no
721 subdirs=
722 MFLAGS=
723 MAKEFLAGS=
724
725 # Identity of this package.
726 PACKAGE_NAME=
727 PACKAGE_TARNAME=
728 PACKAGE_VERSION=
729 PACKAGE_STRING=
730 PACKAGE_BUGREPORT=
731 PACKAGE_URL=
732
733 ac_unique_file="README.txt"
734 # Factoring default headers for most tests.
735 ac_includes_default="\
736 #include <stdio.h>
737 #ifdef HAVE_SYS_TYPES_H
738 # include <sys/types.h>
739 #endif
740 #ifdef HAVE_SYS_STAT_H
741 # include <sys/stat.h>
742 #endif
743 #ifdef STDC_HEADERS
744 # include <stdlib.h>
745 # include <stddef.h>
746 #else
747 # ifdef HAVE_STDLIB_H
748 # include <stdlib.h>
749 # endif
750 #endif
751 #ifdef HAVE_STRING_H
752 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
753 # include <memory.h>
754 # endif
755 # include <string.h>
756 #endif
757 #ifdef HAVE_STRINGS_H
758 # include <strings.h>
759 #endif
760 #ifdef HAVE_INTTYPES_H
761 # include <inttypes.h>
762 #endif
763 #ifdef HAVE_STDINT_H
764 # include <stdint.h>
765 #endif
766 #ifdef HAVE_UNISTD_H
767 # include <unistd.h>
768 #endif"
769
770 ac_subst_vars='LTLIBOBJS
771 LIBOBJS
772 SDL_VERSION
773 EXE
774 EXTRA_LDFLAGS
775 BUILD_LDFLAGS
776 EXTRA_CFLAGS
777 BUILD_CFLAGS
778 PLAYMUS_OBJECTS
779 PLAYWAVE_OBJECTS
780 VERSION_OBJECTS
781 OBJECTS
782 ac_aux_dir
783 OPUSFILE_LIBS
784 OPUSFILE_CFLAGS
785 LIBMIKMOD_CONFIG
786 MODPLUG_LIBS
787 MODPLUG_CFLAGS
788 SDL2_CONFIG
789 SDL_LIBS
790 SDL_CFLAGS
791 PKG_CONFIG
792 WINDRES
793 SET_MAKE
794 INSTALL_DATA
795 INSTALL_SCRIPT
796 INSTALL_PROGRAM
797 LT_AGE
798 LT_REVISION
799 LT_CURRENT
800 LT_RELEASE
801 CPP
802 OTOOL64
803 OTOOL
804 LIPO
805 NMEDIT
806 DSYMUTIL
807 lt_ECHO
808 RANLIB
809 STRIP
810 AR
811 LN_S
812 NM
813 ac_ct_DUMPBIN
814 DUMPBIN
815 LD
816 FGREP
817 EGREP
818 GREP
819 SED
820 OBJEXT
821 EXEEXT
822 ac_ct_CC
823 CPPFLAGS
824 LDFLAGS
825 CFLAGS
826 CC
827 host_os
828 host_vendor
829 host_cpu
830 host
831 build_os
832 build_vendor
833 build_cpu
834 build
835 LIBTOOL
836 OBJDUMP
837 DLLTOOL
838 AS
839 VERSION
840 BINARY_AGE
841 INTERFACE_AGE
842 MICRO_VERSION
843 MINOR_VERSION
844 MAJOR_VERSION
845 target_alias
846 host_alias
847 build_alias
848 LIBS
849 ECHO_T
850 ECHO_N
851 ECHO_C
852 DEFS
853 mandir
854 localedir
855 libdir
856 psdir
857 pdfdir
858 dvidir
859 htmldir
860 infodir
861 docdir
862 oldincludedir
863 includedir
864 localstatedir
865 sharedstatedir
866 sysconfdir
867 datadir
868 datarootdir
869 libexecdir
870 sbindir
871 bindir
872 program_transform_name
873 prefix
874 exec_prefix
875 PACKAGE_URL
876 PACKAGE_BUGREPORT
877 PACKAGE_STRING
878 PACKAGE_VERSION
879 PACKAGE_TARNAME
880 PACKAGE_NAME
881 PATH_SEPARATOR
882 SHELL'
883 ac_subst_files=''
884 ac_user_opts='
885 enable_option_checking
886 enable_shared
887 enable_static
888 with_pic
889 enable_fast_install
890 with_gnu_ld
891 enable_libtool_lock
892 enable_dependency_tracking
893 with_sdl_prefix
894 with_sdl_exec_prefix
895 enable_sdltest
896 enable_music_cmd
897 enable_music_wave
898 enable_music_mod
899 enable_music_mod_modplug
900 enable_music_mod_modplug_shared
901 enable_music_mod_mikmod
902 enable_music_mod_mikmod_shared
903 enable_music_midi
904 enable_music_midi_timidity
905 enable_music_midi_native
906 enable_music_midi_fluidsynth
907 enable_music_midi_fluidsynth_shared
908 enable_music_ogg
909 enable_music_ogg_tremor
910 enable_music_ogg_shared
911 enable_music_flac
912 enable_music_flac_shared
913 enable_music_mp3
914 enable_music_mp3_mad_gpl
915 enable_music_mp3_mad_gpl_dithering
916 enable_music_mp3_mpg123
917 enable_music_mp3_mpg123_shared
918 enable_music_opus
919 enable_music_opus_shared
920 '
921 ac_precious_vars='build_alias
922 host_alias
923 target_alias
924 CC
925 CFLAGS
926 LDFLAGS
927 LIBS
928 CPPFLAGS
929 CPP
930 PKG_CONFIG
931 SDL_CFLAGS
932 SDL_LIBS
933 MODPLUG_CFLAGS
934 MODPLUG_LIBS
935 OPUSFILE_CFLAGS
936 OPUSFILE_LIBS'
937
938
939 # Initialize some variables set by options.
940 ac_init_help=
941 ac_init_version=false
942 ac_unrecognized_opts=
943 ac_unrecognized_sep=
944 # The variables have the same names as the options, with
945 # dashes changed to underlines.
946 cache_file=/dev/null
947 exec_prefix=NONE
948 no_create=
949 no_recursion=
950 prefix=NONE
951 program_prefix=NONE
952 program_suffix=NONE
953 program_transform_name=s,x,x,
954 silent=
955 site=
956 srcdir=
957 verbose=
958 x_includes=NONE
959 x_libraries=NONE
960
961 # Installation directory options.
962 # These are left unexpanded so users can "make install exec_prefix=/foo"
963 # and all the variables that are supposed to be based on exec_prefix
964 # by default will actually change.
965 # Use braces instead of parens because sh, perl, etc. also accept them.
966 # (The list follows the same order as the GNU Coding Standards.)
967 bindir='${exec_prefix}/bin'
968 sbindir='${exec_prefix}/sbin'
969 libexecdir='${exec_prefix}/libexec'
970 datarootdir='${prefix}/share'
971 datadir='${datarootdir}'
972 sysconfdir='${prefix}/etc'
973 sharedstatedir='${prefix}/com'
974 localstatedir='${prefix}/var'
975 includedir='${prefix}/include'
976 oldincludedir='/usr/include'
977 docdir='${datarootdir}/doc/${PACKAGE}'
978 infodir='${datarootdir}/info'
979 htmldir='${docdir}'
980 dvidir='${docdir}'
981 pdfdir='${docdir}'
982 psdir='${docdir}'
983 libdir='${exec_prefix}/lib'
984 localedir='${datarootdir}/locale'
985 mandir='${datarootdir}/man'
986
987 ac_prev=
988 ac_dashdash=
989 for ac_option
990 do
991 # If the previous option needs an argument, assign it.
992 if test -n "$ac_prev"; then
993 eval $ac_prev=\$ac_option
994 ac_prev=
995 continue
996 fi
997
998 case $ac_option in
999 *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
1000 *=) ac_optarg= ;;
1001 *) ac_optarg=yes ;;
1002 esac
1003
1004 # Accept the important Cygnus configure options, so we can diagnose typos.
1005
1006 case $ac_dashdash$ac_option in
1007 --)
1008 ac_dashdash=yes ;;
1009
1010 -bindir | --bindir | --bindi | --bind | --bin | --bi)
1011 ac_prev=bindir ;;
1012 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
1013 bindir=$ac_optarg ;;
1014
1015 -build | --build | --buil | --bui | --bu)
1016 ac_prev=build_alias ;;
1017 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
1018 build_alias=$ac_optarg ;;
1019
1020 -cache-file | --cache-file | --cache-fil | --cache-fi \
1021 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
1022 ac_prev=cache_file ;;
1023 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
1024 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
1025 cache_file=$ac_optarg ;;
1026
1027 --config-cache | -C)
1028 cache_file=config.cache ;;
1029
1030 -datadir | --datadir | --datadi | --datad)
1031 ac_prev=datadir ;;
1032 -datadir=* | --datadir=* | --datadi=* | --datad=*)
1033 datadir=$ac_optarg ;;
1034
1035 -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
1036 | --dataroo | --dataro | --datar)
1037 ac_prev=datarootdir ;;
1038 -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
1039 | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
1040 datarootdir=$ac_optarg ;;
1041
1042 -disable-* | --disable-*)
1043 ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
1044 # Reject names that are not valid shell variable names.
1045 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1046 as_fn_error $? "invalid feature name: $ac_useropt"
1047 ac_useropt_orig=$ac_useropt
1048 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1049 case $ac_user_opts in
1050 *"
1051 "enable_$ac_useropt"
1052 "*) ;;
1053 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
1054 ac_unrecognized_sep=', ';;
1055 esac
1056 eval enable_$ac_useropt=no ;;
1057
1058 -docdir | --docdir | --docdi | --doc | --do)
1059 ac_prev=docdir ;;
1060 -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
1061 docdir=$ac_optarg ;;
1062
1063 -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
1064 ac_prev=dvidir ;;
1065 -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
1066 dvidir=$ac_optarg ;;
1067
1068 -enable-* | --enable-*)
1069 ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
1070 # Reject names that are not valid shell variable names.
1071 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1072 as_fn_error $? "invalid feature name: $ac_useropt"
1073 ac_useropt_orig=$ac_useropt
1074 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1075 case $ac_user_opts in
1076 *"
1077 "enable_$ac_useropt"
1078 "*) ;;
1079 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
1080 ac_unrecognized_sep=', ';;
1081 esac
1082 eval enable_$ac_useropt=\$ac_optarg ;;
1083
1084 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
1085 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
1086 | --exec | --exe | --ex)
1087 ac_prev=exec_prefix ;;
1088 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
1089 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
1090 | --exec=* | --exe=* | --ex=*)
1091 exec_prefix=$ac_optarg ;;
1092
1093 -gas | --gas | --ga | --g)
1094 # Obsolete; use --with-gas.
1095 with_gas=yes ;;
1096
1097 -help | --help | --hel | --he | -h)
1098 ac_init_help=long ;;
1099 -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
1100 ac_init_help=recursive ;;
1101 -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
1102 ac_init_help=short ;;
1103
1104 -host | --host | --hos | --ho)
1105 ac_prev=host_alias ;;
1106 -host=* | --host=* | --hos=* | --ho=*)
1107 host_alias=$ac_optarg ;;
1108
1109 -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
1110 ac_prev=htmldir ;;
1111 -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
1112 | --ht=*)
1113 htmldir=$ac_optarg ;;
1114
1115 -includedir | --includedir | --includedi | --included | --include \
1116 | --includ | --inclu | --incl | --inc)
1117 ac_prev=includedir ;;
1118 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
1119 | --includ=* | --inclu=* | --incl=* | --inc=*)
1120 includedir=$ac_optarg ;;
1121
1122 -infodir | --infodir | --infodi | --infod | --info | --inf)
1123 ac_prev=infodir ;;
1124 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
1125 infodir=$ac_optarg ;;
1126
1127 -libdir | --libdir | --libdi | --libd)
1128 ac_prev=libdir ;;
1129 -libdir=* | --libdir=* | --libdi=* | --libd=*)
1130 libdir=$ac_optarg ;;
1131
1132 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
1133 | --libexe | --libex | --libe)
1134 ac_prev=libexecdir ;;
1135 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
1136 | --libexe=* | --libex=* | --libe=*)
1137 libexecdir=$ac_optarg ;;
1138
1139 -localedir | --localedir | --localedi | --localed | --locale)
1140 ac_prev=localedir ;;
1141 -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
1142 localedir=$ac_optarg ;;
1143
1144 -localstatedir | --localstatedir | --localstatedi | --localstated \
1145 | --localstate | --localstat | --localsta | --localst | --locals)
1146 ac_prev=localstatedir ;;
1147 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
1148 | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
1149 localstatedir=$ac_optarg ;;
1150
1151 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
1152 ac_prev=mandir ;;
1153 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
1154 mandir=$ac_optarg ;;
1155
1156 -nfp | --nfp | --nf)
1157 # Obsolete; use --without-fp.
1158 with_fp=no ;;
1159
1160 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
1161 | --no-cr | --no-c | -n)
1162 no_create=yes ;;
1163
1164 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
1165 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
1166 no_recursion=yes ;;
1167
1168 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
1169 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
1170 | --oldin | --oldi | --old | --ol | --o)
1171 ac_prev=oldincludedir ;;
1172 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
1173 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
1174 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
1175 oldincludedir=$ac_optarg ;;
1176
1177 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
1178 ac_prev=prefix ;;
1179 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
1180 prefix=$ac_optarg ;;
1181
1182 -program-prefix | --program-prefix | --program-prefi | --program-pref \
1183 | --program-pre | --program-pr | --program-p)
1184 ac_prev=program_prefix ;;
1185 -program-prefix=* | --program-prefix=* | --program-prefi=* \
1186 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
1187 program_prefix=$ac_optarg ;;
1188
1189 -program-suffix | --program-suffix | --program-suffi | --program-suff \
1190 | --program-suf | --program-su | --program-s)
1191 ac_prev=program_suffix ;;
1192 -program-suffix=* | --program-suffix=* | --program-suffi=* \
1193 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
1194 program_suffix=$ac_optarg ;;
1195
1196 -program-transform-name | --program-transform-name \
1197 | --program-transform-nam | --program-transform-na \
1198 | --program-transform-n | --program-transform- \
1199 | --program-transform | --program-transfor \
1200 | --program-transfo | --program-transf \
1201 | --program-trans | --program-tran \
1202 | --progr-tra | --program-tr | --program-t)
1203 ac_prev=program_transform_name ;;
1204 -program-transform-name=* | --program-transform-name=* \
1205 | --program-transform-nam=* | --program-transform-na=* \
1206 | --program-transform-n=* | --program-transform-=* \
1207 | --program-transform=* | --program-transfor=* \
1208 | --program-transfo=* | --program-transf=* \
1209 | --program-trans=* | --program-tran=* \
1210 | --progr-tra=* | --program-tr=* | --program-t=*)
1211 program_transform_name=$ac_optarg ;;
1212
1213 -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
1214 ac_prev=pdfdir ;;
1215 -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
1216 pdfdir=$ac_optarg ;;
1217
1218 -psdir | --psdir | --psdi | --psd | --ps)
1219 ac_prev=psdir ;;
1220 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
1221 psdir=$ac_optarg ;;
1222
1223 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1224 | -silent | --silent | --silen | --sile | --sil)
1225 silent=yes ;;
1226
1227 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
1228 ac_prev=sbindir ;;
1229 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
1230 | --sbi=* | --sb=*)
1231 sbindir=$ac_optarg ;;
1232
1233 -sharedstatedir | --sharedstatedir | --sharedstatedi \
1234 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
1235 | --sharedst | --shareds | --shared | --share | --shar \
1236 | --sha | --sh)
1237 ac_prev=sharedstatedir ;;
1238 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
1239 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
1240 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
1241 | --sha=* | --sh=*)
1242 sharedstatedir=$ac_optarg ;;
1243
1244 -site | --site | --sit)
1245 ac_prev=site ;;
1246 -site=* | --site=* | --sit=*)
1247 site=$ac_optarg ;;
1248
1249 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
1250 ac_prev=srcdir ;;
1251 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
1252 srcdir=$ac_optarg ;;
1253
1254 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
1255 | --syscon | --sysco | --sysc | --sys | --sy)
1256 ac_prev=sysconfdir ;;
1257 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
1258 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
1259 sysconfdir=$ac_optarg ;;
1260
1261 -target | --target | --targe | --targ | --tar | --ta | --t)
1262 ac_prev=target_alias ;;
1263 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
1264 target_alias=$ac_optarg ;;
1265
1266 -v | -verbose | --verbose | --verbos | --verbo | --verb)
1267 verbose=yes ;;
1268
1269 -version | --version | --versio | --versi | --vers | -V)
1270 ac_init_version=: ;;
1271
1272 -with-* | --with-*)
1273 ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
1274 # Reject names that are not valid shell variable names.
1275 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1276 as_fn_error $? "invalid package name: $ac_useropt"
1277 ac_useropt_orig=$ac_useropt
1278 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1279 case $ac_user_opts in
1280 *"
1281 "with_$ac_useropt"
1282 "*) ;;
1283 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
1284 ac_unrecognized_sep=', ';;
1285 esac
1286 eval with_$ac_useropt=\$ac_optarg ;;
1287
1288 -without-* | --without-*)
1289 ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
1290 # Reject names that are not valid shell variable names.
1291 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1292 as_fn_error $? "invalid package name: $ac_useropt"
1293 ac_useropt_orig=$ac_useropt
1294 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1295 case $ac_user_opts in
1296 *"
1297 "with_$ac_useropt"
1298 "*) ;;
1299 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
1300 ac_unrecognized_sep=', ';;
1301 esac
1302 eval with_$ac_useropt=no ;;
1303
1304 --x)
1305 # Obsolete; use --with-x.
1306 with_x=yes ;;
1307
1308 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
1309 | --x-incl | --x-inc | --x-in | --x-i)
1310 ac_prev=x_includes ;;
1311 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
1312 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
1313 x_includes=$ac_optarg ;;
1314
1315 -x-libraries | --x-libraries | --x-librarie | --x-librari \
1316 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
1317 ac_prev=x_libraries ;;
1318 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
1319 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
1320 x_libraries=$ac_optarg ;;
1321
1322 -*) as_fn_error $? "unrecognized option: \`$ac_option'
1323 Try \`$0 --help' for more information"
1324 ;;
1325
1326 *=*)
1327 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
1328 # Reject names that are not valid shell variable names.
1329 case $ac_envvar in #(
1330 '' | [0-9]* | *[!_$as_cr_alnum]* )
1331 as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
1332 esac
1333 eval $ac_envvar=\$ac_optarg
1334 export $ac_envvar ;;
1335
1336 *)
1337 # FIXME: should be removed in autoconf 3.0.
1338 $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
1339 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1340 $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
1341 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
1342 ;;
1343
1344 esac
1345 done
1346
1347 if test -n "$ac_prev"; then
1348 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
1349 as_fn_error $? "missing argument to $ac_option"
1350 fi
1351
1352 if test -n "$ac_unrecognized_opts"; then
1353 case $enable_option_checking in
1354 no) ;;
1355 fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
1356 *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
1357 esac
1358 fi
1359
1360 # Check all directory arguments for consistency.
1361 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
1362 datadir sysconfdir sharedstatedir localstatedir includedir \
1363 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1364 libdir localedir mandir
1365 do
1366 eval ac_val=\$$ac_var
1367 # Remove trailing slashes.
1368 case $ac_val in
1369 */ )
1370 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
1371 eval $ac_var=\$ac_val;;
1372 esac
1373 # Be sure to have absolute directory names.
1374 case $ac_val in
1375 [\\/$]* | ?:[\\/]* ) continue;;
1376 NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
1377 esac
1378 as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
1379 done
1380
1381 # There might be people who depend on the old broken behavior: `$host'
1382 # used to hold the argument of --host etc.
1383 # FIXME: To remove some day.
1384 build=$build_alias
1385 host=$host_alias
1386 target=$target_alias
1387
1388 # FIXME: To remove some day.
1389 if test "x$host_alias" != x; then
1390 if test "x$build_alias" = x; then
1391 cross_compiling=maybe
1392 elif test "x$build_alias" != "x$host_alias"; then
1393 cross_compiling=yes
1394 fi
1395 fi
1396
1397 ac_tool_prefix=
1398 test -n "$host_alias" && ac_tool_prefix=$host_alias-
1399
1400 test "$silent" = yes && exec 6>/dev/null
1401
1402
1403 ac_pwd=`pwd` && test -n "$ac_pwd" &&
1404 ac_ls_di=`ls -di .` &&
1405 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
1406 as_fn_error $? "working directory cannot be determined"
1407 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
1408 as_fn_error $? "pwd does not report name of working directory"
1409
1410
1411 # Find the source files, if location was not specified.
1412 if test -z "$srcdir"; then
1413 ac_srcdir_defaulted=yes
1414 # Try the directory containing this script, then the parent directory.
1415 ac_confdir=`$as_dirname -- "$as_myself" ||
1416 $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1417 X"$as_myself" : 'X\(//\)[^/]' \| \
1418 X"$as_myself" : 'X\(//\)$' \| \
1419 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
1420 $as_echo X"$as_myself" |
1421 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1422 s//\1/
1423 q
1424 }
1425 /^X\(\/\/\)[^/].*/{
1426 s//\1/
1427 q
1428 }
1429 /^X\(\/\/\)$/{
1430 s//\1/
1431 q
1432 }
1433 /^X\(\/\).*/{
1434 s//\1/
1435 q
1436 }
1437 s/.*/./; q'`
1438 srcdir=$ac_confdir
1439 if test ! -r "$srcdir/$ac_unique_file"; then
1440 srcdir=..
1441 fi
1442 else
1443 ac_srcdir_defaulted=no
1444 fi
1445 if test ! -r "$srcdir/$ac_unique_file"; then
1446 test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
1447 as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
1448 fi
1449 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
1450 ac_abs_confdir=`(
1451 cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
1452 pwd)`
1453 # When building in place, set srcdir=.
1454 if test "$ac_abs_confdir" = "$ac_pwd"; then
1455 srcdir=.
1456 fi
1457 # Remove unnecessary trailing slashes from srcdir.
1458 # Double slashes in file names in object file debugging info
1459 # mess up M-x gdb in Emacs.
1460 case $srcdir in
1461 */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
1462 esac
1463 for ac_var in $ac_precious_vars; do
1464 eval ac_env_${ac_var}_set=\${${ac_var}+set}
1465 eval ac_env_${ac_var}_value=\$${ac_var}
1466 eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
1467 eval ac_cv_env_${ac_var}_value=\$${ac_var}
1468 done
1469
1470 #
1471 # Report the --help message.
1472 #
1473 if test "$ac_init_help" = "long"; then
1474 # Omit some internal or obsolete options to make the list less imposing.
1475 # This message is too long to be a string in the A/UX 3.1 sh.
1476 cat <<_ACEOF
1477 \`configure' configures this package to adapt to many kinds of systems.
1478
1479 Usage: $0 [OPTION]... [VAR=VALUE]...
1480
1481 To assign environment variables (e.g., CC, CFLAGS...), specify them as
1482 VAR=VALUE. See below for descriptions of some of the useful variables.
1483
1484 Defaults for the options are specified in brackets.
1485
1486 Configuration:
1487 -h, --help display this help and exit
1488 --help=short display options specific to this package
1489 --help=recursive display the short help of all the included packages
1490 -V, --version display version information and exit
1491 -q, --quiet, --silent do not print \`checking ...' messages
1492 --cache-file=FILE cache test results in FILE [disabled]
1493 -C, --config-cache alias for \`--cache-file=config.cache'
1494 -n, --no-create do not create output files
1495 --srcdir=DIR find the sources in DIR [configure dir or \`..']
1496
1497 Installation directories:
1498 --prefix=PREFIX install architecture-independent files in PREFIX
1499 [$ac_default_prefix]
1500 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
1501 [PREFIX]
1502
1503 By default, \`make install' will install all the files in
1504 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
1505 an installation prefix other than \`$ac_default_prefix' using \`--prefix',
1506 for instance \`--prefix=\$HOME'.
1507
1508 For better control, use the options below.
1509
1510 Fine tuning of the installation directories:
1511 --bindir=DIR user executables [EPREFIX/bin]
1512 --sbindir=DIR system admin executables [EPREFIX/sbin]
1513 --libexecdir=DIR program executables [EPREFIX/libexec]
1514 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
1515 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
1516 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
1517 --libdir=DIR object code libraries [EPREFIX/lib]
1518 --includedir=DIR C header files [PREFIX/include]
1519 --oldincludedir=DIR C header files for non-gcc [/usr/include]
1520 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
1521 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
1522 --infodir=DIR info documentation [DATAROOTDIR/info]
1523 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
1524 --mandir=DIR man documentation [DATAROOTDIR/man]
1525 --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
1526 --htmldir=DIR html documentation [DOCDIR]
1527 --dvidir=DIR dvi documentation [DOCDIR]
1528 --pdfdir=DIR pdf documentation [DOCDIR]
1529 --psdir=DIR ps documentation [DOCDIR]
1530 _ACEOF
1531
1532 cat <<\_ACEOF
1533
1534 System types:
1535 --build=BUILD configure for building on BUILD [guessed]
1536 --host=HOST cross-compile to build programs to run on HOST [BUILD]
1537 _ACEOF
1538 fi
1539
1540 if test -n "$ac_init_help"; then
1541
1542 cat <<\_ACEOF
1543
1544 Optional Features:
1545 --disable-option-checking ignore unrecognized --enable/--with options
1546 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
1547 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1548 --enable-shared[=PKGS] build shared libraries [default=yes]
1549 --enable-static[=PKGS] build static libraries [default=yes]
1550 --enable-fast-install[=PKGS]
1551 optimize for fast installation [default=yes]
1552 --disable-libtool-lock avoid locking (might break parallel builds)
1553 --enable-dependency-tracking
1554 Use gcc -MMD -MT dependency tracking [[default=yes]]
1555 --disable-sdltest Do not try to compile and run a test SDL program
1556 --enable-music-cmd support an external music player [[default=yes]]
1557 --enable-music-wave enable streaming WAVE music [[default=yes]]
1558 --enable-music-mod enable MOD music [[default=yes]]
1559 --enable-music-mod-modplug
1560 enable MOD music via modplug [[default=yes]]
1561 --enable-music-mod-modplug-shared
1562 dynamically load modplug library [[default=yes]]
1563 --enable-music-mod-mikmod
1564 enable MOD music via mikmod [[default=no]]
1565 --enable-music-mod-mikmod-shared
1566 dynamically load mikmod library [[default=yes]]
1567 --enable-music-midi enable MIDI music [[default=yes]]
1568 --enable-music-midi-timidity
1569 enable timidity MIDI output [[default=yes]]
1570 --enable-music-midi-native
1571 enable native MIDI music output [[default=yes]]
1572 --enable-music-midi-fluidsynth
1573 enable FluidSynth MIDI output [[default=yes]]
1574 --enable-music-midi-fluidsynth-shared
1575 dynamically load FluidSynth library [[default=yes]]
1576 --enable-music-ogg enable Ogg Vorbis music [[default=yes]]
1577 --enable-music-ogg-tremor
1578 enable OGG Vorbis music via libtremor [[default=no]]
1579 --enable-music-ogg-shared
1580 dynamically load Ogg Vorbis library [[default=yes]]
1581 --enable-music-flac enable FLAC music [[default=yes]]
1582 --enable-music-flac-shared
1583 dynamically load FLAC library [[default=yes]]
1584 --enable-music-mp3 enable MP3 music [[default=yes]]
1585 --enable-music-mp3-mad-gpl
1586 enable MP3 music via libmad GPL code [[default=no]]
1587 --enable-music-mp3-mad-gpl-dithering
1588 enable MP3 music via libmad GPL code [[default=yes]]
1589 --enable-music-mp3-mpg123
1590 enable MP3 music via libmpg123 [[default=yes]]
1591 --enable-music-mp3-mpg123-shared
1592 dynamically load libmpg123 library [[default=yes]]
1593 --enable-music-opus enable Opus music [[default=yes]]
1594 --enable-music-opus-shared
1595 dynamically load opusfile library [[default=yes]]
1596
1597 Optional Packages:
1598 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
1599 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1600 --with-pic try to use only PIC/non-PIC objects [default=use
1601 both]
1602 --with-gnu-ld assume the C compiler uses GNU ld [default=no]
1603 --with-sdl-prefix=PFX Prefix where SDL is installed (optional)
1604 --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
1605
1606 Some influential environment variables:
1607 CC C compiler command
1608 CFLAGS C compiler flags
1609 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
1610 nonstandard directory <lib dir>
1611 LIBS libraries to pass to the linker, e.g. -l<library>
1612 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
1613 you have headers in a nonstandard directory <include dir>
1614 CPP C preprocessor
1615 PKG_CONFIG path to pkg-config utility
1616 SDL_CFLAGS C compiler flags for SDL, overriding pkg-config
1617 SDL_LIBS linker flags for SDL, overriding pkg-config
1618 MODPLUG_CFLAGS
1619 C compiler flags for MODPLUG, overriding pkg-config
1620 MODPLUG_LIBS
1621 linker flags for MODPLUG, overriding pkg-config
1622 OPUSFILE_CFLAGS
1623 C compiler flags for OPUSFILE, overriding pkg-config
1624 OPUSFILE_LIBS
1625 linker flags for OPUSFILE, overriding pkg-config
1626
1627 Use these variables to override the choices made by `configure' or to help
1628 it to find libraries and programs with nonstandard names/locations.
1629
1630 Report bugs to the package provider.
1631 _ACEOF
1632 ac_status=$?
1633 fi
1634
1635 if test "$ac_init_help" = "recursive"; then
1636 # If there are subdirs, report their specific --help.
1637 for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
1638 test -d "$ac_dir" ||
1639 { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
1640 continue
1641 ac_builddir=.
1642
1643 case "$ac_dir" in
1644 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
1645 *)
1646 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
1647 # A ".." for each directory in $ac_dir_suffix.
1648 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
1649 case $ac_top_builddir_sub in
1650 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
1651 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
1652 esac ;;
1653 esac
1654 ac_abs_top_builddir=$ac_pwd
1655 ac_abs_builddir=$ac_pwd$ac_dir_suffix
1656 # for backward compatibility:
1657 ac_top_builddir=$ac_top_build_prefix
1658
1659 case $srcdir in
1660 .) # We are building in place.
1661 ac_srcdir=.
1662 ac_top_srcdir=$ac_top_builddir_sub
1663 ac_abs_top_srcdir=$ac_pwd ;;
1664 [\\/]* | ?:[\\/]* ) # Absolute name.
1665 ac_srcdir=$srcdir$ac_dir_suffix;
1666 ac_top_srcdir=$srcdir
1667 ac_abs_top_srcdir=$srcdir ;;
1668 *) # Relative name.
1669 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
1670 ac_top_srcdir=$ac_top_build_prefix$srcdir
1671 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
1672 esac
1673 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
1674
1675 cd "$ac_dir" || { ac_status=$?; continue; }
1676 # Check for guested configure.
1677 if test -f "$ac_srcdir/configure.gnu"; then
1678 echo &&
1679 $SHELL "$ac_srcdir/configure.gnu" --help=recursive
1680 elif test -f "$ac_srcdir/configure"; then
1681 echo &&
1682 $SHELL "$ac_srcdir/configure" --help=recursive
1683 else
1684 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
1685 fi || ac_status=$?
1686 cd "$ac_pwd" || { ac_status=$?; break; }
1687 done
1688 fi
1689
1690 test -n "$ac_init_help" && exit $ac_status
1691 if $ac_init_version; then
1692 cat <<\_ACEOF
1693 configure
1694 generated by GNU Autoconf 2.69
1695
1696 Copyright (C) 2012 Free Software Foundation, Inc.
1697 This configure script is free software; the Free Software Foundation
1698 gives unlimited permission to copy, distribute and modify it.
1699 _ACEOF
1700 exit
1701 fi
1702
1703 ## ------------------------ ##
1704 ## Autoconf initialization. ##
1705 ## ------------------------ ##
1706
1707 # ac_fn_c_try_compile LINENO
1708 # --------------------------
1709 # Try to compile conftest.$ac_ext, and return whether this succeeded.
1710 ac_fn_c_try_compile ()
1711 {
1712 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1713 rm -f conftest.$ac_objext
1714 if { { ac_try="$ac_compile"
1715 case "(($ac_try" in
1716 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1717 *) ac_try_echo=$ac_try;;
1718 esac
1719 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1720 $as_echo "$ac_try_echo"; } >&5
1721 (eval "$ac_compile") 2>conftest.err
1722 ac_status=$?
1723 if test -s conftest.err; then
1724 grep -v '^ *+' conftest.err >conftest.er1
1725 cat conftest.er1 >&5
1726 mv -f conftest.er1 conftest.err
1727 fi
1728 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1729 test $ac_status = 0; } && {
1730 test -z "$ac_c_werror_flag" ||
1731 test ! -s conftest.err
1732 } && test -s conftest.$ac_objext; then :
1733 ac_retval=0
1734 else
1735 $as_echo "$as_me: failed program was:" >&5
1736 sed 's/^/| /' conftest.$ac_ext >&5
1737
1738 ac_retval=1
1739 fi
1740 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1741 as_fn_set_status $ac_retval
1742
1743 } # ac_fn_c_try_compile
1744
1745 # ac_fn_c_try_link LINENO
1746 # -----------------------
1747 # Try to link conftest.$ac_ext, and return whether this succeeded.
1748 ac_fn_c_try_link ()
1749 {
1750 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1751 rm -f conftest.$ac_objext conftest$ac_exeext
1752 if { { ac_try="$ac_link"
1753 case "(($ac_try" in
1754 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1755 *) ac_try_echo=$ac_try;;
1756 esac
1757 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1758 $as_echo "$ac_try_echo"; } >&5
1759 (eval "$ac_link") 2>conftest.err
1760 ac_status=$?
1761 if test -s conftest.err; then
1762 grep -v '^ *+' conftest.err >conftest.er1
1763 cat conftest.er1 >&5
1764 mv -f conftest.er1 conftest.err
1765 fi
1766 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1767 test $ac_status = 0; } && {
1768 test -z "$ac_c_werror_flag" ||
1769 test ! -s conftest.err
1770 } && test -s conftest$ac_exeext && {
1771 test "$cross_compiling" = yes ||
1772 test -x conftest$ac_exeext
1773 }; then :
1774 ac_retval=0
1775 else
1776 $as_echo "$as_me: failed program was:" >&5
1777 sed 's/^/| /' conftest.$ac_ext >&5
1778
1779 ac_retval=1
1780 fi
1781 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1782 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1783 # interfere with the next link command; also delete a directory that is
1784 # left behind by Apple's compiler. We do this before executing the actions.
1785 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1786 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1787 as_fn_set_status $ac_retval
1788
1789 } # ac_fn_c_try_link
1790
1791 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
1792 # -------------------------------------------------------
1793 # Tests whether HEADER exists and can be compiled using the include files in
1794 # INCLUDES, setting the cache variable VAR accordingly.
1795 ac_fn_c_check_header_compile ()
1796 {
1797 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1798 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1799 $as_echo_n "checking for $2... " >&6; }
1800 if eval \${$3+:} false; then :
1801 $as_echo_n "(cached) " >&6
1802 else
1803 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1804 /* end confdefs.h. */
1805 $4
1806 #include <$2>
1807 _ACEOF
1808 if ac_fn_c_try_compile "$LINENO"; then :
1809 eval "$3=yes"
1810 else
1811 eval "$3=no"
1812 fi
1813 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1814 fi
1815 eval ac_res=\$$3
1816 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1817 $as_echo "$ac_res" >&6; }
1818 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1819
1820 } # ac_fn_c_check_header_compile
1821
1822 # ac_fn_c_try_cpp LINENO
1823 # ----------------------
1824 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
1825 ac_fn_c_try_cpp ()
1826 {
1827 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1828 if { { ac_try="$ac_cpp conftest.$ac_ext"
1829 case "(($ac_try" in
1830 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1831 *) ac_try_echo=$ac_try;;
1832 esac
1833 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1834 $as_echo "$ac_try_echo"; } >&5
1835 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
1836 ac_status=$?
1837 if test -s conftest.err; then
1838 grep -v '^ *+' conftest.err >conftest.er1
1839 cat conftest.er1 >&5
1840 mv -f conftest.er1 conftest.err
1841 fi
1842 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1843 test $ac_status = 0; } > conftest.i && {
1844 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
1845 test ! -s conftest.err
1846 }; then :
1847 ac_retval=0
1848 else
1849 $as_echo "$as_me: failed program was:" >&5
1850 sed 's/^/| /' conftest.$ac_ext >&5
1851
1852 ac_retval=1
1853 fi
1854 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1855 as_fn_set_status $ac_retval
1856
1857 } # ac_fn_c_try_cpp
1858
1859 # ac_fn_c_try_run LINENO
1860 # ----------------------
1861 # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
1862 # that executables *can* be run.
1863 ac_fn_c_try_run ()
1864 {
1865 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1866 if { { ac_try="$ac_link"
1867 case "(($ac_try" in
1868 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1869 *) ac_try_echo=$ac_try;;
1870 esac
1871 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1872 $as_echo "$ac_try_echo"; } >&5
1873 (eval "$ac_link") 2>&5
1874 ac_status=$?
1875 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1876 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
1877 { { case "(($ac_try" in
1878 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1879 *) ac_try_echo=$ac_try;;
1880 esac
1881 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1882 $as_echo "$ac_try_echo"; } >&5
1883 (eval "$ac_try") 2>&5
1884 ac_status=$?
1885 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1886 test $ac_status = 0; }; }; then :
1887 ac_retval=0
1888 else
1889 $as_echo "$as_me: program exited with status $ac_status" >&5
1890 $as_echo "$as_me: failed program was:" >&5
1891 sed 's/^/| /' conftest.$ac_ext >&5
1892
1893 ac_retval=$ac_status
1894 fi
1895 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1896 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1897 as_fn_set_status $ac_retval
1898
1899 } # ac_fn_c_try_run
1900
1901 # ac_fn_c_check_func LINENO FUNC VAR
1902 # ----------------------------------
1903 # Tests whether FUNC exists, setting the cache variable VAR accordingly
1904 ac_fn_c_check_func ()
1905 {
1906 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1907 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1908 $as_echo_n "checking for $2... " >&6; }
1909 if eval \${$3+:} false; then :
1910 $as_echo_n "(cached) " >&6
1911 else
1912 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1913 /* end confdefs.h. */
1914 /* Define $2 to an innocuous variant, in case <limits.h> declares $2.
1915 For example, HP-UX 11i <limits.h> declares gettimeofday. */
1916 #define $2 innocuous_$2
1917
1918 /* System header to define __stub macros and hopefully few prototypes,
1919 which can conflict with char $2 (); below.
1920 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
1921 <limits.h> exists even on freestanding compilers. */
1922
1923 #ifdef __STDC__
1924 # include <limits.h>
1925 #else
1926 # include <assert.h>
1927 #endif
1928
1929 #undef $2
1930
1931 /* Override any GCC internal prototype to avoid an error.
1932 Use char because int might match the return type of a GCC
1933 builtin and then its argument prototype would still apply. */
1934 #ifdef __cplusplus
1935 extern "C"
1936 #endif
1937 char $2 ();
1938 /* The GNU C library defines this for functions which it implements
1939 to always fail with ENOSYS. Some functions are actually named
1940 something starting with __ and the normal name is an alias. */
1941 #if defined __stub_$2 || defined __stub___$2
1942 choke me
1943 #endif
1944
1945 int
1946 main ()
1947 {
1948 return $2 ();
1949 ;
1950 return 0;
1951 }
1952 _ACEOF
1953 if ac_fn_c_try_link "$LINENO"; then :
1954 eval "$3=yes"
1955 else
1956 eval "$3=no"
1957 fi
1958 rm -f core conftest.err conftest.$ac_objext \
1959 conftest$ac_exeext conftest.$ac_ext
1960 fi
1961 eval ac_res=\$$3
1962 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1963 $as_echo "$ac_res" >&6; }
1964 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1965
1966 } # ac_fn_c_check_func
1967
1968 # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
1969 # -------------------------------------------------------
1970 # Tests whether HEADER exists, giving a warning if it cannot be compiled using
1971 # the include files in INCLUDES and setting the cache variable VAR
1972 # accordingly.
1973 ac_fn_c_check_header_mongrel ()
1974 {
1975 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1976 if eval \${$3+:} false; then :
1977 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1978 $as_echo_n "checking for $2... " >&6; }
1979 if eval \${$3+:} false; then :
1980 $as_echo_n "(cached) " >&6
1981 fi
1982 eval ac_res=\$$3
1983 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1984 $as_echo "$ac_res" >&6; }
1985 else
1986 # Is the header compilable?
1987 { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
1988 $as_echo_n "checking $2 usability... " >&6; }
1989 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1990 /* end confdefs.h. */
1991 $4
1992 #include <$2>
1993 _ACEOF
1994 if ac_fn_c_try_compile "$LINENO"; then :
1995 ac_header_compiler=yes
1996 else
1997 ac_header_compiler=no
1998 fi
1999 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2000 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
2001 $as_echo "$ac_header_compiler" >&6; }
2002
2003 # Is the header present?
2004 { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
2005 $as_echo_n "checking $2 presence... " >&6; }
2006 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2007 /* end confdefs.h. */
2008 #include <$2>
2009 _ACEOF
2010 if ac_fn_c_try_cpp "$LINENO"; then :
2011 ac_header_preproc=yes
2012 else
2013 ac_header_preproc=no
2014 fi
2015 rm -f conftest.err conftest.i conftest.$ac_ext
2016 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
2017 $as_echo "$ac_header_preproc" >&6; }
2018
2019 # So? What about this header?
2020 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
2021 yes:no: )
2022 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
2023 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
2024 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
2025 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
2026 ;;
2027 no:yes:* )
2028 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
2029 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
2030 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
2031 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
2032 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
2033 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
2034 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
2035 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
2036 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
2037 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
2038 ;;
2039 esac
2040 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2041 $as_echo_n "checking for $2... " >&6; }
2042 if eval \${$3+:} false; then :
2043 $as_echo_n "(cached) " >&6
2044 else
2045 eval "$3=\$ac_header_compiler"
2046 fi
2047 eval ac_res=\$$3
2048 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
2049 $as_echo "$ac_res" >&6; }
2050 fi
2051 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
2052
2053 } # ac_fn_c_check_header_mongrel
2054 cat >config.log <<_ACEOF
2055 This file contains any messages produced by compilers while
2056 running configure, to aid debugging if configure makes a mistake.
2057
2058 It was created by $as_me, which was
2059 generated by GNU Autoconf 2.69. Invocation command line was
2060
2061 $ $0 $@
2062
2063 _ACEOF
2064 exec 5>>config.log
2065 {
2066 cat <<_ASUNAME
2067 ## --------- ##
2068 ## Platform. ##
2069 ## --------- ##
2070
2071 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
2072 uname -m = `(uname -m) 2>/dev/null || echo unknown`
2073 uname -r = `(uname -r) 2>/dev/null || echo unknown`
2074 uname -s = `(uname -s) 2>/dev/null || echo unknown`
2075 uname -v = `(uname -v) 2>/dev/null || echo unknown`
2076
2077 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
2078 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
2079
2080 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
2081 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
2082 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
2083 /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
2084 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
2085 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
2086 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
2087
2088 _ASUNAME
2089
2090 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2091 for as_dir in $PATH
2092 do
2093 IFS=$as_save_IFS
2094 test -z "$as_dir" && as_dir=.
2095 $as_echo "PATH: $as_dir"
2096 done
2097 IFS=$as_save_IFS
2098
2099 } >&5
2100
2101 cat >&5 <<_ACEOF
2102
2103
2104 ## ----------- ##
2105 ## Core tests. ##
2106 ## ----------- ##
2107
2108 _ACEOF
2109
2110
2111 # Keep a trace of the command line.
2112 # Strip out --no-create and --no-recursion so they do not pile up.
2113 # Strip out --silent because we don't want to record it for future runs.
2114 # Also quote any args containing shell meta-characters.
2115 # Make two passes to allow for proper duplicate-argument suppression.
2116 ac_configure_args=
2117 ac_configure_args0=
2118 ac_configure_args1=
2119 ac_must_keep_next=false
2120 for ac_pass in 1 2
2121 do
2122 for ac_arg
2123 do
2124 case $ac_arg in
2125 -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
2126 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
2127 | -silent | --silent | --silen | --sile | --sil)
2128 continue ;;
2129 *\'*)
2130 ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
2131 esac
2132 case $ac_pass in
2133 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
2134 2)
2135 as_fn_append ac_configure_args1 " '$ac_arg'"
2136 if test $ac_must_keep_next = true; then
2137 ac_must_keep_next=false # Got value, back to normal.
2138 else
2139 case $ac_arg in
2140 *=* | --config-cache | -C | -disable-* | --disable-* \
2141 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
2142 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
2143 | -with-* | --with-* | -without-* | --without-* | --x)
2144 case "$ac_configure_args0 " in
2145 "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
2146 esac
2147 ;;
2148 -* ) ac_must_keep_next=true ;;
2149 esac
2150 fi
2151 as_fn_append ac_configure_args " '$ac_arg'"
2152 ;;
2153 esac
2154 done
2155 done
2156 { ac_configure_args0=; unset ac_configure_args0;}
2157 { ac_configure_args1=; unset ac_configure_args1;}
2158
2159 # When interrupted or exit'd, cleanup temporary files, and complete
2160 # config.log. We remove comments because anyway the quotes in there
2161 # would cause problems or look ugly.
2162 # WARNING: Use '\'' to represent an apostrophe within the trap.
2163 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
2164 trap 'exit_status=$?
2165 # Save into config.log some information that might help in debugging.
2166 {
2167 echo
2168
2169 $as_echo "## ---------------- ##
2170 ## Cache variables. ##
2171 ## ---------------- ##"
2172 echo
2173 # The following way of writing the cache mishandles newlines in values,
2174 (
2175 for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
2176 eval ac_val=\$$ac_var
2177 case $ac_val in #(
2178 *${as_nl}*)
2179 case $ac_var in #(
2180 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
2181 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
2182 esac
2183 case $ac_var in #(
2184 _ | IFS | as_nl) ;; #(
2185 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
2186 *) { eval $ac_var=; unset $ac_var;} ;;
2187 esac ;;
2188 esac
2189 done
2190 (set) 2>&1 |
2191 case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
2192 *${as_nl}ac_space=\ *)
2193 sed -n \
2194 "s/'\''/'\''\\\\'\'''\''/g;
2195 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
2196 ;; #(
2197 *)
2198 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
2199 ;;
2200 esac |
2201 sort
2202 )
2203 echo
2204
2205 $as_echo "## ----------------- ##
2206 ## Output variables. ##
2207 ## ----------------- ##"
2208 echo
2209 for ac_var in $ac_subst_vars
2210 do
2211 eval ac_val=\$$ac_var
2212 case $ac_val in
2213 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
2214 esac
2215 $as_echo "$ac_var='\''$ac_val'\''"
2216 done | sort
2217 echo
2218
2219 if test -n "$ac_subst_files"; then
2220 $as_echo "## ------------------- ##
2221 ## File substitutions. ##
2222 ## ------------------- ##"
2223 echo
2224 for ac_var in $ac_subst_files
2225 do
2226 eval ac_val=\$$ac_var
2227 case $ac_val in
2228 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
2229 esac
2230 $as_echo "$ac_var='\''$ac_val'\''"
2231 done | sort
2232 echo
2233 fi
2234
2235 if test -s confdefs.h; then
2236 $as_echo "## ----------- ##
2237 ## confdefs.h. ##
2238 ## ----------- ##"
2239 echo
2240 cat confdefs.h
2241 echo
2242 fi
2243 test "$ac_signal" != 0 &&
2244 $as_echo "$as_me: caught signal $ac_signal"
2245 $as_echo "$as_me: exit $exit_status"
2246 } >&5
2247 rm -f core *.core core.conftest.* &&
2248 rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
2249 exit $exit_status
2250 ' 0
2251 for ac_signal in 1 2 13 15; do
2252 trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
2253 done
2254 ac_signal=0
2255
2256 # confdefs.h avoids OS command line length limits that DEFS can exceed.
2257 rm -f -r conftest* confdefs.h
2258
2259 $as_echo "/* confdefs.h */" > confdefs.h
2260
2261 # Predefined preprocessor variables.
2262
2263 cat >>confdefs.h <<_ACEOF
2264 #define PACKAGE_NAME "$PACKAGE_NAME"
2265 _ACEOF
2266
2267 cat >>confdefs.h <<_ACEOF
2268 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
2269 _ACEOF
2270
2271 cat >>confdefs.h <<_ACEOF
2272 #define PACKAGE_VERSION "$PACKAGE_VERSION"
2273 _ACEOF
2274
2275 cat >>confdefs.h <<_ACEOF
2276 #define PACKAGE_STRING "$PACKAGE_STRING"
2277 _ACEOF
2278
2279 cat >>confdefs.h <<_ACEOF
2280 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
2281 _ACEOF
2282
2283 cat >>confdefs.h <<_ACEOF
2284 #define PACKAGE_URL "$PACKAGE_URL"
2285 _ACEOF
2286
2287
2288 # Let the site file select an alternate cache file if it wants to.
2289 # Prefer an explicitly selected file to automatically selected ones.
2290 ac_site_file1=NONE
2291 ac_site_file2=NONE
2292 if test -n "$CONFIG_SITE"; then
2293 # We do not want a PATH search for config.site.
2294 case $CONFIG_SITE in #((
2295 -*) ac_site_file1=./$CONFIG_SITE;;
2296 */*) ac_site_file1=$CONFIG_SITE;;
2297 *) ac_site_file1=./$CONFIG_SITE;;
2298 esac
2299 elif test "x$prefix" != xNONE; then
2300 ac_site_file1=$prefix/share/config.site
2301 ac_site_file2=$prefix/etc/config.site
2302 else
2303 ac_site_file1=$ac_default_prefix/share/config.site
2304 ac_site_file2=$ac_default_prefix/etc/config.site
2305 fi
2306 for ac_site_file in "$ac_site_file1" "$ac_site_file2"
2307 do
2308 test "x$ac_site_file" = xNONE && continue
2309 if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
2310 { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
2311 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
2312 sed 's/^/| /' "$ac_site_file" >&5
2313 . "$ac_site_file" \
2314 || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2315 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2316 as_fn_error $? "failed to load site script $ac_site_file
2317 See \`config.log' for more details" "$LINENO" 5; }
2318 fi
2319 done
2320
2321 if test -r "$cache_file"; then
2322 # Some versions of bash will fail to source /dev/null (special files
2323 # actually), so we avoid doing that. DJGPP emulates it as a regular file.
2324 if test /dev/null != "$cache_file" && test -f "$cache_file"; then
2325 { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
2326 $as_echo "$as_me: loading cache $cache_file" >&6;}
2327 case $cache_file in
2328 [\\/]* | ?:[\\/]* ) . "$cache_file";;
2329 *) . "./$cache_file";;
2330 esac
2331 fi
2332 else
2333 { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
2334 $as_echo "$as_me: creating cache $cache_file" >&6;}
2335 >$cache_file
2336 fi
2337
2338 # Check that the precious variables saved in the cache have kept the same
2339 # value.
2340 ac_cache_corrupted=false
2341 for ac_var in $ac_precious_vars; do
2342 eval ac_old_set=\$ac_cv_env_${ac_var}_set
2343 eval ac_new_set=\$ac_env_${ac_var}_set
2344 eval ac_old_val=\$ac_cv_env_${ac_var}_value
2345 eval ac_new_val=\$ac_env_${ac_var}_value
2346 case $ac_old_set,$ac_new_set in
2347 set,)
2348 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
2349 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
2350 ac_cache_corrupted=: ;;
2351 ,set)
2352 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
2353 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
2354 ac_cache_corrupted=: ;;
2355 ,);;
2356 *)
2357 if test "x$ac_old_val" != "x$ac_new_val"; then
2358 # differences in whitespace do not lead to failure.
2359 ac_old_val_w=`echo x $ac_old_val`
2360 ac_new_val_w=`echo x $ac_new_val`
2361 if test "$ac_old_val_w" != "$ac_new_val_w"; then
2362 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
2363 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
2364 ac_cache_corrupted=:
2365 else
2366 { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
2367 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
2368 eval $ac_var=\$ac_old_val
2369 fi
2370 { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
2371 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
2372 { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
2373 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
2374 fi;;
2375 esac
2376 # Pass precious variables to config.status.
2377 if test "$ac_new_set" = set; then
2378 case $ac_new_val in
2379 *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
2380 *) ac_arg=$ac_var=$ac_new_val ;;
2381 esac
2382 case " $ac_configure_args " in
2383 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
2384 *) as_fn_append ac_configure_args " '$ac_arg'" ;;
2385 esac
2386 fi
2387 done
2388 if $ac_cache_corrupted; then
2389 { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2390 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2391 { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
2392 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
2393 as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
2394 fi
2395 ## -------------------- ##
2396 ## Main body of script. ##
2397 ## -------------------- ##
2398
2399 ac_ext=c
2400 ac_cpp='$CPP $CPPFLAGS'
2401 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2402 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2403 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2404
2405
2406 ac_aux_dir=
2407 for ac_dir in build-scripts "$srcdir"/build-scripts; do
2408 if test -f "$ac_dir/install-sh"; then
2409 ac_aux_dir=$ac_dir
2410 ac_install_sh="$ac_aux_dir/install-sh -c"
2411 break
2412 elif test -f "$ac_dir/install.sh"; then
2413 ac_aux_dir=$ac_dir
2414 ac_install_sh="$ac_aux_dir/install.sh -c"
2415 break
2416 elif test -f "$ac_dir/shtool"; then
2417 ac_aux_dir=$ac_dir
2418 ac_install_sh="$ac_aux_dir/shtool install -c"
2419 break
2420 fi
2421 done
2422 if test -z "$ac_aux_dir"; then
2423 as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-scripts \"$srcdir\"/build-scripts" "$LINENO" 5
2424 fi
2425
2426 # These three variables are undocumented and unsupported,
2427 # and are intended to be withdrawn in a future Autoconf release.
2428 # They can cause serious problems if a builder's source tree is in a directory
2429 # whose full name contains unusual characters.
2430 ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
2431 ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
2432 ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
2433
2434
2435
2436
2437 # Making releases:
2438 # MICRO_VERSION += 1;
2439 # INTERFACE_AGE += 1;
2440 # BINARY_AGE += 1;
2441 # if any functions have been added, set INTERFACE_AGE to 0.
2442 # if backwards compatibility has been broken,
2443 # set BINARY_AGE and INTERFACE_AGE to 0.
2444 #
2445 MAJOR_VERSION=2
2446 MINOR_VERSION=0
2447 MICRO_VERSION=4
2448 INTERFACE_AGE=2
2449 BINARY_AGE=4
2450 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
2451
2452
2453
2454
2455
2456
2457
2458
2459 # libtool versioning
2460 case `pwd` in
2461 *\ * | *\ *)
2462 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
2463 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
2464 esac
2465
2466
2467
2468 macro_version='2.2.6'
2469 macro_revision='1.3012'
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483 ltmain="$ac_aux_dir/ltmain.sh"
2484
2485 # Make sure we can run config.sub.
2486 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
2487 as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
2488
2489 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
2490 $as_echo_n "checking build system type... " >&6; }
2491 if ${ac_cv_build+:} false; then :
2492 $as_echo_n "(cached) " >&6
2493 else
2494 ac_build_alias=$build_alias
2495 test "x$ac_build_alias" = x &&
2496 ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
2497 test "x$ac_build_alias" = x &&
2498 as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
2499 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
2500 as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
2501
2502 fi
2503 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
2504 $as_echo "$ac_cv_build" >&6; }
2505 case $ac_cv_build in
2506 *-*-*) ;;
2507 *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
2508 esac
2509 build=$ac_cv_build
2510 ac_save_IFS=$IFS; IFS='-'
2511 set x $ac_cv_build
2512 shift
2513 build_cpu=$1
2514 build_vendor=$2
2515 shift; shift
2516 # Remember, the first character of IFS is used to create $*,
2517 # except with old shells:
2518 build_os=$*
2519 IFS=$ac_save_IFS
2520 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
2521
2522
2523 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
2524 $as_echo_n "checking host system type... " >&6; }
2525 if ${ac_cv_host+:} false; then :
2526 $as_echo_n "(cached) " >&6
2527 else
2528 if test "x$host_alias" = x; then
2529 ac_cv_host=$ac_cv_build
2530 else
2531 ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
2532 as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
2533 fi
2534
2535 fi
2536 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
2537 $as_echo "$ac_cv_host" >&6; }
2538 case $ac_cv_host in
2539 *-*-*) ;;
2540 *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
2541 esac
2542 host=$ac_cv_host
2543 ac_save_IFS=$IFS; IFS='-'
2544 set x $ac_cv_host
2545 shift
2546 host_cpu=$1
2547 host_vendor=$2
2548 shift; shift
2549 # Remember, the first character of IFS is used to create $*,
2550 # except with old shells:
2551 host_os=$*
2552 IFS=$ac_save_IFS
2553 case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
2554
2555
2556 ac_ext=c
2557 ac_cpp='$CPP $CPPFLAGS'
2558 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2559 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2560 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2561 if test -n "$ac_tool_prefix"; then
2562 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
2563 set dummy ${ac_tool_prefix}gcc; ac_word=$2
2564 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2565 $as_echo_n "checking for $ac_word... " >&6; }
2566 if ${ac_cv_prog_CC+:} false; then :
2567 $as_echo_n "(cached) " >&6
2568 else
2569 if test -n "$CC"; then
2570 ac_cv_prog_CC="$CC" # Let the user override the test.
2571 else
2572 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2573 for as_dir in $PATH
2574 do
2575 IFS=$as_save_IFS
2576 test -z "$as_dir" && as_dir=.
2577 for ac_exec_ext in '' $ac_executable_extensions; do
2578 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2579 ac_cv_prog_CC="${ac_tool_prefix}gcc"
2580 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2581 break 2
2582 fi
2583 done
2584 done
2585 IFS=$as_save_IFS
2586
2587 fi
2588 fi
2589 CC=$ac_cv_prog_CC
2590 if test -n "$CC"; then
2591 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2592 $as_echo "$CC" >&6; }
2593 else
2594 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2595 $as_echo "no" >&6; }
2596 fi
2597
2598
2599 fi
2600 if test -z "$ac_cv_prog_CC"; then
2601 ac_ct_CC=$CC
2602 # Extract the first word of "gcc", so it can be a program name with args.
2603 set dummy gcc; ac_word=$2
2604 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2605 $as_echo_n "checking for $ac_word... " >&6; }
2606 if ${ac_cv_prog_ac_ct_CC+:} false; then :
2607 $as_echo_n "(cached) " >&6
2608 else
2609 if test -n "$ac_ct_CC"; then
2610 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2611 else
2612 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2613 for as_dir in $PATH
2614 do
2615 IFS=$as_save_IFS
2616 test -z "$as_dir" && as_dir=.
2617 for ac_exec_ext in '' $ac_executable_extensions; do
2618 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2619 ac_cv_prog_ac_ct_CC="gcc"
2620 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2621 break 2
2622 fi
2623 done
2624 done
2625 IFS=$as_save_IFS
2626
2627 fi
2628 fi
2629 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2630 if test -n "$ac_ct_CC"; then
2631 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2632 $as_echo "$ac_ct_CC" >&6; }
2633 else
2634 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2635 $as_echo "no" >&6; }
2636 fi
2637
2638 if test "x$ac_ct_CC" = x; then
2639 CC=""
2640 else
2641 case $cross_compiling:$ac_tool_warned in
2642 yes:)
2643 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2644 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2645 ac_tool_warned=yes ;;
2646 esac
2647 CC=$ac_ct_CC
2648 fi
2649 else
2650 CC="$ac_cv_prog_CC"
2651 fi
2652
2653 if test -z "$CC"; then
2654 if test -n "$ac_tool_prefix"; then
2655 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
2656 set dummy ${ac_tool_prefix}cc; ac_word=$2
2657 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2658 $as_echo_n "checking for $ac_word... " >&6; }
2659 if ${ac_cv_prog_CC+:} false; then :
2660 $as_echo_n "(cached) " >&6
2661 else
2662 if test -n "$CC"; then
2663 ac_cv_prog_CC="$CC" # Let the user override the test.
2664 else
2665 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2666 for as_dir in $PATH
2667 do
2668 IFS=$as_save_IFS
2669 test -z "$as_dir" && as_dir=.
2670 for ac_exec_ext in '' $ac_executable_extensions; do
2671 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2672 ac_cv_prog_CC="${ac_tool_prefix}cc"
2673 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2674 break 2
2675 fi
2676 done
2677 done
2678 IFS=$as_save_IFS
2679
2680 fi
2681 fi
2682 CC=$ac_cv_prog_CC
2683 if test -n "$CC"; then
2684 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2685 $as_echo "$CC" >&6; }
2686 else
2687 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2688 $as_echo "no" >&6; }
2689 fi
2690
2691
2692 fi
2693 fi
2694 if test -z "$CC"; then
2695 # Extract the first word of "cc", so it can be a program name with args.
2696 set dummy cc; ac_word=$2
2697 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2698 $as_echo_n "checking for $ac_word... " >&6; }
2699 if ${ac_cv_prog_CC+:} false; then :
2700 $as_echo_n "(cached) " >&6
2701 else
2702 if test -n "$CC"; then
2703 ac_cv_prog_CC="$CC" # Let the user override the test.
2704 else
2705 ac_prog_rejected=no
2706 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2707 for as_dir in $PATH
2708 do
2709 IFS=$as_save_IFS
2710 test -z "$as_dir" && as_dir=.
2711 for ac_exec_ext in '' $ac_executable_extensions; do
2712 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2713 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
2714 ac_prog_rejected=yes
2715 continue
2716 fi
2717 ac_cv_prog_CC="cc"
2718 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2719 break 2
2720 fi
2721 done
2722 done
2723 IFS=$as_save_IFS
2724
2725 if test $ac_prog_rejected = yes; then
2726 # We found a bogon in the path, so make sure we never use it.
2727 set dummy $ac_cv_prog_CC
2728 shift
2729 if test $# != 0; then
2730 # We chose a different compiler from the bogus one.
2731 # However, it has the same basename, so the bogon will be chosen
2732 # first if we set CC to just the basename; use the full file name.
2733 shift
2734 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
2735 fi
2736 fi
2737 fi
2738 fi
2739 CC=$ac_cv_prog_CC
2740 if test -n "$CC"; then
2741 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2742 $as_echo "$CC" >&6; }
2743 else
2744 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2745 $as_echo "no" >&6; }
2746 fi
2747
2748
2749 fi
2750 if test -z "$CC"; then
2751 if test -n "$ac_tool_prefix"; then
2752 for ac_prog in cl.exe
2753 do
2754 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
2755 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
2756 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2757 $as_echo_n "checking for $ac_word... " >&6; }
2758 if ${ac_cv_prog_CC+:} false; then :
2759 $as_echo_n "(cached) " >&6
2760 else
2761 if test -n "$CC"; then
2762 ac_cv_prog_CC="$CC" # Let the user override the test.
2763 else
2764 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2765 for as_dir in $PATH
2766 do
2767 IFS=$as_save_IFS
2768 test -z "$as_dir" && as_dir=.
2769 for ac_exec_ext in '' $ac_executable_extensions; do
2770 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2771 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
2772 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2773 break 2
2774 fi
2775 done
2776 done
2777 IFS=$as_save_IFS
2778
2779 fi
2780 fi
2781 CC=$ac_cv_prog_CC
2782 if test -n "$CC"; then
2783 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2784 $as_echo "$CC" >&6; }
2785 else
2786 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2787 $as_echo "no" >&6; }
2788 fi
2789
2790
2791 test -n "$CC" && break
2792 done
2793 fi
2794 if test -z "$CC"; then
2795 ac_ct_CC=$CC
2796 for ac_prog in cl.exe
2797 do
2798 # Extract the first word of "$ac_prog", so it can be a program name with args.
2799 set dummy $ac_prog; ac_word=$2
2800 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2801 $as_echo_n "checking for $ac_word... " >&6; }
2802 if ${ac_cv_prog_ac_ct_CC+:} false; then :
2803 $as_echo_n "(cached) " >&6
2804 else
2805 if test -n "$ac_ct_CC"; then
2806 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2807 else
2808 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2809 for as_dir in $PATH
2810 do
2811 IFS=$as_save_IFS
2812 test -z "$as_dir" && as_dir=.
2813 for ac_exec_ext in '' $ac_executable_extensions; do
2814 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2815 ac_cv_prog_ac_ct_CC="$ac_prog"
2816 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2817 break 2
2818 fi
2819 done
2820 done
2821 IFS=$as_save_IFS
2822
2823 fi
2824 fi
2825 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2826 if test -n "$ac_ct_CC"; then
2827 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2828 $as_echo "$ac_ct_CC" >&6; }
2829 else
2830 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2831 $as_echo "no" >&6; }
2832 fi
2833
2834
2835 test -n "$ac_ct_CC" && break
2836 done
2837
2838 if test "x$ac_ct_CC" = x; then
2839 CC=""
2840 else
2841 case $cross_compiling:$ac_tool_warned in
2842 yes:)
2843 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2844 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2845 ac_tool_warned=yes ;;
2846 esac
2847 CC=$ac_ct_CC
2848 fi
2849 fi
2850
2851 fi
2852
2853
2854 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2855 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2856 as_fn_error $? "no acceptable C compiler found in \$PATH
2857 See \`config.log' for more details" "$LINENO" 5; }
2858
2859 # Provide some information about the compiler.
2860 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
2861 set X $ac_compile
2862 ac_compiler=$2
2863 for ac_option in --version -v -V -qversion; do
2864 { { ac_try="$ac_compiler $ac_option >&5"
2865 case "(($ac_try" in
2866 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2867 *) ac_try_echo=$ac_try;;
2868 esac
2869 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2870 $as_echo "$ac_try_echo"; } >&5
2871 (eval "$ac_compiler $ac_option >&5") 2>conftest.err
2872 ac_status=$?
2873 if test -s conftest.err; then
2874 sed '10a\
2875 ... rest of stderr output deleted ...
2876 10q' conftest.err >conftest.er1
2877 cat conftest.er1 >&5
2878 fi
2879 rm -f conftest.er1 conftest.err
2880 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2881 test $ac_status = 0; }
2882 done
2883
2884 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2885 /* end confdefs.h. */
2886
2887 int
2888 main ()
2889 {
2890
2891 ;
2892 return 0;
2893 }
2894 _ACEOF
2895 ac_clean_files_save=$ac_clean_files
2896 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
2897 # Try to create an executable without -o first, disregard a.out.
2898 # It will help us diagnose broken compilers, and finding out an intuition
2899 # of exeext.
2900 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
2901 $as_echo_n "checking whether the C compiler works... " >&6; }
2902 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
2903
2904 # The possible output files:
2905 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
2906
2907 ac_rmfiles=
2908 for ac_file in $ac_files
2909 do
2910 case $ac_file in
2911 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
2912 * ) ac_rmfiles="$ac_rmfiles $ac_file";;
2913 esac
2914 done
2915 rm -f $ac_rmfiles
2916
2917 if { { ac_try="$ac_link_default"
2918 case "(($ac_try" in
2919 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2920 *) ac_try_echo=$ac_try;;
2921 esac
2922 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2923 $as_echo "$ac_try_echo"; } >&5
2924 (eval "$ac_link_default") 2>&5
2925 ac_status=$?
2926 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2927 test $ac_status = 0; }; then :
2928 # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
2929 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
2930 # in a Makefile. We should not override ac_cv_exeext if it was cached,
2931 # so that the user can short-circuit this test for compilers unknown to
2932 # Autoconf.
2933 for ac_file in $ac_files ''
2934 do
2935 test -f "$ac_file" || continue
2936 case $ac_file in
2937 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
2938 ;;
2939 [ab].out )
2940 # We found the default executable, but exeext='' is most
2941 # certainly right.
2942 break;;
2943 *.* )
2944 if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
2945 then :; else
2946 ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
2947 fi
2948 # We set ac_cv_exeext here because the later test for it is not
2949 # safe: cross compilers may not add the suffix if given an `-o'
2950 # argument, so we may need to know it at that point already.
2951 # Even if this section looks crufty: it has the advantage of
2952 # actually working.
2953 break;;
2954 * )
2955 break;;
2956 esac
2957 done
2958 test "$ac_cv_exeext" = no && ac_cv_exeext=
2959
2960 else
2961 ac_file=''
2962 fi
2963 if test -z "$ac_file"; then :
2964 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2965 $as_echo "no" >&6; }
2966 $as_echo "$as_me: failed program was:" >&5
2967 sed 's/^/| /' conftest.$ac_ext >&5
2968
2969 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2970 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2971 as_fn_error 77 "C compiler cannot create executables
2972 See \`config.log' for more details" "$LINENO" 5; }
2973 else
2974 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2975 $as_echo "yes" >&6; }
2976 fi
2977 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
2978 $as_echo_n "checking for C compiler default output file name... " >&6; }
2979 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
2980 $as_echo "$ac_file" >&6; }
2981 ac_exeext=$ac_cv_exeext
2982
2983 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
2984 ac_clean_files=$ac_clean_files_save
2985 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
2986 $as_echo_n "checking for suffix of executables... " >&6; }
2987 if { { ac_try="$ac_link"
2988 case "(($ac_try" in
2989 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2990 *) ac_try_echo=$ac_try;;
2991 esac
2992 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2993 $as_echo "$ac_try_echo"; } >&5
2994 (eval "$ac_link") 2>&5
2995 ac_status=$?
2996 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2997 test $ac_status = 0; }; then :
2998 # If both `conftest.exe' and `conftest' are `present' (well, observable)
2999 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
3000 # work properly (i.e., refer to `conftest.exe'), while it won't with
3001 # `rm'.
3002 for ac_file in conftest.exe conftest conftest.*; do
3003 test -f "$ac_file" || continue
3004 case $ac_file in
3005 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
3006 *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
3007 break;;
3008 * ) break;;
3009 esac
3010 done
3011 else
3012 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3013 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3014 as_fn_error $? "cannot compute suffix of executables: cannot compile and link
3015 See \`config.log' for more details" "$LINENO" 5; }
3016 fi
3017 rm -f conftest conftest$ac_cv_exeext
3018 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
3019 $as_echo "$ac_cv_exeext" >&6; }
3020
3021 rm -f conftest.$ac_ext
3022 EXEEXT=$ac_cv_exeext
3023 ac_exeext=$EXEEXT
3024 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3025 /* end confdefs.h. */
3026 #include <stdio.h>
3027 int
3028 main ()
3029 {
3030 FILE *f = fopen ("conftest.out", "w");
3031 return ferror (f) || fclose (f) != 0;
3032
3033 ;
3034 return 0;
3035 }
3036 _ACEOF
3037 ac_clean_files="$ac_clean_files conftest.out"
3038 # Check that the compiler produces executables we can run. If not, either
3039 # the compiler is broken, or we cross compile.
3040 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
3041 $as_echo_n "checking whether we are cross compiling... " >&6; }
3042 if test "$cross_compiling" != yes; then
3043 { { ac_try="$ac_link"
3044 case "(($ac_try" in
3045 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3046 *) ac_try_echo=$ac_try;;
3047 esac
3048 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3049 $as_echo "$ac_try_echo"; } >&5
3050 (eval "$ac_link") 2>&5
3051 ac_status=$?
3052 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3053 test $ac_status = 0; }
3054 if { ac_try='./conftest$ac_cv_exeext'
3055 { { case "(($ac_try" in
3056 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3057 *) ac_try_echo=$ac_try;;
3058 esac
3059 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3060 $as_echo "$ac_try_echo"; } >&5
3061 (eval "$ac_try") 2>&5
3062 ac_status=$?
3063 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3064 test $ac_status = 0; }; }; then
3065 cross_compiling=no
3066 else
3067 if test "$cross_compiling" = maybe; then
3068 cross_compiling=yes
3069 else
3070 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3071 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3072 as_fn_error $? "cannot run C compiled programs.
3073 If you meant to cross compile, use \`--host'.
3074 See \`config.log' for more details" "$LINENO" 5; }
3075 fi
3076 fi
3077 fi
3078 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
3079 $as_echo "$cross_compiling" >&6; }
3080
3081 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
3082 ac_clean_files=$ac_clean_files_save
3083 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
3084 $as_echo_n "checking for suffix of object files... " >&6; }
3085 if ${ac_cv_objext+:} false; then :
3086 $as_echo_n "(cached) " >&6
3087 else
3088 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3089 /* end confdefs.h. */
3090
3091 int
3092 main ()
3093 {
3094
3095 ;
3096 return 0;
3097 }
3098 _ACEOF
3099 rm -f conftest.o conftest.obj
3100 if { { ac_try="$ac_compile"
3101 case "(($ac_try" in
3102 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3103 *) ac_try_echo=$ac_try;;
3104 esac
3105 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3106 $as_echo "$ac_try_echo"; } >&5
3107 (eval "$ac_compile") 2>&5
3108 ac_status=$?
3109 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3110 test $ac_status = 0; }; then :
3111 for ac_file in conftest.o conftest.obj conftest.*; do
3112 test -f "$ac_file" || continue;
3113 case $ac_file in
3114 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
3115 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
3116 break;;
3117 esac
3118 done
3119 else
3120 $as_echo "$as_me: failed program was:" >&5
3121 sed 's/^/| /' conftest.$ac_ext >&5
3122
3123 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3124 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3125 as_fn_error $? "cannot compute suffix of object files: cannot compile
3126 See \`config.log' for more details" "$LINENO" 5; }
3127 fi
3128 rm -f conftest.$ac_cv_objext conftest.$ac_ext
3129 fi
3130 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
3131 $as_echo "$ac_cv_objext" >&6; }
3132 OBJEXT=$ac_cv_objext
3133 ac_objext=$OBJEXT
3134 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
3135 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
3136 if ${ac_cv_c_compiler_gnu+:} false; then :
3137 $as_echo_n "(cached) " >&6
3138 else
3139 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3140 /* end confdefs.h. */
3141
3142 int
3143 main ()
3144 {
3145 #ifndef __GNUC__
3146 choke me
3147 #endif
3148
3149 ;
3150 return 0;
3151 }
3152 _ACEOF
3153 if ac_fn_c_try_compile "$LINENO"; then :
3154 ac_compiler_gnu=yes
3155 else
3156 ac_compiler_gnu=no
3157 fi
3158 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3159 ac_cv_c_compiler_gnu=$ac_compiler_gnu
3160
3161 fi
3162 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
3163 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
3164 if test $ac_compiler_gnu = yes; then
3165 GCC=yes
3166 else
3167 GCC=
3168 fi
3169 ac_test_CFLAGS=${CFLAGS+set}
3170 ac_save_CFLAGS=$CFLAGS
3171 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
3172 $as_echo_n "checking whether $CC accepts -g... " >&6; }
3173 if ${ac_cv_prog_cc_g+:} false; then :
3174 $as_echo_n "(cached) " >&6
3175 else
3176 ac_save_c_werror_flag=$ac_c_werror_flag
3177 ac_c_werror_flag=yes
3178 ac_cv_prog_cc_g=no
3179 CFLAGS="-g"
3180 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3181 /* end confdefs.h. */
3182
3183 int
3184 main ()
3185 {
3186
3187 ;
3188 return 0;
3189 }
3190 _ACEOF
3191 if ac_fn_c_try_compile "$LINENO"; then :
3192 ac_cv_prog_cc_g=yes
3193 else
3194 CFLAGS=""
3195 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3196 /* end confdefs.h. */
3197
3198 int
3199 main ()
3200 {
3201
3202 ;
3203 return 0;
3204 }
3205 _ACEOF
3206 if ac_fn_c_try_compile "$LINENO"; then :
3207
3208 else
3209 ac_c_werror_flag=$ac_save_c_werror_flag
3210 CFLAGS="-g"
3211 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3212 /* end confdefs.h. */
3213
3214 int
3215 main ()
3216 {
3217
3218 ;
3219 return 0;
3220 }
3221 _ACEOF
3222 if ac_fn_c_try_compile "$LINENO"; then :
3223 ac_cv_prog_cc_g=yes
3224 fi
3225 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3226 fi
3227 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3228 fi
3229 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3230 ac_c_werror_flag=$ac_save_c_werror_flag
3231 fi
3232 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
3233 $as_echo "$ac_cv_prog_cc_g" >&6; }
3234 if test "$ac_test_CFLAGS" = set; then
3235 CFLAGS=$ac_save_CFLAGS
3236 elif test $ac_cv_prog_cc_g = yes; then
3237 if test "$GCC" = yes; then
3238 CFLAGS="-g -O2"
3239 else
3240 CFLAGS="-g"
3241 fi
3242 else
3243 if test "$GCC" = yes; then
3244 CFLAGS="-O2"
3245 else
3246 CFLAGS=
3247 fi
3248 fi
3249 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
3250 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
3251 if ${ac_cv_prog_cc_c89+:} false; then :
3252 $as_echo_n "(cached) " >&6
3253 else
3254 ac_cv_prog_cc_c89=no
3255 ac_save_CC=$CC
3256 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3257 /* end confdefs.h. */
3258 #include <stdarg.h>
3259 #include <stdio.h>
3260 struct stat;
3261 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
3262 struct buf { int x; };
3263 FILE * (*rcsopen) (struct buf *, struct stat *, int);
3264 static char *e (p, i)
3265 char **p;
3266 int i;
3267 {
3268 return p[i];
3269 }
3270 static char *f (char * (*g) (char **, int), char **p, ...)
3271 {
3272 char *s;
3273 va_list v;
3274 va_start (v,p);
3275 s = g (p, va_arg (v,int));
3276 va_end (v);
3277 return s;
3278 }
3279
3280 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
3281 function prototypes and stuff, but not '\xHH' hex character constants.
3282 These don't provoke an error unfortunately, instead are silently treated
3283 as 'x'. The following induces an error, until -std is added to get
3284 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
3285 array size at least. It's necessary to write '\x00'==0 to get something
3286 that's true only with -std. */
3287 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
3288
3289 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
3290 inside strings and character constants. */
3291 #define FOO(x) 'x'
3292 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
3293
3294 int test (int i, double x);
3295 struct s1 {int (*f) (int a);};
3296 struct s2 {int (*f) (double a);};
3297 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
3298 int argc;
3299 char **argv;
3300 int
3301 main ()
3302 {
3303 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
3304 ;
3305 return 0;
3306 }
3307 _ACEOF
3308 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
3309 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3310 do
3311 CC="$ac_save_CC $ac_arg"
3312 if ac_fn_c_try_compile "$LINENO"; then :
3313 ac_cv_prog_cc_c89=$ac_arg
3314 fi
3315 rm -f core conftest.err conftest.$ac_objext
3316 test "x$ac_cv_prog_cc_c89" != "xno" && break
3317 done
3318 rm -f conftest.$ac_ext
3319 CC=$ac_save_CC
3320
3321 fi
3322 # AC_CACHE_VAL
3323 case "x$ac_cv_prog_cc_c89" in
3324 x)
3325 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
3326 $as_echo "none needed" >&6; } ;;
3327 xno)
3328 { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
3329 $as_echo "unsupported" >&6; } ;;
3330 *)
3331 CC="$CC $ac_cv_prog_cc_c89"
3332 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
3333 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
3334 esac
3335 if test "x$ac_cv_prog_cc_c89" != xno; then :
3336
3337 fi
3338
3339 ac_ext=c
3340 ac_cpp='$CPP $CPPFLAGS'
3341 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3342 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3343 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3344
3345 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
3346 $as_echo_n "checking for a sed that does not truncate output... " >&6; }
3347 if ${ac_cv_path_SED+:} false; then :
3348 $as_echo_n "(cached) " >&6
3349 else
3350 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
3351 for ac_i in 1 2 3 4 5 6 7; do
3352 ac_script="$ac_script$as_nl$ac_script"
3353 done
3354 echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
3355 { ac_script=; unset ac_script;}
3356 if test -z "$SED"; then
3357 ac_path_SED_found=false
3358 # Loop through the user's path and test for each of PROGNAME-LIST
3359 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3360 for as_dir in $PATH
3361 do
3362 IFS=$as_save_IFS
3363 test -z "$as_dir" && as_dir=.
3364 for ac_prog in sed gsed; do
3365 for ac_exec_ext in '' $ac_executable_extensions; do
3366 ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
3367 as_fn_executable_p "$ac_path_SED" || continue
3368 # Check for GNU ac_path_SED and select it if it is found.
3369 # Check for GNU $ac_path_SED
3370 case `"$ac_path_SED" --version 2>&1` in
3371 *GNU*)
3372 ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
3373 *)
3374 ac_count=0
3375 $as_echo_n 0123456789 >"conftest.in"
3376 while :
3377 do
3378 cat "conftest.in" "conftest.in" >"conftest.tmp"
3379 mv "conftest.tmp" "conftest.in"
3380 cp "conftest.in" "conftest.nl"
3381 $as_echo '' >> "conftest.nl"
3382 "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
3383 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3384 as_fn_arith $ac_count + 1 && ac_count=$as_val
3385 if test $ac_count -gt ${ac_path_SED_max-0}; then
3386 # Best one so far, save it but keep looking for a better one
3387 ac_cv_path_SED="$ac_path_SED"
3388 ac_path_SED_max=$ac_count
3389 fi
3390 # 10*(2^10) chars as input seems more than enough
3391 test $ac_count -gt 10 && break
3392 done
3393 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3394 esac
3395
3396 $ac_path_SED_found && break 3
3397 done
3398 done
3399 done
3400 IFS=$as_save_IFS
3401 if test -z "$ac_cv_path_SED"; then
3402 as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
3403 fi
3404 else
3405 ac_cv_path_SED=$SED
3406 fi
3407
3408 fi
3409 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
3410 $as_echo "$ac_cv_path_SED" >&6; }
3411 SED="$ac_cv_path_SED"
3412 rm -f conftest.sed
3413
3414 test -z "$SED" && SED=sed
3415 Xsed="$SED -e 1s/^X//"
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
3428 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
3429 if ${ac_cv_path_GREP+:} false; then :
3430 $as_echo_n "(cached) " >&6
3431 else
3432 if test -z "$GREP"; then
3433 ac_path_GREP_found=false
3434 # Loop through the user's path and test for each of PROGNAME-LIST
3435 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3436 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3437 do
3438 IFS=$as_save_IFS
3439 test -z "$as_dir" && as_dir=.
3440 for ac_prog in grep ggrep; do
3441 for ac_exec_ext in '' $ac_executable_extensions; do
3442 ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
3443 as_fn_executable_p "$ac_path_GREP" || continue
3444 # Check for GNU ac_path_GREP and select it if it is found.
3445 # Check for GNU $ac_path_GREP
3446 case `"$ac_path_GREP" --version 2>&1` in
3447 *GNU*)
3448 ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
3449 *)
3450 ac_count=0
3451 $as_echo_n 0123456789 >"conftest.in"
3452 while :
3453 do
3454 cat "conftest.in" "conftest.in" >"conftest.tmp"
3455 mv "conftest.tmp" "conftest.in"
3456 cp "conftest.in" "conftest.nl"
3457 $as_echo 'GREP' >> "conftest.nl"
3458 "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
3459 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3460 as_fn_arith $ac_count + 1 && ac_count=$as_val
3461 if test $ac_count -gt ${ac_path_GREP_max-0}; then
3462 # Best one so far, save it but keep looking for a better one
3463 ac_cv_path_GREP="$ac_path_GREP"
3464 ac_path_GREP_max=$ac_count
3465 fi
3466 # 10*(2^10) chars as input seems more than enough
3467 test $ac_count -gt 10 && break
3468 done
3469 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3470 esac
3471
3472 $ac_path_GREP_found && break 3
3473 done
3474 done
3475 done
3476 IFS=$as_save_IFS
3477 if test -z "$ac_cv_path_GREP"; then
3478 as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3479 fi
3480 else
3481 ac_cv_path_GREP=$GREP
3482 fi
3483
3484 fi
3485 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
3486 $as_echo "$ac_cv_path_GREP" >&6; }
3487 GREP="$ac_cv_path_GREP"
3488
3489
3490 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
3491 $as_echo_n "checking for egrep... " >&6; }
3492 if ${ac_cv_path_EGREP+:} false; then :
3493 $as_echo_n "(cached) " >&6
3494 else
3495 if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
3496 then ac_cv_path_EGREP="$GREP -E"
3497 else
3498 if test -z "$EGREP"; then
3499 ac_path_EGREP_found=false
3500 # Loop through the user's path and test for each of PROGNAME-LIST
3501 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3502 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3503 do
3504 IFS=$as_save_IFS
3505 test -z "$as_dir" && as_dir=.
3506 for ac_prog in egrep; do
3507 for ac_exec_ext in '' $ac_executable_extensions; do
3508 ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
3509 as_fn_executable_p "$ac_path_EGREP" || continue
3510 # Check for GNU ac_path_EGREP and select it if it is found.
3511 # Check for GNU $ac_path_EGREP
3512 case `"$ac_path_EGREP" --version 2>&1` in
3513 *GNU*)
3514 ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
3515 *)
3516 ac_count=0
3517 $as_echo_n 0123456789 >"conftest.in"
3518 while :
3519 do
3520 cat "conftest.in" "conftest.in" >"conftest.tmp"
3521 mv "conftest.tmp" "conftest.in"
3522 cp "conftest.in" "conftest.nl"
3523 $as_echo 'EGREP' >> "conftest.nl"
3524 "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
3525 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3526 as_fn_arith $ac_count + 1 && ac_count=$as_val
3527 if test $ac_count -gt ${ac_path_EGREP_max-0}; then
3528 # Best one so far, save it but keep looking for a better one
3529 ac_cv_path_EGREP="$ac_path_EGREP"
3530 ac_path_EGREP_max=$ac_count
3531 fi
3532 # 10*(2^10) chars as input seems more than enough
3533 test $ac_count -gt 10 && break
3534 done
3535 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3536 esac
3537
3538 $ac_path_EGREP_found && break 3
3539 done
3540 done
3541 done
3542 IFS=$as_save_IFS
3543 if test -z "$ac_cv_path_EGREP"; then
3544 as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3545 fi
3546 else
3547 ac_cv_path_EGREP=$EGREP
3548 fi
3549
3550 fi
3551 fi
3552 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
3553 $as_echo "$ac_cv_path_EGREP" >&6; }
3554 EGREP="$ac_cv_path_EGREP"
3555
3556
3557 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
3558 $as_echo_n "checking for fgrep... " >&6; }
3559 if ${ac_cv_path_FGREP+:} false; then :
3560 $as_echo_n "(cached) " >&6
3561 else
3562 if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
3563 then ac_cv_path_FGREP="$GREP -F"
3564 else
3565 if test -z "$FGREP"; then
3566 ac_path_FGREP_found=false
3567 # Loop through the user's path and test for each of PROGNAME-LIST
3568 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3569 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3570 do
3571 IFS=$as_save_IFS
3572 test -z "$as_dir" && as_dir=.
3573 for ac_prog in fgrep; do
3574 for ac_exec_ext in '' $ac_executable_extensions; do
3575 ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
3576 as_fn_executable_p "$ac_path_FGREP" || continue
3577 # Check for GNU ac_path_FGREP and select it if it is found.
3578 # Check for GNU $ac_path_FGREP
3579 case `"$ac_path_FGREP" --version 2>&1` in
3580 *GNU*)
3581 ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
3582 *)
3583 ac_count=0
3584 $as_echo_n 0123456789 >"conftest.in"
3585 while :
3586 do
3587 cat "conftest.in" "conftest.in" >"conftest.tmp"
3588 mv "conftest.tmp" "conftest.in"
3589 cp "conftest.in" "conftest.nl"
3590 $as_echo 'FGREP' >> "conftest.nl"
3591 "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
3592 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3593 as_fn_arith $ac_count + 1 && ac_count=$as_val
3594 if test $ac_count -gt ${ac_path_FGREP_max-0}; then
3595 # Best one so far, save it but keep looking for a better one
3596 ac_cv_path_FGREP="$ac_path_FGREP"
3597 ac_path_FGREP_max=$ac_count
3598 fi
3599 # 10*(2^10) chars as input seems more than enough
3600 test $ac_count -gt 10 && break
3601 done
3602 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3603 esac
3604
3605 $ac_path_FGREP_found && break 3
3606 done
3607 done
3608 done
3609 IFS=$as_save_IFS
3610 if test -z "$ac_cv_path_FGREP"; then
3611 as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3612 fi
3613 else
3614 ac_cv_path_FGREP=$FGREP
3615 fi
3616
3617 fi
3618 fi
3619 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
3620 $as_echo "$ac_cv_path_FGREP" >&6; }
3621 FGREP="$ac_cv_path_FGREP"
3622
3623
3624 test -z "$GREP" && GREP=grep
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644 # Check whether --with-gnu-ld was given.
3645 if test "${with_gnu_ld+set}" = set; then :
3646 withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
3647 else
3648 with_gnu_ld=no
3649 fi
3650
3651 ac_prog=ld
3652 if test "$GCC" = yes; then
3653 # Check if gcc -print-prog-name=ld gives a path.
3654 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
3655 $as_echo_n "checking for ld used by $CC... " >&6; }
3656 case $host in
3657 *-*-mingw*)
3658 # gcc leaves a trailing carriage return which upsets mingw
3659 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
3660 *)
3661 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
3662 esac
3663 case $ac_prog in
3664 # Accept absolute paths.
3665 [\\/]* | ?:[\\/]*)
3666 re_direlt='/[^/][^/]*/\.\./'
3667 # Canonicalize the pathname of ld
3668 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
3669 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
3670 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
3671 done
3672 test -z "$LD" && LD="$ac_prog"
3673 ;;
3674 "")
3675 # If it fails, then pretend we aren't using GCC.
3676 ac_prog=ld
3677 ;;
3678 *)
3679 # If it is relative, then search for the first ld in PATH.
3680 with_gnu_ld=unknown
3681 ;;
3682 esac
3683 elif test "$with_gnu_ld" = yes; then
3684 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
3685 $as_echo_n "checking for GNU ld... " >&6; }
3686 else
3687 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
3688 $as_echo_n "checking for non-GNU ld... " >&6; }
3689 fi
3690 if ${lt_cv_path_LD+:} false; then :
3691 $as_echo_n "(cached) " >&6
3692 else
3693 if test -z "$LD"; then
3694 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3695 for ac_dir in $PATH; do
3696 IFS="$lt_save_ifs"
3697 test -z "$ac_dir" && ac_dir=.
3698 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
3699 lt_cv_path_LD="$ac_dir/$ac_prog"
3700 # Check to see if the program is GNU ld. I'd rather use --version,
3701 # but apparently some variants of GNU ld only accept -v.
3702 # Break only if it was the GNU/non-GNU ld that we prefer.
3703 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
3704 *GNU* | *'with BFD'*)
3705 test "$with_gnu_ld" != no && break
3706 ;;
3707 *)
3708 test "$with_gnu_ld" != yes && break
3709 ;;
3710 esac
3711 fi
3712 done
3713 IFS="$lt_save_ifs"
3714 else
3715 lt_cv_path_LD="$LD" # Let the user override the test with a path.
3716 fi
3717 fi
3718
3719 LD="$lt_cv_path_LD"
3720 if test -n "$LD"; then
3721 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
3722 $as_echo "$LD" >&6; }
3723 else
3724 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3725 $as_echo "no" >&6; }
3726 fi
3727 test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
3728 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
3729 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
3730 if ${lt_cv_prog_gnu_ld+:} false; then :
3731 $as_echo_n "(cached) " >&6
3732 else
3733 # I'd rather use --version here, but apparently some GNU lds only accept -v.
3734 case `$LD -v 2>&1 </dev/null` in
3735 *GNU* | *'with BFD'*)
3736 lt_cv_prog_gnu_ld=yes
3737 ;;
3738 *)
3739 lt_cv_prog_gnu_ld=no
3740 ;;
3741 esac
3742 fi
3743 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
3744 $as_echo "$lt_cv_prog_gnu_ld" >&6; }
3745 with_gnu_ld=$lt_cv_prog_gnu_ld
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
3756 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
3757 if ${lt_cv_path_NM+:} false; then :
3758 $as_echo_n "(cached) " >&6
3759 else
3760 if test -n "$NM"; then
3761 # Let the user override the test.
3762 lt_cv_path_NM="$NM"
3763 else
3764 lt_nm_to_check="${ac_tool_prefix}nm"
3765 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
3766 lt_nm_to_check="$lt_nm_to_check nm"
3767 fi
3768 for lt_tmp_nm in $lt_nm_to_check; do
3769 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3770 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
3771 IFS="$lt_save_ifs"
3772 test -z "$ac_dir" && ac_dir=.
3773 tmp_nm="$ac_dir/$lt_tmp_nm"
3774 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
3775 # Check to see if the nm accepts a BSD-compat flag.
3776 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
3777 # nm: unknown option "B" ignored
3778 # Tru64's nm complains that /dev/null is an invalid object file
3779 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
3780 */dev/null* | *'Invalid file or object type'*)
3781 lt_cv_path_NM="$tmp_nm -B"
3782 break
3783 ;;
3784 *)
3785 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
3786 */dev/null*)
3787 lt_cv_path_NM="$tmp_nm -p"
3788 break
3789 ;;
3790 *)
3791 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
3792 continue # so that we can try to find one that supports BSD flags
3793 ;;
3794 esac
3795 ;;
3796 esac
3797 fi
3798 done
3799 IFS="$lt_save_ifs"
3800 done
3801 : ${lt_cv_path_NM=no}
3802 fi
3803 fi
3804 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
3805 $as_echo "$lt_cv_path_NM" >&6; }
3806 if test "$lt_cv_path_NM" != "no"; then
3807 NM="$lt_cv_path_NM"
3808 else
3809 # Didn't find any BSD compatible name lister, look for dumpbin.
3810 if test -n "$ac_tool_prefix"; then
3811 for ac_prog in "dumpbin -symbols" "link -dump -symbols"
3812 do
3813 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
3814 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
3815 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3816 $as_echo_n "checking for $ac_word... " >&6; }
3817 if ${ac_cv_prog_DUMPBIN+:} false; then :
3818 $as_echo_n "(cached) " >&6
3819 else
3820 if test -n "$DUMPBIN"; then
3821 ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
3822 else
3823 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3824 for as_dir in $PATH
3825 do
3826 IFS=$as_save_IFS
3827 test -z "$as_dir" && as_dir=.
3828 for ac_exec_ext in '' $ac_executable_extensions; do
3829 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3830 ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
3831 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3832 break 2
3833 fi
3834 done
3835 done
3836 IFS=$as_save_IFS
3837
3838 fi
3839 fi
3840 DUMPBIN=$ac_cv_prog_DUMPBIN
3841 if test -n "$DUMPBIN"; then
3842 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
3843 $as_echo "$DUMPBIN" >&6; }
3844 else
3845 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3846 $as_echo "no" >&6; }
3847 fi
3848
3849
3850 test -n "$DUMPBIN" && break
3851 done
3852 fi
3853 if test -z "$DUMPBIN"; then
3854 ac_ct_DUMPBIN=$DUMPBIN
3855 for ac_prog in "dumpbin -symbols" "link -dump -symbols"
3856 do
3857 # Extract the first word of "$ac_prog", so it can be a program name with args.
3858 set dummy $ac_prog; ac_word=$2
3859 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3860 $as_echo_n "checking for $ac_word... " >&6; }
3861 if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
3862 $as_echo_n "(cached) " >&6
3863 else
3864 if test -n "$ac_ct_DUMPBIN"; then
3865 ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
3866 else
3867 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3868 for as_dir in $PATH
3869 do
3870 IFS=$as_save_IFS
3871 test -z "$as_dir" && as_dir=.
3872 for ac_exec_ext in '' $ac_executable_extensions; do
3873 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3874 ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
3875 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3876 break 2
3877 fi
3878 done
3879 done
3880 IFS=$as_save_IFS
3881
3882 fi
3883 fi
3884 ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
3885 if test -n "$ac_ct_DUMPBIN"; then
3886 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
3887 $as_echo "$ac_ct_DUMPBIN" >&6; }
3888 else
3889 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3890 $as_echo "no" >&6; }
3891 fi
3892
3893
3894 test -n "$ac_ct_DUMPBIN" && break
3895 done
3896
3897 if test "x$ac_ct_DUMPBIN" = x; then
3898 DUMPBIN=":"
3899 else
3900 case $cross_compiling:$ac_tool_warned in
3901 yes:)
3902 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
3903 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
3904 ac_tool_warned=yes ;;
3905 esac
3906 DUMPBIN=$ac_ct_DUMPBIN
3907 fi
3908 fi
3909
3910
3911 if test "$DUMPBIN" != ":"; then
3912 NM="$DUMPBIN"
3913 fi
3914 fi
3915 test -z "$NM" && NM=nm
3916
3917
3918
3919
3920
3921
3922 { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
3923 $as_echo_n "checking the name lister ($NM) interface... " >&6; }
3924 if ${lt_cv_nm_interface+:} false; then :
3925 $as_echo_n "(cached) " >&6
3926 else
3927 lt_cv_nm_interface="BSD nm"
3928 echo "int some_variable = 0;" > conftest.$ac_ext
3929 (eval echo "\"\$as_me:3930: $ac_compile\"" >&5)
3930 (eval "$ac_compile" 2>conftest.err)
3931 cat conftest.err >&5
3932 (eval echo "\"\$as_me:3933: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
3933 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
3934 cat conftest.err >&5
3935 (eval echo "\"\$as_me:3936: output\"" >&5)
3936 cat conftest.out >&5
3937 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
3938 lt_cv_nm_interface="MS dumpbin"
3939 fi
3940 rm -f conftest*
3941 fi
3942 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
3943 $as_echo "$lt_cv_nm_interface" >&6; }
3944
3945 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
3946 $as_echo_n "checking whether ln -s works... " >&6; }
3947 LN_S=$as_ln_s
3948 if test "$LN_S" = "ln -s"; then
3949 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3950 $as_echo "yes" >&6; }
3951 else
3952 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
3953 $as_echo "no, using $LN_S" >&6; }
3954 fi
3955
3956 # find the maximum length of command line arguments
3957 { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
3958 $as_echo_n "checking the maximum length of command line arguments... " >&6; }
3959 if ${lt_cv_sys_max_cmd_len+:} false; then :
3960 $as_echo_n "(cached) " >&6
3961 else
3962 i=0
3963 teststring="ABCD"
3964
3965 case $build_os in
3966 msdosdjgpp*)
3967 # On DJGPP, this test can blow up pretty badly due to problems in libc
3968 # (any single argument exceeding 2000 bytes causes a buffer overrun
3969 # during glob expansion). Even if it were fixed, the result of this
3970 # check would be larger than it should be.
3971 lt_cv_sys_max_cmd_len=12288; # 12K is about right
3972 ;;
3973
3974 gnu*)
3975 # Under GNU Hurd, this test is not required because there is
3976 # no limit to the length of command line arguments.
3977 # Libtool will interpret -1 as no limit whatsoever
3978 lt_cv_sys_max_cmd_len=-1;
3979 ;;
3980
3981 cygwin* | mingw* | cegcc*)
3982 # On Win9x/ME, this test blows up -- it succeeds, but takes
3983 # about 5 minutes as the teststring grows exponentially.
3984 # Worse, since 9x/ME are not pre-emptively multitasking,
3985 # you end up with a "frozen" computer, even though with patience
3986 # the test eventually succeeds (with a max line length of 256k).
3987 # Instead, let's just punt: use the minimum linelength reported by
3988 # all of the supported platforms: 8192 (on NT/2K/XP).
3989 lt_cv_sys_max_cmd_len=8192;
3990 ;;
3991
3992 beos*)
3993 # On BeOS, this test takes a really really long time.
3994 # So we just punt and use a minimum line length of 8192.
3995 lt_cv_sys_max_cmd_len=8192;
3996 ;;
3997
3998 amigaos*)
3999 # On AmigaOS with pdksh, this test takes hours, literally.
4000 # So we just punt and use a minimum line length of 8192.
4001 lt_cv_sys_max_cmd_len=8192;
4002 ;;
4003
4004 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
4005 # This has been around since 386BSD, at least. Likely further.
4006 if test -x /sbin/sysctl; then
4007 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
4008 elif test -x /usr/sbin/sysctl; then
4009 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
4010 else
4011 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
4012 fi
4013 # And add a safety zone
4014 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4015 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4016 ;;
4017
4018 interix*)
4019 # We know the value 262144 and hardcode it with a safety zone (like BSD)
4020 lt_cv_sys_max_cmd_len=196608
4021 ;;
4022
4023 osf*)
4024 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
4025 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
4026 # nice to cause kernel panics so lets avoid the loop below.
4027 # First set a reasonable default.
4028 lt_cv_sys_max_cmd_len=16384
4029 #
4030 if test -x /sbin/sysconfig; then
4031 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
4032 *1*) lt_cv_sys_max_cmd_len=-1 ;;
4033 esac
4034 fi
4035 ;;
4036 sco3.2v5*)
4037 lt_cv_sys_max_cmd_len=102400
4038 ;;
4039 sysv5* | sco5v6* | sysv4.2uw2*)
4040 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
4041 if test -n "$kargmax"; then
4042 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
4043 else
4044 lt_cv_sys_max_cmd_len=32768
4045 fi
4046 ;;
4047 *)
4048 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
4049 if test -n "$lt_cv_sys_max_cmd_len"; then
4050 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4051 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4052 else
4053 # Make teststring a little bigger before we do anything with it.
4054 # a 1K string should be a reasonable start.
4055 for i in 1 2 3 4 5 6 7 8 ; do
4056 teststring=$teststring$teststring
4057 done
4058 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
4059 # If test is not a shell built-in, we'll probably end up computing a
4060 # maximum length that is only half of the actual maximum length, but
4061 # we can't tell.
4062 while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
4063 = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
4064 test $i != 17 # 1/2 MB should be enough
4065 do
4066 i=`expr $i + 1`
4067 teststring=$teststring$teststring
4068 done
4069 # Only check the string length outside the loop.
4070 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
4071 teststring=
4072 # Add a significant safety factor because C++ compilers can tack on
4073 # massive amounts of additional arguments before passing them to the
4074 # linker. It appears as though 1/2 is a usable value.
4075 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
4076 fi
4077 ;;
4078 esac
4079
4080 fi
4081
4082 if test -n $lt_cv_sys_max_cmd_len ; then
4083 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
4084 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
4085 else
4086 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
4087 $as_echo "none" >&6; }
4088 fi
4089 max_cmd_len=$lt_cv_sys_max_cmd_len
4090
4091
4092
4093
4094
4095
4096 : ${CP="cp -f"}
4097 : ${MV="mv -f"}
4098 : ${RM="rm -f"}
4099
4100 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
4101 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
4102 # Try some XSI features
4103 xsi_shell=no
4104 ( _lt_dummy="a/b/c"
4105 test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
4106 = c,a/b,, \
4107 && eval 'test $(( 1 + 1 )) -eq 2 \
4108 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
4109 && xsi_shell=yes
4110 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
4111 $as_echo "$xsi_shell" >&6; }
4112
4113
4114 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
4115 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
4116 lt_shell_append=no
4117 ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
4118 >/dev/null 2>&1 \
4119 && lt_shell_append=yes
4120 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
4121 $as_echo "$lt_shell_append" >&6; }
4122
4123
4124 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
4125 lt_unset=unset
4126 else
4127 lt_unset=false
4128 fi
4129
4130
4131
4132
4133
4134 # test EBCDIC or ASCII
4135 case `echo X|tr X '\101'` in
4136 A) # ASCII based system
4137 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
4138 lt_SP2NL='tr \040 \012'
4139 lt_NL2SP='tr \015\012 \040\040'
4140 ;;
4141 *) # EBCDIC based system
4142 lt_SP2NL='tr \100 \n'
4143 lt_NL2SP='tr \r\n \100\100'
4144 ;;
4145 esac
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
4156 $as_echo_n "checking for $LD option to reload object files... " >&6; }
4157 if ${lt_cv_ld_reload_flag+:} false; then :
4158 $as_echo_n "(cached) " >&6
4159 else
4160 lt_cv_ld_reload_flag='-r'
4161 fi
4162 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
4163 $as_echo "$lt_cv_ld_reload_flag" >&6; }
4164 reload_flag=$lt_cv_ld_reload_flag
4165 case $reload_flag in
4166 "" | " "*) ;;
4167 *) reload_flag=" $reload_flag" ;;
4168 esac
4169 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4170 case $host_os in
4171 darwin*)
4172 if test "$GCC" = yes; then
4173 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
4174 else
4175 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4176 fi
4177 ;;
4178 esac
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188 if test -n "$ac_tool_prefix"; then
4189 # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
4190 set dummy ${ac_tool_prefix}objdump; ac_word=$2
4191 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4192 $as_echo_n "checking for $ac_word... " >&6; }
4193 if ${ac_cv_prog_OBJDUMP+:} false; then :
4194 $as_echo_n "(cached) " >&6
4195 else
4196 if test -n "$OBJDUMP"; then
4197 ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
4198 else
4199 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4200 for as_dir in $PATH
4201 do
4202 IFS=$as_save_IFS
4203 test -z "$as_dir" && as_dir=.
4204 for ac_exec_ext in '' $ac_executable_extensions; do
4205 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4206 ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
4207 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4208 break 2
4209 fi
4210 done
4211 done
4212 IFS=$as_save_IFS
4213
4214 fi
4215 fi
4216 OBJDUMP=$ac_cv_prog_OBJDUMP
4217 if test -n "$OBJDUMP"; then
4218 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
4219 $as_echo "$OBJDUMP" >&6; }
4220 else
4221 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4222 $as_echo "no" >&6; }
4223 fi
4224
4225
4226 fi
4227 if test -z "$ac_cv_prog_OBJDUMP"; then
4228 ac_ct_OBJDUMP=$OBJDUMP
4229 # Extract the first word of "objdump", so it can be a program name with args.
4230 set dummy objdump; ac_word=$2
4231 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4232 $as_echo_n "checking for $ac_word... " >&6; }
4233 if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
4234 $as_echo_n "(cached) " >&6
4235 else
4236 if test -n "$ac_ct_OBJDUMP"; then
4237 ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
4238 else
4239 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4240 for as_dir in $PATH
4241 do
4242 IFS=$as_save_IFS
4243 test -z "$as_dir" && as_dir=.
4244 for ac_exec_ext in '' $ac_executable_extensions; do
4245 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4246 ac_cv_prog_ac_ct_OBJDUMP="objdump"
4247 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4248 break 2
4249 fi
4250 done
4251 done
4252 IFS=$as_save_IFS
4253
4254 fi
4255 fi
4256 ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
4257 if test -n "$ac_ct_OBJDUMP"; then
4258 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
4259 $as_echo "$ac_ct_OBJDUMP" >&6; }
4260 else
4261 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4262 $as_echo "no" >&6; }
4263 fi
4264
4265 if test "x$ac_ct_OBJDUMP" = x; then
4266 OBJDUMP="false"
4267 else
4268 case $cross_compiling:$ac_tool_warned in
4269 yes:)
4270 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4271 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4272 ac_tool_warned=yes ;;
4273 esac
4274 OBJDUMP=$ac_ct_OBJDUMP
4275 fi
4276 else
4277 OBJDUMP="$ac_cv_prog_OBJDUMP"
4278 fi
4279
4280 test -z "$OBJDUMP" && OBJDUMP=objdump
4281
4282
4283
4284
4285
4286
4287 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
4288 $as_echo_n "checking how to recognize dependent libraries... " >&6; }
4289 if ${lt_cv_deplibs_check_method+:} false; then :
4290 $as_echo_n "(cached) " >&6
4291 else
4292 lt_cv_file_magic_cmd='$MAGIC_CMD'
4293 lt_cv_file_magic_test_file=
4294 lt_cv_deplibs_check_method='unknown'
4295 # Need to set the preceding variable on all platforms that support
4296 # interlibrary dependencies.
4297 # 'none' -- dependencies not supported.
4298 # `unknown' -- same as none, but documents that we really don't know.
4299 # 'pass_all' -- all dependencies passed with no checks.
4300 # 'test_compile' -- check by making test program.
4301 # 'file_magic [[regex]]' -- check by looking for files in library path
4302 # which responds to the $file_magic_cmd with a given extended regex.
4303 # If you have `file' or equivalent on your system and you're not sure
4304 # whether `pass_all' will *always* work, you probably want this one.
4305
4306 case $host_os in
4307 aix[4-9]*)
4308 lt_cv_deplibs_check_method=pass_all
4309 ;;
4310
4311 beos*)
4312 lt_cv_deplibs_check_method=pass_all
4313 ;;
4314
4315 bsdi[45]*)
4316 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
4317 lt_cv_file_magic_cmd='/usr/bin/file -L'
4318 lt_cv_file_magic_test_file=/shlib/libc.so
4319 ;;
4320
4321 cygwin*)
4322 # func_win32_libid is a shell function defined in ltmain.sh
4323 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4324 lt_cv_deplibs_check_method=pass_all
4325 lt_cv_file_magic_cmd='func_win32_libid'
4326 ;;
4327
4328 mingw* | pw32*)
4329 # Base MSYS/MinGW do not provide the 'file' command needed by
4330 # func_win32_libid shell function, so use a weaker test based on 'objdump',
4331 # unless we find 'file', for example because we are cross-compiling.
4332 if ( file / ) >/dev/null 2>&1; then
4333 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4334 lt_cv_file_magic_cmd='func_win32_libid'
4335 else
4336 lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
4337 lt_cv_file_magic_cmd='$OBJDUMP -f'
4338 fi
4339 lt_cv_deplibs_check_method=pass_all
4340 ;;
4341
4342 cegcc)
4343 # use the weaker test based on 'objdump'. See mingw*.
4344 lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
4345 lt_cv_file_magic_cmd='$OBJDUMP -f'
4346 ;;
4347
4348 darwin* | rhapsody*)
4349 lt_cv_deplibs_check_method=pass_all
4350 ;;
4351
4352 freebsd* | dragonfly*)
4353 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4354 case $host_cpu in
4355 i*86 )
4356 # Not sure whether the presence of OpenBSD here was a mistake.
4357 # Let's accept both of them until this is cleared up.
4358 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
4359 lt_cv_file_magic_cmd=/usr/bin/file
4360 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
4361 ;;
4362 esac
4363 else
4364 lt_cv_deplibs_check_method=pass_all
4365 fi
4366 ;;
4367
4368 gnu*)
4369 lt_cv_deplibs_check_method=pass_all
4370 ;;
4371
4372 hpux10.20* | hpux11*)
4373 lt_cv_file_magic_cmd=/usr/bin/file
4374 case $host_cpu in
4375 ia64*)
4376 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
4377 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
4378 ;;
4379 hppa*64*)
4380 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]'
4381 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
4382 ;;
4383 *)
4384 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
4385 lt_cv_file_magic_test_file=/usr/lib/libc.sl
4386 ;;
4387 esac
4388 ;;
4389
4390 interix[3-9]*)
4391 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
4392 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
4393 ;;
4394
4395 irix5* | irix6* | nonstopux*)
4396 case $LD in
4397 *-32|*"-32 ") libmagic=32-bit;;
4398 *-n32|*"-n32 ") libmagic=N32;;
4399 *-64|*"-64 ") libmagic=64-bit;;
4400 *) libmagic=never-match;;
4401 esac
4402 lt_cv_deplibs_check_method=pass_all
4403 ;;
4404
4405 # This must be Linux ELF.
4406 linux* | k*bsd*-gnu)
4407 lt_cv_deplibs_check_method=pass_all
4408 ;;
4409
4410 netbsd*)
4411 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4412 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4413 else
4414 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
4415 fi
4416 ;;
4417
4418 newos6*)
4419 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
4420 lt_cv_file_magic_cmd=/usr/bin/file
4421 lt_cv_file_magic_test_file=/usr/lib/libnls.so
4422 ;;
4423
4424 *nto* | *qnx*)
4425 lt_cv_deplibs_check_method=pass_all
4426 ;;
4427
4428 openbsd*)
4429 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4430 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
4431 else
4432 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4433 fi
4434 ;;
4435
4436 osf3* | osf4* | osf5*)
4437 lt_cv_deplibs_check_method=pass_all
4438 ;;
4439
4440 rdos*)
4441 lt_cv_deplibs_check_method=pass_all
4442 ;;
4443
4444 solaris*)
4445 lt_cv_deplibs_check_method=pass_all
4446 ;;
4447
4448 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
4449 lt_cv_deplibs_check_method=pass_all
4450 ;;
4451
4452 sysv4 | sysv4.3*)
4453 case $host_vendor in
4454 motorola)
4455 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]'
4456 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
4457 ;;
4458 ncr)
4459 lt_cv_deplibs_check_method=pass_all
4460 ;;
4461 sequent)
4462 lt_cv_file_magic_cmd='/bin/file'
4463 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
4464 ;;
4465 sni)
4466 lt_cv_file_magic_cmd='/bin/file'
4467 lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
4468 lt_cv_file_magic_test_file=/lib/libc.so
4469 ;;
4470 siemens)
4471 lt_cv_deplibs_check_method=pass_all
4472 ;;
4473 pc)
4474 lt_cv_deplibs_check_method=pass_all
4475 ;;
4476 esac
4477 ;;
4478
4479 tpf*)
4480 lt_cv_deplibs_check_method=pass_all
4481 ;;
4482 esac
4483
4484 fi
4485 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
4486 $as_echo "$lt_cv_deplibs_check_method" >&6; }
4487 file_magic_cmd=$lt_cv_file_magic_cmd
4488 deplibs_check_method=$lt_cv_deplibs_check_method
4489 test -z "$deplibs_check_method" && deplibs_check_method=unknown
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502 if test -n "$ac_tool_prefix"; then
4503 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
4504 set dummy ${ac_tool_prefix}ar; ac_word=$2
4505 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4506 $as_echo_n "checking for $ac_word... " >&6; }
4507 if ${ac_cv_prog_AR+:} false; then :
4508 $as_echo_n "(cached) " >&6
4509 else
4510 if test -n "$AR"; then
4511 ac_cv_prog_AR="$AR" # Let the user override the test.
4512 else
4513 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4514 for as_dir in $PATH
4515 do
4516 IFS=$as_save_IFS
4517 test -z "$as_dir" && as_dir=.
4518 for ac_exec_ext in '' $ac_executable_extensions; do
4519 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4520 ac_cv_prog_AR="${ac_tool_prefix}ar"
4521 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4522 break 2
4523 fi
4524 done
4525 done
4526 IFS=$as_save_IFS
4527
4528 fi
4529 fi
4530 AR=$ac_cv_prog_AR
4531 if test -n "$AR"; then
4532 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
4533 $as_echo "$AR" >&6; }
4534 else
4535 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4536 $as_echo "no" >&6; }
4537 fi
4538
4539
4540 fi
4541 if test -z "$ac_cv_prog_AR"; then
4542 ac_ct_AR=$AR
4543 # Extract the first word of "ar", so it can be a program name with args.
4544 set dummy ar; ac_word=$2
4545 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4546 $as_echo_n "checking for $ac_word... " >&6; }
4547 if ${ac_cv_prog_ac_ct_AR+:} false; then :
4548 $as_echo_n "(cached) " >&6
4549 else
4550 if test -n "$ac_ct_AR"; then
4551 ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
4552 else
4553 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4554 for as_dir in $PATH
4555 do
4556 IFS=$as_save_IFS
4557 test -z "$as_dir" && as_dir=.
4558 for ac_exec_ext in '' $ac_executable_extensions; do
4559 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4560 ac_cv_prog_ac_ct_AR="ar"
4561 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4562 break 2
4563 fi
4564 done
4565 done
4566 IFS=$as_save_IFS
4567
4568 fi
4569 fi
4570 ac_ct_AR=$ac_cv_prog_ac_ct_AR
4571 if test -n "$ac_ct_AR"; then
4572 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
4573 $as_echo "$ac_ct_AR" >&6; }
4574 else
4575 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4576 $as_echo "no" >&6; }
4577 fi
4578
4579 if test "x$ac_ct_AR" = x; then
4580 AR="false"
4581 else
4582 case $cross_compiling:$ac_tool_warned in
4583 yes:)
4584 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4585 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4586 ac_tool_warned=yes ;;
4587 esac
4588 AR=$ac_ct_AR
4589 fi
4590 else
4591 AR="$ac_cv_prog_AR"
4592 fi
4593
4594 test -z "$AR" && AR=ar
4595 test -z "$AR_FLAGS" && AR_FLAGS=cru
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607 if test -n "$ac_tool_prefix"; then
4608 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
4609 set dummy ${ac_tool_prefix}strip; ac_word=$2
4610 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4611 $as_echo_n "checking for $ac_word... " >&6; }
4612 if ${ac_cv_prog_STRIP+:} false; then :
4613 $as_echo_n "(cached) " >&6
4614 else
4615 if test -n "$STRIP"; then
4616 ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
4617 else
4618 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4619 for as_dir in $PATH
4620 do
4621 IFS=$as_save_IFS
4622 test -z "$as_dir" && as_dir=.
4623 for ac_exec_ext in '' $ac_executable_extensions; do
4624 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4625 ac_cv_prog_STRIP="${ac_tool_prefix}strip"
4626 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4627 break 2
4628 fi
4629 done
4630 done
4631 IFS=$as_save_IFS
4632
4633 fi
4634 fi
4635 STRIP=$ac_cv_prog_STRIP
4636 if test -n "$STRIP"; then
4637 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
4638 $as_echo "$STRIP" >&6; }
4639 else
4640 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4641 $as_echo "no" >&6; }
4642 fi
4643
4644
4645 fi
4646 if test -z "$ac_cv_prog_STRIP"; then
4647 ac_ct_STRIP=$STRIP
4648 # Extract the first word of "strip", so it can be a program name with args.
4649 set dummy strip; ac_word=$2
4650 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4651 $as_echo_n "checking for $ac_word... " >&6; }
4652 if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
4653 $as_echo_n "(cached) " >&6
4654 else
4655 if test -n "$ac_ct_STRIP"; then
4656 ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
4657 else
4658 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4659 for as_dir in $PATH
4660 do
4661 IFS=$as_save_IFS
4662 test -z "$as_dir" && as_dir=.
4663 for ac_exec_ext in '' $ac_executable_extensions; do
4664 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4665 ac_cv_prog_ac_ct_STRIP="strip"
4666 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4667 break 2
4668 fi
4669 done
4670 done
4671 IFS=$as_save_IFS
4672
4673 fi
4674 fi
4675 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
4676 if test -n "$ac_ct_STRIP"; then
4677 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
4678 $as_echo "$ac_ct_STRIP" >&6; }
4679 else
4680 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4681 $as_echo "no" >&6; }
4682 fi
4683
4684 if test "x$ac_ct_STRIP" = x; then
4685 STRIP=":"
4686 else
4687 case $cross_compiling:$ac_tool_warned in
4688 yes:)
4689 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4690 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4691 ac_tool_warned=yes ;;
4692 esac
4693 STRIP=$ac_ct_STRIP
4694 fi
4695 else
4696 STRIP="$ac_cv_prog_STRIP"
4697 fi
4698
4699 test -z "$STRIP" && STRIP=:
4700
4701
4702
4703
4704
4705
4706 if test -n "$ac_tool_prefix"; then
4707 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
4708 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
4709 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4710 $as_echo_n "checking for $ac_word... " >&6; }
4711 if ${ac_cv_prog_RANLIB+:} false; then :
4712 $as_echo_n "(cached) " >&6
4713 else
4714 if test -n "$RANLIB"; then
4715 ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
4716 else
4717 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4718 for as_dir in $PATH
4719 do
4720 IFS=$as_save_IFS
4721 test -z "$as_dir" && as_dir=.
4722 for ac_exec_ext in '' $ac_executable_extensions; do
4723 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4724 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
4725 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4726 break 2
4727 fi
4728 done
4729 done
4730 IFS=$as_save_IFS
4731
4732 fi
4733 fi
4734 RANLIB=$ac_cv_prog_RANLIB
4735 if test -n "$RANLIB"; then
4736 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
4737 $as_echo "$RANLIB" >&6; }
4738 else
4739 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4740 $as_echo "no" >&6; }
4741 fi
4742
4743
4744 fi
4745 if test -z "$ac_cv_prog_RANLIB"; then
4746 ac_ct_RANLIB=$RANLIB
4747 # Extract the first word of "ranlib", so it can be a program name with args.
4748 set dummy ranlib; ac_word=$2
4749 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4750 $as_echo_n "checking for $ac_word... " >&6; }
4751 if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
4752 $as_echo_n "(cached) " >&6
4753 else
4754 if test -n "$ac_ct_RANLIB"; then
4755 ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
4756 else
4757 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4758 for as_dir in $PATH
4759 do
4760 IFS=$as_save_IFS
4761 test -z "$as_dir" && as_dir=.
4762 for ac_exec_ext in '' $ac_executable_extensions; do
4763 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4764 ac_cv_prog_ac_ct_RANLIB="ranlib"
4765 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4766 break 2
4767 fi
4768 done
4769 done
4770 IFS=$as_save_IFS
4771
4772 fi
4773 fi
4774 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
4775 if test -n "$ac_ct_RANLIB"; then
4776 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
4777 $as_echo "$ac_ct_RANLIB" >&6; }
4778 else
4779 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4780 $as_echo "no" >&6; }
4781 fi
4782
4783 if test "x$ac_ct_RANLIB" = x; then
4784 RANLIB=":"
4785 else
4786 case $cross_compiling:$ac_tool_warned in
4787 yes:)
4788 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4789 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4790 ac_tool_warned=yes ;;
4791 esac
4792 RANLIB=$ac_ct_RANLIB
4793 fi
4794 else
4795 RANLIB="$ac_cv_prog_RANLIB"
4796 fi
4797
4798 test -z "$RANLIB" && RANLIB=:
4799
4800
4801
4802
4803
4804
4805 # Determine commands to create old-style static archives.
4806 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
4807 old_postinstall_cmds='chmod 644 $oldlib'
4808 old_postuninstall_cmds=
4809
4810 if test -n "$RANLIB"; then
4811 case $host_os in
4812 openbsd*)
4813 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
4814 ;;
4815 *)
4816 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
4817 ;;
4818 esac
4819 old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
4820 fi
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855 # If no C compiler was specified, use CC.
4856 LTCC=${LTCC-"$CC"}
4857
4858 # If no C compiler flags were specified, use CFLAGS.
4859 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
4860
4861 # Allow CC to be a program name with arguments.
4862 compiler=$CC
4863
4864
4865 # Check for command to grab the raw symbol name followed by C symbol from nm.
4866 { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
4867 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
4868 if ${lt_cv_sys_global_symbol_pipe+:} false; then :
4869 $as_echo_n "(cached) " >&6
4870 else
4871
4872 # These are sane defaults that work on at least a few old systems.
4873 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
4874
4875 # Character class describing NM global symbol codes.
4876 symcode='[BCDEGRST]'
4877
4878 # Regexp to match symbols that can be accessed directly from C.
4879 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
4880
4881 # Define system-specific variables.
4882 case $host_os in
4883 aix*)
4884 symcode='[BCDT]'
4885 ;;
4886 cygwin* | mingw* | pw32* | cegcc*)
4887 symcode='[ABCDGISTW]'
4888 ;;
4889 hpux*)
4890 if test "$host_cpu" = ia64; then
4891 symcode='[ABCDEGRST]'
4892 fi
4893 ;;
4894 irix* | nonstopux*)
4895 symcode='[BCDEGRST]'
4896 ;;
4897 osf*)
4898 symcode='[BCDEGQRST]'
4899 ;;
4900 solaris*)
4901 symcode='[BDRT]'
4902 ;;
4903 sco3.2v5*)
4904 symcode='[DT]'
4905 ;;
4906 sysv4.2uw2*)
4907 symcode='[DT]'
4908 ;;
4909 sysv5* | sco5v6* | unixware* | OpenUNIX*)
4910 symcode='[ABDT]'
4911 ;;
4912 sysv4)
4913 symcode='[DFNSTU]'
4914 ;;
4915 esac
4916
4917 # If we're using GNU nm, then use its standard symbol codes.
4918 case `$NM -V 2>&1` in
4919 *GNU* | *'with BFD'*)
4920 symcode='[ABCDGIRSTW]' ;;
4921 esac
4922
4923 # Transform an extracted symbol line into a proper C declaration.
4924 # Some systems (esp. on ia64) link data and code symbols differently,
4925 # so use this general approach.
4926 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
4927
4928 # Transform an extracted symbol line into symbol name and symbol address
4929 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
4930 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'"
4931
4932 # Handle CRLF in mingw tool chain
4933 opt_cr=
4934 case $build_os in
4935 mingw*)
4936 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
4937 ;;
4938 esac
4939
4940 # Try without a prefix underscore, then with it.
4941 for ac_symprfx in "" "_"; do
4942
4943 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
4944 symxfrm="\\1 $ac_symprfx\\2 \\2"
4945
4946 # Write the raw and C identifiers.
4947 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
4948 # Fake it for dumpbin and say T for any non-static function
4949 # and D for any global variable.
4950 # Also find C++ and __fastcall symbols from MSVC++,
4951 # which start with @ or ?.
4952 lt_cv_sys_global_symbol_pipe="$AWK '"\
4953 " {last_section=section; section=\$ 3};"\
4954 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
4955 " \$ 0!~/External *\|/{next};"\
4956 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
4957 " {if(hide[section]) next};"\
4958 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
4959 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
4960 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
4961 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
4962 " ' prfx=^$ac_symprfx"
4963 else
4964 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
4965 fi
4966
4967 # Check to see that the pipe works correctly.
4968 pipe_works=no
4969
4970 rm -f conftest*
4971 cat > conftest.$ac_ext <<_LT_EOF
4972 #ifdef __cplusplus
4973 extern "C" {
4974 #endif
4975 char nm_test_var;
4976 void nm_test_func(void);
4977 void nm_test_func(void){}
4978 #ifdef __cplusplus
4979 }
4980 #endif
4981 int main(){nm_test_var='a';nm_test_func();return(0);}
4982 _LT_EOF
4983
4984 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
4985 (eval $ac_compile) 2>&5
4986 ac_status=$?
4987 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4988 test $ac_status = 0; }; then
4989 # Now try to grab the symbols.
4990 nlist=conftest.nm
4991 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5
4992 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
4993 ac_status=$?
4994 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4995 test $ac_status = 0; } && test -s "$nlist"; then
4996 # Try sorting and uniquifying the output.
4997 if sort "$nlist" | uniq > "$nlist"T; then
4998 mv -f "$nlist"T "$nlist"
4999 else
5000 rm -f "$nlist"T
5001 fi
5002
5003 # Make sure that we snagged all the symbols we need.
5004 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
5005 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
5006 cat <<_LT_EOF > conftest.$ac_ext
5007 #ifdef __cplusplus
5008 extern "C" {
5009 #endif
5010
5011 _LT_EOF
5012 # Now generate the symbol file.
5013 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
5014
5015 cat <<_LT_EOF >> conftest.$ac_ext
5016
5017 /* The mapping between symbol names and symbols. */
5018 const struct {
5019 const char *name;
5020 void *address;
5021 }
5022 lt__PROGRAM__LTX_preloaded_symbols[] =
5023 {
5024 { "@PROGRAM@", (void *) 0 },
5025 _LT_EOF
5026 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
5027 cat <<\_LT_EOF >> conftest.$ac_ext
5028 {0, (void *) 0}
5029 };
5030
5031 /* This works around a problem in FreeBSD linker */
5032 #ifdef FREEBSD_WORKAROUND
5033 static const void *lt_preloaded_setup() {
5034 return lt__PROGRAM__LTX_preloaded_symbols;
5035 }
5036 #endif
5037
5038 #ifdef __cplusplus
5039 }
5040 #endif
5041 _LT_EOF
5042 # Now try linking the two files.
5043 mv conftest.$ac_objext conftstm.$ac_objext
5044 lt_save_LIBS="$LIBS"
5045 lt_save_CFLAGS="$CFLAGS"
5046 LIBS="conftstm.$ac_objext"
5047 CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
5048 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
5049 (eval $ac_link) 2>&5
5050 ac_status=$?
5051 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5052 test $ac_status = 0; } && test -s conftest${ac_exeext}; then
5053 pipe_works=yes
5054 fi
5055 LIBS="$lt_save_LIBS"
5056 CFLAGS="$lt_save_CFLAGS"
5057 else
5058 echo "cannot find nm_test_func in $nlist" >&5
5059 fi
5060 else
5061 echo "cannot find nm_test_var in $nlist" >&5
5062 fi
5063 else
5064 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
5065 fi
5066 else
5067 echo "$progname: failed program was:" >&5
5068 cat conftest.$ac_ext >&5
5069 fi
5070 rm -rf conftest* conftst*
5071
5072 # Do not use the global_symbol_pipe unless it works.
5073 if test "$pipe_works" = yes; then
5074 break
5075 else
5076 lt_cv_sys_global_symbol_pipe=
5077 fi
5078 done
5079
5080 fi
5081
5082 if test -z "$lt_cv_sys_global_symbol_pipe"; then
5083 lt_cv_sys_global_symbol_to_cdecl=
5084 fi
5085 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
5086 { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
5087 $as_echo "failed" >&6; }
5088 else
5089 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
5090 $as_echo "ok" >&6; }
5091 fi
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115 # Check whether --enable-libtool-lock was given.
5116 if test "${enable_libtool_lock+set}" = set; then :
5117 enableval=$enable_libtool_lock;
5118 fi
5119
5120 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
5121
5122 # Some flags need to be propagated to the compiler or linker for good
5123 # libtool support.
5124 case $host in
5125 ia64-*-hpux*)
5126 # Find out which ABI we are using.
5127 echo 'int i;' > conftest.$ac_ext
5128 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5129 (eval $ac_compile) 2>&5
5130 ac_status=$?
5131 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5132 test $ac_status = 0; }; then
5133 case `/usr/bin/file conftest.$ac_objext` in
5134 *ELF-32*)
5135 HPUX_IA64_MODE="32"
5136 ;;
5137 *ELF-64*)
5138 HPUX_IA64_MODE="64"
5139 ;;
5140 esac
5141 fi
5142 rm -rf conftest*
5143 ;;
5144 *-*-irix6*)
5145 # Find out which ABI we are using.
5146 echo '#line 5147 "configure"' > conftest.$ac_ext
5147 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5148 (eval $ac_compile) 2>&5
5149 ac_status=$?
5150 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5151 test $ac_status = 0; }; then
5152 if test "$lt_cv_prog_gnu_ld" = yes; then
5153 case `/usr/bin/file conftest.$ac_objext` in
5154 *32-bit*)
5155 LD="${LD-ld} -melf32bsmip"
5156 ;;
5157 *N32*)
5158 LD="${LD-ld} -melf32bmipn32"
5159 ;;
5160 *64-bit*)
5161 LD="${LD-ld} -melf64bmip"
5162 ;;
5163 esac
5164 else
5165 case `/usr/bin/file conftest.$ac_objext` in
5166 *32-bit*)
5167 LD="${LD-ld} -32"
5168 ;;
5169 *N32*)
5170 LD="${LD-ld} -n32"
5171 ;;
5172 *64-bit*)
5173 LD="${LD-ld} -64"
5174 ;;
5175 esac
5176 fi
5177 fi
5178 rm -rf conftest*
5179 ;;
5180
5181 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
5182 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
5183 # Find out which ABI we are using.
5184 echo 'int i;' > conftest.$ac_ext
5185 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5186 (eval $ac_compile) 2>&5
5187 ac_status=$?
5188 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5189 test $ac_status = 0; }; then
5190 case `/usr/bin/file conftest.o` in
5191 *32-bit*)
5192 case $host in
5193 x86_64-*kfreebsd*-gnu)
5194 LD="${LD-ld} -m elf_i386_fbsd"
5195 ;;
5196 x86_64-*linux*)
5197 LD="${LD-ld} -m elf_i386"
5198 ;;
5199 ppc64-*linux*|powerpc64-*linux*)
5200 LD="${LD-ld} -m elf32ppclinux"
5201 ;;
5202 s390x-*linux*)
5203 LD="${LD-ld} -m elf_s390"
5204 ;;
5205 sparc64-*linux*)
5206 LD="${LD-ld} -m elf32_sparc"
5207 ;;
5208 esac
5209 ;;
5210 *64-bit*)
5211 case $host in
5212 x86_64-*kfreebsd*-gnu)
5213 LD="${LD-ld} -m elf_x86_64_fbsd"
5214 ;;
5215 x86_64-*linux*)
5216 LD="${LD-ld} -m elf_x86_64"
5217 ;;
5218 powerpc64le-*linux*)
5219 LD="${LD-ld} -m elf64lppc"
5220 ;;
5221 powerpc64-*linux*)
5222 LD="${LD-ld} -m elf64ppc"
5223 ;;
5224 s390*-*linux*|s390*-*tpf*)
5225 LD="${LD-ld} -m elf64_s390"
5226 ;;
5227 sparc*-*linux*)
5228 LD="${LD-ld} -m elf64_sparc"
5229 ;;
5230 esac
5231 ;;
5232 esac
5233 fi
5234 rm -rf conftest*
5235 ;;
5236
5237 *-*-sco3.2v5*)
5238 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
5239 SAVE_CFLAGS="$CFLAGS"
5240 CFLAGS="$CFLAGS -belf"
5241 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
5242 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
5243 if ${lt_cv_cc_needs_belf+:} false; then :
5244 $as_echo_n "(cached) " >&6
5245 else
5246 ac_ext=c
5247 ac_cpp='$CPP $CPPFLAGS'
5248 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5249 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5250 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5251
5252 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5253 /* end confdefs.h. */
5254
5255 int
5256 main ()
5257 {
5258
5259 ;
5260 return 0;
5261 }
5262 _ACEOF
5263 if ac_fn_c_try_link "$LINENO"; then :
5264 lt_cv_cc_needs_belf=yes
5265 else
5266 lt_cv_cc_needs_belf=no
5267 fi
5268 rm -f core conftest.err conftest.$ac_objext \
5269 conftest$ac_exeext conftest.$ac_ext
5270 ac_ext=c
5271 ac_cpp='$CPP $CPPFLAGS'
5272 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5273 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5274 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5275
5276 fi
5277 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
5278 $as_echo "$lt_cv_cc_needs_belf" >&6; }
5279 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
5280 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
5281 CFLAGS="$SAVE_CFLAGS"
5282 fi
5283 ;;
5284 sparc*-*solaris*)
5285 # Find out which ABI we are using.
5286 echo 'int i;' > conftest.$ac_ext
5287 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5288 (eval $ac_compile) 2>&5
5289 ac_status=$?
5290 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5291 test $ac_status = 0; }; then
5292 case `/usr/bin/file conftest.o` in
5293 *64-bit*)
5294 case $lt_cv_prog_gnu_ld in
5295 yes*) LD="${LD-ld} -m elf64_sparc" ;;
5296 *)
5297 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
5298 LD="${LD-ld} -64"
5299 fi
5300 ;;
5301 esac
5302 ;;
5303 esac
5304 fi
5305 rm -rf conftest*
5306 ;;
5307 esac
5308
5309 need_locks="$enable_libtool_lock"
5310
5311
5312 case $host_os in
5313 rhapsody* | darwin*)
5314 if test -n "$ac_tool_prefix"; then
5315 # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
5316 set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
5317 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5318 $as_echo_n "checking for $ac_word... " >&6; }
5319 if ${ac_cv_prog_DSYMUTIL+:} false; then :
5320 $as_echo_n "(cached) " >&6
5321 else
5322 if test -n "$DSYMUTIL"; then
5323 ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
5324 else
5325 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5326 for as_dir in $PATH
5327 do
5328 IFS=$as_save_IFS
5329 test -z "$as_dir" && as_dir=.
5330 for ac_exec_ext in '' $ac_executable_extensions; do
5331 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5332 ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
5333 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5334 break 2
5335 fi
5336 done
5337 done
5338 IFS=$as_save_IFS
5339
5340 fi
5341 fi
5342 DSYMUTIL=$ac_cv_prog_DSYMUTIL
5343 if test -n "$DSYMUTIL"; then
5344 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
5345 $as_echo "$DSYMUTIL" >&6; }
5346 else
5347 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5348 $as_echo "no" >&6; }
5349 fi
5350
5351
5352 fi
5353 if test -z "$ac_cv_prog_DSYMUTIL"; then
5354 ac_ct_DSYMUTIL=$DSYMUTIL
5355 # Extract the first word of "dsymutil", so it can be a program name with args.
5356 set dummy dsymutil; ac_word=$2
5357 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5358 $as_echo_n "checking for $ac_word... " >&6; }
5359 if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
5360 $as_echo_n "(cached) " >&6
5361 else
5362 if test -n "$ac_ct_DSYMUTIL"; then
5363 ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
5364 else
5365 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5366 for as_dir in $PATH
5367 do
5368 IFS=$as_save_IFS
5369 test -z "$as_dir" && as_dir=.
5370 for ac_exec_ext in '' $ac_executable_extensions; do
5371 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5372 ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
5373 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5374 break 2
5375 fi
5376 done
5377 done
5378 IFS=$as_save_IFS
5379
5380 fi
5381 fi
5382 ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
5383 if test -n "$ac_ct_DSYMUTIL"; then
5384 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
5385 $as_echo "$ac_ct_DSYMUTIL" >&6; }
5386 else
5387 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5388 $as_echo "no" >&6; }
5389 fi
5390
5391 if test "x$ac_ct_DSYMUTIL" = x; then
5392 DSYMUTIL=":"
5393 else
5394 case $cross_compiling:$ac_tool_warned in
5395 yes:)
5396 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5397 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5398 ac_tool_warned=yes ;;
5399 esac
5400 DSYMUTIL=$ac_ct_DSYMUTIL
5401 fi
5402 else
5403 DSYMUTIL="$ac_cv_prog_DSYMUTIL"
5404 fi
5405
5406 if test -n "$ac_tool_prefix"; then
5407 # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
5408 set dummy ${ac_tool_prefix}nmedit; ac_word=$2
5409 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5410 $as_echo_n "checking for $ac_word... " >&6; }
5411 if ${ac_cv_prog_NMEDIT+:} false; then :
5412 $as_echo_n "(cached) " >&6
5413 else
5414 if test -n "$NMEDIT"; then
5415 ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
5416 else
5417 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5418 for as_dir in $PATH
5419 do
5420 IFS=$as_save_IFS
5421 test -z "$as_dir" && as_dir=.
5422 for ac_exec_ext in '' $ac_executable_extensions; do
5423 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5424 ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
5425 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5426 break 2
5427 fi
5428 done
5429 done
5430 IFS=$as_save_IFS
5431
5432 fi
5433 fi
5434 NMEDIT=$ac_cv_prog_NMEDIT
5435 if test -n "$NMEDIT"; then
5436 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
5437 $as_echo "$NMEDIT" >&6; }
5438 else
5439 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5440 $as_echo "no" >&6; }
5441 fi
5442
5443
5444 fi
5445 if test -z "$ac_cv_prog_NMEDIT"; then
5446 ac_ct_NMEDIT=$NMEDIT
5447 # Extract the first word of "nmedit", so it can be a program name with args.
5448 set dummy nmedit; ac_word=$2
5449 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5450 $as_echo_n "checking for $ac_word... " >&6; }
5451 if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
5452 $as_echo_n "(cached) " >&6
5453 else
5454 if test -n "$ac_ct_NMEDIT"; then
5455 ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
5456 else
5457 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5458 for as_dir in $PATH
5459 do
5460 IFS=$as_save_IFS
5461 test -z "$as_dir" && as_dir=.
5462 for ac_exec_ext in '' $ac_executable_extensions; do
5463 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5464 ac_cv_prog_ac_ct_NMEDIT="nmedit"
5465 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5466 break 2
5467 fi
5468 done
5469 done
5470 IFS=$as_save_IFS
5471
5472 fi
5473 fi
5474 ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
5475 if test -n "$ac_ct_NMEDIT"; then
5476 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
5477 $as_echo "$ac_ct_NMEDIT" >&6; }
5478 else
5479 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5480 $as_echo "no" >&6; }
5481 fi
5482
5483 if test "x$ac_ct_NMEDIT" = x; then
5484 NMEDIT=":"
5485 else
5486 case $cross_compiling:$ac_tool_warned in
5487 yes:)
5488 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5489 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5490 ac_tool_warned=yes ;;
5491 esac
5492 NMEDIT=$ac_ct_NMEDIT
5493 fi
5494 else
5495 NMEDIT="$ac_cv_prog_NMEDIT"
5496 fi
5497
5498 if test -n "$ac_tool_prefix"; then
5499 # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
5500 set dummy ${ac_tool_prefix}lipo; ac_word=$2
5501 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5502 $as_echo_n "checking for $ac_word... " >&6; }
5503 if ${ac_cv_prog_LIPO+:} false; then :
5504 $as_echo_n "(cached) " >&6
5505 else
5506 if test -n "$LIPO"; then
5507 ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
5508 else
5509 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5510 for as_dir in $PATH
5511 do
5512 IFS=$as_save_IFS
5513 test -z "$as_dir" && as_dir=.
5514 for ac_exec_ext in '' $ac_executable_extensions; do
5515 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5516 ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
5517 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5518 break 2
5519 fi
5520 done
5521 done
5522 IFS=$as_save_IFS
5523
5524 fi
5525 fi
5526 LIPO=$ac_cv_prog_LIPO
5527 if test -n "$LIPO"; then
5528 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
5529 $as_echo "$LIPO" >&6; }
5530 else
5531 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5532 $as_echo "no" >&6; }
5533 fi
5534
5535
5536 fi
5537 if test -z "$ac_cv_prog_LIPO"; then
5538 ac_ct_LIPO=$LIPO
5539 # Extract the first word of "lipo", so it can be a program name with args.
5540 set dummy lipo; ac_word=$2
5541 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5542 $as_echo_n "checking for $ac_word... " >&6; }
5543 if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
5544 $as_echo_n "(cached) " >&6
5545 else
5546 if test -n "$ac_ct_LIPO"; then
5547 ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
5548 else
5549 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5550 for as_dir in $PATH
5551 do
5552 IFS=$as_save_IFS
5553 test -z "$as_dir" && as_dir=.
5554 for ac_exec_ext in '' $ac_executable_extensions; do
5555 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5556 ac_cv_prog_ac_ct_LIPO="lipo"
5557 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5558 break 2
5559 fi
5560 done
5561 done
5562 IFS=$as_save_IFS
5563
5564 fi
5565 fi
5566 ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
5567 if test -n "$ac_ct_LIPO"; then
5568 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
5569 $as_echo "$ac_ct_LIPO" >&6; }
5570 else
5571 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5572 $as_echo "no" >&6; }
5573 fi
5574
5575 if test "x$ac_ct_LIPO" = x; then
5576 LIPO=":"
5577 else
5578 case $cross_compiling:$ac_tool_warned in
5579 yes:)
5580 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5581 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5582 ac_tool_warned=yes ;;
5583 esac
5584 LIPO=$ac_ct_LIPO
5585 fi
5586 else
5587 LIPO="$ac_cv_prog_LIPO"
5588 fi
5589
5590 if test -n "$ac_tool_prefix"; then
5591 # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
5592 set dummy ${ac_tool_prefix}otool; ac_word=$2
5593 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5594 $as_echo_n "checking for $ac_word... " >&6; }
5595 if ${ac_cv_prog_OTOOL+:} false; then :
5596 $as_echo_n "(cached) " >&6
5597 else
5598 if test -n "$OTOOL"; then
5599 ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
5600 else
5601 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5602 for as_dir in $PATH
5603 do
5604 IFS=$as_save_IFS
5605 test -z "$as_dir" && as_dir=.
5606 for ac_exec_ext in '' $ac_executable_extensions; do
5607 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5608 ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
5609 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5610 break 2
5611 fi
5612 done
5613 done
5614 IFS=$as_save_IFS
5615
5616 fi
5617 fi
5618 OTOOL=$ac_cv_prog_OTOOL
5619 if test -n "$OTOOL"; then
5620 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
5621 $as_echo "$OTOOL" >&6; }
5622 else
5623 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5624 $as_echo "no" >&6; }
5625 fi
5626
5627
5628 fi
5629 if test -z "$ac_cv_prog_OTOOL"; then
5630 ac_ct_OTOOL=$OTOOL
5631 # Extract the first word of "otool", so it can be a program name with args.
5632 set dummy otool; ac_word=$2
5633 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5634 $as_echo_n "checking for $ac_word... " >&6; }
5635 if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
5636 $as_echo_n "(cached) " >&6
5637 else
5638 if test -n "$ac_ct_OTOOL"; then
5639 ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
5640 else
5641 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5642 for as_dir in $PATH
5643 do
5644 IFS=$as_save_IFS
5645 test -z "$as_dir" && as_dir=.
5646 for ac_exec_ext in '' $ac_executable_extensions; do
5647 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5648 ac_cv_prog_ac_ct_OTOOL="otool"
5649 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5650 break 2
5651 fi
5652 done
5653 done
5654 IFS=$as_save_IFS
5655
5656 fi
5657 fi
5658 ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
5659 if test -n "$ac_ct_OTOOL"; then
5660 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
5661 $as_echo "$ac_ct_OTOOL" >&6; }
5662 else
5663 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5664 $as_echo "no" >&6; }
5665 fi
5666
5667 if test "x$ac_ct_OTOOL" = x; then
5668 OTOOL=":"
5669 else
5670 case $cross_compiling:$ac_tool_warned in
5671 yes:)
5672 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5673 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5674 ac_tool_warned=yes ;;
5675 esac
5676 OTOOL=$ac_ct_OTOOL
5677 fi
5678 else
5679 OTOOL="$ac_cv_prog_OTOOL"
5680 fi
5681
5682 if test -n "$ac_tool_prefix"; then
5683 # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
5684 set dummy ${ac_tool_prefix}otool64; ac_word=$2
5685 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5686 $as_echo_n "checking for $ac_word... " >&6; }
5687 if ${ac_cv_prog_OTOOL64+:} false; then :
5688 $as_echo_n "(cached) " >&6
5689 else
5690 if test -n "$OTOOL64"; then
5691 ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
5692 else
5693 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5694 for as_dir in $PATH
5695 do
5696 IFS=$as_save_IFS
5697 test -z "$as_dir" && as_dir=.
5698 for ac_exec_ext in '' $ac_executable_extensions; do
5699 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5700 ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
5701 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5702 break 2
5703 fi
5704 done
5705 done
5706 IFS=$as_save_IFS
5707
5708 fi
5709 fi
5710 OTOOL64=$ac_cv_prog_OTOOL64
5711 if test -n "$OTOOL64"; then
5712 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
5713 $as_echo "$OTOOL64" >&6; }
5714 else
5715 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5716 $as_echo "no" >&6; }
5717 fi
5718
5719
5720 fi
5721 if test -z "$ac_cv_prog_OTOOL64"; then
5722 ac_ct_OTOOL64=$OTOOL64
5723 # Extract the first word of "otool64", so it can be a program name with args.
5724 set dummy otool64; ac_word=$2
5725 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5726 $as_echo_n "checking for $ac_word... " >&6; }
5727 if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
5728 $as_echo_n "(cached) " >&6
5729 else
5730 if test -n "$ac_ct_OTOOL64"; then
5731 ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
5732 else
5733 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5734 for as_dir in $PATH
5735 do
5736 IFS=$as_save_IFS
5737 test -z "$as_dir" && as_dir=.
5738 for ac_exec_ext in '' $ac_executable_extensions; do
5739 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5740 ac_cv_prog_ac_ct_OTOOL64="otool64"
5741 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5742 break 2
5743 fi
5744 done
5745 done
5746 IFS=$as_save_IFS
5747
5748 fi
5749 fi
5750 ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
5751 if test -n "$ac_ct_OTOOL64"; then
5752 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
5753 $as_echo "$ac_ct_OTOOL64" >&6; }
5754 else
5755 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5756 $as_echo "no" >&6; }
5757 fi
5758
5759 if test "x$ac_ct_OTOOL64" = x; then
5760 OTOOL64=":"
5761 else
5762 case $cross_compiling:$ac_tool_warned in
5763 yes:)
5764 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5765 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5766 ac_tool_warned=yes ;;
5767 esac
5768 OTOOL64=$ac_ct_OTOOL64
5769 fi
5770 else
5771 OTOOL64="$ac_cv_prog_OTOOL64"
5772 fi
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
5801 $as_echo_n "checking for -single_module linker flag... " >&6; }
5802 if ${lt_cv_apple_cc_single_mod+:} false; then :
5803 $as_echo_n "(cached) " >&6
5804 else
5805 lt_cv_apple_cc_single_mod=no
5806 if test -z "${LT_MULTI_MODULE}"; then
5807 # By default we will add the -single_module flag. You can override
5808 # by either setting the environment variable LT_MULTI_MODULE
5809 # non-empty at configure time, or by adding -multi_module to the
5810 # link flags.
5811 rm -rf libconftest.dylib*
5812 echo "int foo(void){return 1;}" > conftest.c
5813 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
5814 -dynamiclib -Wl,-single_module conftest.c" >&5
5815 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
5816 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
5817 _lt_result=$?
5818 if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
5819 lt_cv_apple_cc_single_mod=yes
5820 else
5821 cat conftest.err >&5
5822 fi
5823 rm -rf libconftest.dylib*
5824 rm -f conftest.*
5825 fi
5826 fi
5827 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
5828 $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
5829 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
5830 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
5831 if ${lt_cv_ld_exported_symbols_list+:} false; then :
5832 $as_echo_n "(cached) " >&6
5833 else
5834 lt_cv_ld_exported_symbols_list=no
5835 save_LDFLAGS=$LDFLAGS
5836 echo "_main" > conftest.sym
5837 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
5838 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5839 /* end confdefs.h. */
5840
5841 int
5842 main ()
5843 {
5844
5845 ;
5846 return 0;
5847 }
5848 _ACEOF
5849 if ac_fn_c_try_link "$LINENO"; then :
5850 lt_cv_ld_exported_symbols_list=yes
5851 else
5852 lt_cv_ld_exported_symbols_list=no
5853 fi
5854 rm -f core conftest.err conftest.$ac_objext \
5855 conftest$ac_exeext conftest.$ac_ext
5856 LDFLAGS="$save_LDFLAGS"
5857
5858 fi
5859 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
5860 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
5861 case $host_os in
5862 rhapsody* | darwin1.[012])
5863 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
5864 darwin1.*)
5865 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
5866 darwin*) # darwin 5.x on
5867 # if running on 10.5 or later, the deployment target defaults
5868 # to the OS version, if on x86, and 10.4, the deployment
5869 # target defaults to 10.4. Don't you love it?
5870 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
5871 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
5872 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
5873 10.[012]*)
5874 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
5875 10.*)
5876 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
5877 esac
5878 ;;
5879 esac
5880 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
5881 _lt_dar_single_mod='$single_module'
5882 fi
5883 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
5884 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
5885 else
5886 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
5887 fi
5888 if test "$DSYMUTIL" != ":"; then
5889 _lt_dsymutil='~$DSYMUTIL $lib || :'
5890 else
5891 _lt_dsymutil=
5892 fi
5893 ;;
5894 esac
5895
5896 ac_ext=c
5897 ac_cpp='$CPP $CPPFLAGS'
5898 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5899 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5900 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5901 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
5902 $as_echo_n "checking how to run the C preprocessor... " >&6; }
5903 # On Suns, sometimes $CPP names a directory.
5904 if test -n "$CPP" && test -d "$CPP"; then
5905 CPP=
5906 fi
5907 if test -z "$CPP"; then
5908 if ${ac_cv_prog_CPP+:} false; then :
5909 $as_echo_n "(cached) " >&6
5910 else
5911 # Double quotes because CPP needs to be expanded
5912 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
5913 do
5914 ac_preproc_ok=false
5915 for ac_c_preproc_warn_flag in '' yes
5916 do
5917 # Use a header file that comes with gcc, so configuring glibc
5918 # with a fresh cross-compiler works.
5919 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
5920 # <limits.h> exists even on freestanding compilers.
5921 # On the NeXT, cc -E runs the code through the compiler's parser,
5922 # not just through cpp. "Syntax error" is here to catch this case.
5923 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5924 /* end confdefs.h. */
5925 #ifdef __STDC__
5926 # include <limits.h>
5927 #else
5928 # include <assert.h>
5929 #endif
5930 Syntax error
5931 _ACEOF
5932 if ac_fn_c_try_cpp "$LINENO"; then :
5933
5934 else
5935 # Broken: fails on valid input.
5936 continue
5937 fi
5938 rm -f conftest.err conftest.i conftest.$ac_ext
5939
5940 # OK, works on sane cases. Now check whether nonexistent headers
5941 # can be detected and how.
5942 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5943 /* end confdefs.h. */
5944 #include <ac_nonexistent.h>
5945 _ACEOF
5946 if ac_fn_c_try_cpp "$LINENO"; then :
5947 # Broken: success on invalid input.
5948 continue
5949 else
5950 # Passes both tests.
5951 ac_preproc_ok=:
5952 break
5953 fi
5954 rm -f conftest.err conftest.i conftest.$ac_ext
5955
5956 done
5957 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
5958 rm -f conftest.i conftest.err conftest.$ac_ext
5959 if $ac_preproc_ok; then :
5960 break
5961 fi
5962
5963 done
5964 ac_cv_prog_CPP=$CPP
5965
5966 fi
5967 CPP=$ac_cv_prog_CPP
5968 else
5969 ac_cv_prog_CPP=$CPP
5970 fi
5971 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
5972 $as_echo "$CPP" >&6; }
5973 ac_preproc_ok=false
5974 for ac_c_preproc_warn_flag in '' yes
5975 do
5976 # Use a header file that comes with gcc, so configuring glibc
5977 # with a fresh cross-compiler works.
5978 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
5979 # <limits.h> exists even on freestanding compilers.
5980 # On the NeXT, cc -E runs the code through the compiler's parser,
5981 # not just through cpp. "Syntax error" is here to catch this case.
5982 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5983 /* end confdefs.h. */
5984 #ifdef __STDC__
5985 # include <limits.h>
5986 #else
5987 # include <assert.h>
5988 #endif
5989 Syntax error
5990 _ACEOF
5991 if ac_fn_c_try_cpp "$LINENO"; then :
5992
5993 else
5994 # Broken: fails on valid input.
5995 continue
5996 fi
5997 rm -f conftest.err conftest.i conftest.$ac_ext
5998
5999 # OK, works on sane cases. Now check whether nonexistent headers
6000 # can be detected and how.
6001 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6002 /* end confdefs.h. */
6003 #include <ac_nonexistent.h>
6004 _ACEOF
6005 if ac_fn_c_try_cpp "$LINENO"; then :
6006 # Broken: success on invalid input.
6007 continue
6008 else
6009 # Passes both tests.
6010 ac_preproc_ok=:
6011 break
6012 fi
6013 rm -f conftest.err conftest.i conftest.$ac_ext
6014
6015 done
6016 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
6017 rm -f conftest.i conftest.err conftest.$ac_ext
6018 if $ac_preproc_ok; then :
6019
6020 else
6021 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
6022 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
6023 as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
6024 See \`config.log' for more details" "$LINENO" 5; }
6025 fi
6026
6027 ac_ext=c
6028 ac_cpp='$CPP $CPPFLAGS'
6029 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6030 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6031 ac_compiler_gnu=$ac_cv_c_compiler_gnu
6032
6033
6034 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
6035 $as_echo_n "checking for ANSI C header files... " >&6; }
6036 if ${ac_cv_header_stdc+:} false; then :
6037 $as_echo_n "(cached) " >&6
6038 else
6039 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6040 /* end confdefs.h. */
6041 #include <stdlib.h>
6042 #include <stdarg.h>
6043 #include <string.h>
6044 #include <float.h>
6045
6046 int
6047 main ()
6048 {
6049
6050 ;
6051 return 0;
6052 }
6053 _ACEOF
6054 if ac_fn_c_try_compile "$LINENO"; then :
6055 ac_cv_header_stdc=yes
6056 else
6057 ac_cv_header_stdc=no
6058 fi
6059 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6060
6061 if test $ac_cv_header_stdc = yes; then
6062 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
6063 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6064 /* end confdefs.h. */
6065 #include <string.h>
6066
6067 _ACEOF
6068 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6069 $EGREP "memchr" >/dev/null 2>&1; then :
6070
6071 else
6072 ac_cv_header_stdc=no
6073 fi
6074 rm -f conftest*
6075
6076 fi
6077
6078 if test $ac_cv_header_stdc = yes; then
6079 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
6080 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6081 /* end confdefs.h. */
6082 #include <stdlib.h>
6083
6084 _ACEOF
6085 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6086 $EGREP "free" >/dev/null 2>&1; then :
6087
6088 else
6089 ac_cv_header_stdc=no
6090 fi
6091 rm -f conftest*
6092
6093 fi
6094
6095 if test $ac_cv_header_stdc = yes; then
6096 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
6097 if test "$cross_compiling" = yes; then :
6098 :
6099 else
6100 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6101 /* end confdefs.h. */
6102 #include <ctype.h>
6103 #include <stdlib.h>
6104 #if ((' ' & 0x0FF) == 0x020)
6105 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
6106 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
6107 #else
6108 # define ISLOWER(c) \
6109 (('a' <= (c) && (c) <= 'i') \
6110 || ('j' <= (c) && (c) <= 'r') \
6111 || ('s' <= (c) && (c) <= 'z'))
6112 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
6113 #endif
6114
6115 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
6116 int
6117 main ()
6118 {
6119 int i;
6120 for (i = 0; i < 256; i++)
6121 if (XOR (islower (i), ISLOWER (i))
6122 || toupper (i) != TOUPPER (i))
6123 return 2;
6124 return 0;
6125 }
6126 _ACEOF
6127 if ac_fn_c_try_run "$LINENO"; then :
6128
6129 else
6130 ac_cv_header_stdc=no
6131 fi
6132 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6133 conftest.$ac_objext conftest.beam conftest.$ac_ext
6134 fi
6135
6136 fi
6137 fi
6138 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
6139 $as_echo "$ac_cv_header_stdc" >&6; }
6140 if test $ac_cv_header_stdc = yes; then
6141
6142 $as_echo "#define STDC_HEADERS 1" >>confdefs.h
6143
6144 fi
6145
6146 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
6147 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
6148 inttypes.h stdint.h unistd.h
6149 do :
6150 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
6151 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
6152 "
6153 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
6154 cat >>confdefs.h <<_ACEOF
6155 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
6156 _ACEOF
6157
6158 fi
6159
6160 done
6161
6162
6163 for ac_header in dlfcn.h
6164 do :
6165 ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
6166 "
6167 if test "x$ac_cv_header_dlfcn_h" = xyes; then :
6168 cat >>confdefs.h <<_ACEOF
6169 #define HAVE_DLFCN_H 1
6170 _ACEOF
6171
6172 fi
6173
6174 done
6175
6176
6177
6178 # Set options
6179 enable_win32_dll=yes
6180
6181 case $host in
6182 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
6183 if test -n "$ac_tool_prefix"; then
6184 # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
6185 set dummy ${ac_tool_prefix}as; ac_word=$2
6186 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6187 $as_echo_n "checking for $ac_word... " >&6; }
6188 if ${ac_cv_prog_AS+:} false; then :
6189 $as_echo_n "(cached) " >&6
6190 else
6191 if test -n "$AS"; then
6192 ac_cv_prog_AS="$AS" # Let the user override the test.
6193 else
6194 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6195 for as_dir in $PATH
6196 do
6197 IFS=$as_save_IFS
6198 test -z "$as_dir" && as_dir=.
6199 for ac_exec_ext in '' $ac_executable_extensions; do
6200 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6201 ac_cv_prog_AS="${ac_tool_prefix}as"
6202 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6203 break 2
6204 fi
6205 done
6206 done
6207 IFS=$as_save_IFS
6208
6209 fi
6210 fi
6211 AS=$ac_cv_prog_AS
6212 if test -n "$AS"; then
6213 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5
6214 $as_echo "$AS" >&6; }
6215 else
6216 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6217 $as_echo "no" >&6; }
6218 fi
6219
6220
6221 fi
6222 if test -z "$ac_cv_prog_AS"; then
6223 ac_ct_AS=$AS
6224 # Extract the first word of "as", so it can be a program name with args.
6225 set dummy as; ac_word=$2
6226 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6227 $as_echo_n "checking for $ac_word... " >&6; }
6228 if ${ac_cv_prog_ac_ct_AS+:} false; then :
6229 $as_echo_n "(cached) " >&6
6230 else
6231 if test -n "$ac_ct_AS"; then
6232 ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.
6233 else
6234 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6235 for as_dir in $PATH
6236 do
6237 IFS=$as_save_IFS
6238 test -z "$as_dir" && as_dir=.
6239 for ac_exec_ext in '' $ac_executable_extensions; do
6240 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6241 ac_cv_prog_ac_ct_AS="as"
6242 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6243 break 2
6244 fi
6245 done
6246 done
6247 IFS=$as_save_IFS
6248
6249 fi
6250 fi
6251 ac_ct_AS=$ac_cv_prog_ac_ct_AS
6252 if test -n "$ac_ct_AS"; then
6253 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5
6254 $as_echo "$ac_ct_AS" >&6; }
6255 else
6256 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6257 $as_echo "no" >&6; }
6258 fi
6259
6260 if test "x$ac_ct_AS" = x; then
6261 AS="false"
6262 else
6263 case $cross_compiling:$ac_tool_warned in
6264 yes:)
6265 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6266 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6267 ac_tool_warned=yes ;;
6268 esac
6269 AS=$ac_ct_AS
6270 fi
6271 else
6272 AS="$ac_cv_prog_AS"
6273 fi
6274
6275 if test -n "$ac_tool_prefix"; then
6276 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
6277 set dummy ${ac_tool_prefix}dlltool; ac_word=$2
6278 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6279 $as_echo_n "checking for $ac_word... " >&6; }
6280 if ${ac_cv_prog_DLLTOOL+:} false; then :
6281 $as_echo_n "(cached) " >&6
6282 else
6283 if test -n "$DLLTOOL"; then
6284 ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
6285 else
6286 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6287 for as_dir in $PATH
6288 do
6289 IFS=$as_save_IFS
6290 test -z "$as_dir" && as_dir=.
6291 for ac_exec_ext in '' $ac_executable_extensions; do
6292 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6293 ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
6294 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6295 break 2
6296 fi
6297 done
6298 done
6299 IFS=$as_save_IFS
6300
6301 fi
6302 fi
6303 DLLTOOL=$ac_cv_prog_DLLTOOL
6304 if test -n "$DLLTOOL"; then
6305 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
6306 $as_echo "$DLLTOOL" >&6; }
6307 else
6308 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6309 $as_echo "no" >&6; }
6310 fi
6311
6312
6313 fi
6314 if test -z "$ac_cv_prog_DLLTOOL"; then
6315 ac_ct_DLLTOOL=$DLLTOOL
6316 # Extract the first word of "dlltool", so it can be a program name with args.
6317 set dummy dlltool; ac_word=$2
6318 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6319 $as_echo_n "checking for $ac_word... " >&6; }
6320 if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
6321 $as_echo_n "(cached) " >&6
6322 else
6323 if test -n "$ac_ct_DLLTOOL"; then
6324 ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
6325 else
6326 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6327 for as_dir in $PATH
6328 do
6329 IFS=$as_save_IFS
6330 test -z "$as_dir" && as_dir=.
6331 for ac_exec_ext in '' $ac_executable_extensions; do
6332 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6333 ac_cv_prog_ac_ct_DLLTOOL="dlltool"
6334 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6335 break 2
6336 fi
6337 done
6338 done
6339 IFS=$as_save_IFS
6340
6341 fi
6342 fi
6343 ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
6344 if test -n "$ac_ct_DLLTOOL"; then
6345 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
6346 $as_echo "$ac_ct_DLLTOOL" >&6; }
6347 else
6348 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6349 $as_echo "no" >&6; }
6350 fi
6351
6352 if test "x$ac_ct_DLLTOOL" = x; then
6353 DLLTOOL="false"
6354 else
6355 case $cross_compiling:$ac_tool_warned in
6356 yes:)
6357 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6358 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6359 ac_tool_warned=yes ;;
6360 esac
6361 DLLTOOL=$ac_ct_DLLTOOL
6362 fi
6363 else
6364 DLLTOOL="$ac_cv_prog_DLLTOOL"
6365 fi
6366
6367 if test -n "$ac_tool_prefix"; then
6368 # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
6369 set dummy ${ac_tool_prefix}objdump; ac_word=$2
6370 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6371 $as_echo_n "checking for $ac_word... " >&6; }
6372 if ${ac_cv_prog_OBJDUMP+:} false; then :
6373 $as_echo_n "(cached) " >&6
6374 else
6375 if test -n "$OBJDUMP"; then
6376 ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
6377 else
6378 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6379 for as_dir in $PATH
6380 do
6381 IFS=$as_save_IFS
6382 test -z "$as_dir" && as_dir=.
6383 for ac_exec_ext in '' $ac_executable_extensions; do
6384 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6385 ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
6386 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6387 break 2
6388 fi
6389 done
6390 done
6391 IFS=$as_save_IFS
6392
6393 fi
6394 fi
6395 OBJDUMP=$ac_cv_prog_OBJDUMP
6396 if test -n "$OBJDUMP"; then
6397 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
6398 $as_echo "$OBJDUMP" >&6; }
6399 else
6400 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6401 $as_echo "no" >&6; }
6402 fi
6403
6404
6405 fi
6406 if test -z "$ac_cv_prog_OBJDUMP"; then
6407 ac_ct_OBJDUMP=$OBJDUMP
6408 # Extract the first word of "objdump", so it can be a program name with args.
6409 set dummy objdump; ac_word=$2
6410 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6411 $as_echo_n "checking for $ac_word... " >&6; }
6412 if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
6413 $as_echo_n "(cached) " >&6
6414 else
6415 if test -n "$ac_ct_OBJDUMP"; then
6416 ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
6417 else
6418 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6419 for as_dir in $PATH
6420 do
6421 IFS=$as_save_IFS
6422 test -z "$as_dir" && as_dir=.
6423 for ac_exec_ext in '' $ac_executable_extensions; do
6424 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6425 ac_cv_prog_ac_ct_OBJDUMP="objdump"
6426 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6427 break 2
6428 fi
6429 done
6430 done
6431 IFS=$as_save_IFS
6432
6433 fi
6434 fi
6435 ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
6436 if test -n "$ac_ct_OBJDUMP"; then
6437 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
6438 $as_echo "$ac_ct_OBJDUMP" >&6; }
6439 else
6440 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6441 $as_echo "no" >&6; }
6442 fi
6443
6444 if test "x$ac_ct_OBJDUMP" = x; then
6445 OBJDUMP="false"
6446 else
6447 case $cross_compiling:$ac_tool_warned in
6448 yes:)
6449 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6450 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6451 ac_tool_warned=yes ;;
6452 esac
6453 OBJDUMP=$ac_ct_OBJDUMP
6454 fi
6455 else
6456 OBJDUMP="$ac_cv_prog_OBJDUMP"
6457 fi
6458
6459 ;;
6460 esac
6461
6462 test -z "$AS" && AS=as
6463
6464
6465
6466
6467
6468 test -z "$DLLTOOL" && DLLTOOL=dlltool
6469
6470
6471
6472
6473
6474 test -z "$OBJDUMP" && OBJDUMP=objdump
6475
6476
6477
6478
6479
6480
6481
6482 enable_dlopen=no
6483
6484
6485
6486 # Check whether --enable-shared was given.
6487 if test "${enable_shared+set}" = set; then :
6488 enableval=$enable_shared; p=${PACKAGE-default}
6489 case $enableval in
6490 yes) enable_shared=yes ;;
6491 no) enable_shared=no ;;
6492 *)
6493 enable_shared=no
6494 # Look at the argument we got. We use all the common list separators.
6495 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6496 for pkg in $enableval; do
6497 IFS="$lt_save_ifs"
6498 if test "X$pkg" = "X$p"; then
6499 enable_shared=yes
6500 fi
6501 done
6502 IFS="$lt_save_ifs"
6503 ;;
6504 esac
6505 else
6506 enable_shared=yes
6507 fi
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517 # Check whether --enable-static was given.
6518 if test "${enable_static+set}" = set; then :
6519 enableval=$enable_static; p=${PACKAGE-default}
6520 case $enableval in
6521 yes) enable_static=yes ;;
6522 no) enable_static=no ;;
6523 *)
6524 enable_static=no
6525 # Look at the argument we got. We use all the common list separators.
6526 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6527 for pkg in $enableval; do
6528 IFS="$lt_save_ifs"
6529 if test "X$pkg" = "X$p"; then
6530 enable_static=yes
6531 fi
6532 done
6533 IFS="$lt_save_ifs"
6534 ;;
6535 esac
6536 else
6537 enable_static=yes
6538 fi
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549 # Check whether --with-pic was given.
6550 if test "${with_pic+set}" = set; then :
6551 withval=$with_pic; pic_mode="$withval"
6552 else
6553 pic_mode=default
6554 fi
6555
6556
6557 test -z "$pic_mode" && pic_mode=default
6558
6559
6560
6561
6562
6563
6564
6565 # Check whether --enable-fast-install was given.
6566 if test "${enable_fast_install+set}" = set; then :
6567 enableval=$enable_fast_install; p=${PACKAGE-default}
6568 case $enableval in
6569 yes) enable_fast_install=yes ;;
6570 no) enable_fast_install=no ;;
6571 *)
6572 enable_fast_install=no
6573 # Look at the argument we got. We use all the common list separators.
6574 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6575 for pkg in $enableval; do
6576 IFS="$lt_save_ifs"
6577 if test "X$pkg" = "X$p"; then
6578 enable_fast_install=yes
6579 fi
6580 done
6581 IFS="$lt_save_ifs"
6582 ;;
6583 esac
6584 else
6585 enable_fast_install=yes
6586 fi
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598 # This can be used to rebuild libtool when needed
6599 LIBTOOL_DEPS="$ltmain"
6600
6601 # Always use our own libtool.
6602 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628 test -z "$LN_S" && LN_S="ln -s"
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643 if test -n "${ZSH_VERSION+set}" ; then
6644 setopt NO_GLOB_SUBST
6645 fi
6646
6647 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
6648 $as_echo_n "checking for objdir... " >&6; }
6649 if ${lt_cv_objdir+:} false; then :
6650 $as_echo_n "(cached) " >&6
6651 else
6652 rm -f .libs 2>/dev/null
6653 mkdir .libs 2>/dev/null
6654 if test -d .libs; then
6655 lt_cv_objdir=.libs
6656 else
6657 # MS-DOS does not allow filenames that begin with a dot.
6658 lt_cv_objdir=_libs
6659 fi
6660 rmdir .libs 2>/dev/null
6661 fi
6662 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
6663 $as_echo "$lt_cv_objdir" >&6; }
6664 objdir=$lt_cv_objdir
6665
6666
6667
6668
6669
6670 cat >>confdefs.h <<_ACEOF
6671 #define LT_OBJDIR "$lt_cv_objdir/"
6672 _ACEOF
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690 case $host_os in
6691 aix3*)
6692 # AIX sometimes has problems with the GCC collect2 program. For some
6693 # reason, if we set the COLLECT_NAMES environment variable, the problems
6694 # vanish in a puff of smoke.
6695 if test "X${COLLECT_NAMES+set}" != Xset; then
6696 COLLECT_NAMES=
6697 export COLLECT_NAMES
6698 fi
6699 ;;
6700 esac
6701
6702 # Sed substitution that helps us do robust quoting. It backslashifies
6703 # metacharacters that are still active within double-quoted strings.
6704 sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
6705
6706 # Same as above, but do not quote variable references.
6707 double_quote_subst='s/\(["`\\]\)/\\\1/g'
6708
6709 # Sed substitution to delay expansion of an escaped shell variable in a
6710 # double_quote_subst'ed string.
6711 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
6712
6713 # Sed substitution to delay expansion of an escaped single quote.
6714 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
6715
6716 # Sed substitution to avoid accidental globbing in evaled expressions
6717 no_glob_subst='s/\*/\\\*/g'
6718
6719 # Global variables:
6720 ofile=libtool
6721 can_build_shared=yes
6722
6723 # All known linkers require a `.a' archive for static linking (except MSVC,
6724 # which needs '.lib').
6725 libext=a
6726
6727 with_gnu_ld="$lt_cv_prog_gnu_ld"
6728
6729 old_CC="$CC"
6730 old_CFLAGS="$CFLAGS"
6731
6732 # Set sane defaults for various variables
6733 test -z "$CC" && CC=cc
6734 test -z "$LTCC" && LTCC=$CC
6735 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
6736 test -z "$LD" && LD=ld
6737 test -z "$ac_objext" && ac_objext=o
6738
6739 for cc_temp in $compiler""; do
6740 case $cc_temp in
6741 compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
6742 distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
6743 \-*) ;;
6744 *) break;;
6745 esac
6746 done
6747 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
6748
6749
6750 # Only perform the check for file, if the check method requires it
6751 test -z "$MAGIC_CMD" && MAGIC_CMD=file
6752 case $deplibs_check_method in
6753 file_magic*)
6754 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
6755 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
6756 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
6757 if ${lt_cv_path_MAGIC_CMD+:} false; then :
6758 $as_echo_n "(cached) " >&6
6759 else
6760 case $MAGIC_CMD in
6761 [\\/*] | ?:[\\/]*)
6762 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
6763 ;;
6764 *)
6765 lt_save_MAGIC_CMD="$MAGIC_CMD"
6766 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
6767 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
6768 for ac_dir in $ac_dummy; do
6769 IFS="$lt_save_ifs"
6770 test -z "$ac_dir" && ac_dir=.
6771 if test -f $ac_dir/${ac_tool_prefix}file; then
6772 lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
6773 if test -n "$file_magic_test_file"; then
6774 case $deplibs_check_method in
6775 "file_magic "*)
6776 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
6777 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6778 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
6779 $EGREP "$file_magic_regex" > /dev/null; then
6780 :
6781 else
6782 cat <<_LT_EOF 1>&2
6783
6784 *** Warning: the command libtool uses to detect shared libraries,
6785 *** $file_magic_cmd, produces output that libtool cannot recognize.
6786 *** The result is that libtool may fail to recognize shared libraries
6787 *** as such. This will affect the creation of libtool libraries that
6788 *** depend on shared libraries, but programs linked with such libtool
6789 *** libraries will work regardless of this problem. Nevertheless, you
6790 *** may want to report the problem to your system manager and/or to
6791 *** bug-libtool@gnu.org
6792
6793 _LT_EOF
6794 fi ;;
6795 esac
6796 fi
6797 break
6798 fi
6799 done
6800 IFS="$lt_save_ifs"
6801 MAGIC_CMD="$lt_save_MAGIC_CMD"
6802 ;;
6803 esac
6804 fi
6805
6806 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6807 if test -n "$MAGIC_CMD"; then
6808 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
6809 $as_echo "$MAGIC_CMD" >&6; }
6810 else
6811 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6812 $as_echo "no" >&6; }
6813 fi
6814
6815
6816
6817
6818
6819 if test -z "$lt_cv_path_MAGIC_CMD"; then
6820 if test -n "$ac_tool_prefix"; then
6821 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
6822 $as_echo_n "checking for file... " >&6; }
6823 if ${lt_cv_path_MAGIC_CMD+:} false; then :
6824 $as_echo_n "(cached) " >&6
6825 else
6826 case $MAGIC_CMD in
6827 [\\/*] | ?:[\\/]*)
6828 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
6829 ;;
6830 *)
6831 lt_save_MAGIC_CMD="$MAGIC_CMD"
6832 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
6833 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
6834 for ac_dir in $ac_dummy; do
6835 IFS="$lt_save_ifs"
6836 test -z "$ac_dir" && ac_dir=.
6837 if test -f $ac_dir/file; then
6838 lt_cv_path_MAGIC_CMD="$ac_dir/file"
6839 if test -n "$file_magic_test_file"; then
6840 case $deplibs_check_method in
6841 "file_magic "*)
6842 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
6843 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6844 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
6845 $EGREP "$file_magic_regex" > /dev/null; then
6846 :
6847 else
6848 cat <<_LT_EOF 1>&2
6849
6850 *** Warning: the command libtool uses to detect shared libraries,
6851 *** $file_magic_cmd, produces output that libtool cannot recognize.
6852 *** The result is that libtool may fail to recognize shared libraries
6853 *** as such. This will affect the creation of libtool libraries that
6854 *** depend on shared libraries, but programs linked with such libtool
6855 *** libraries will work regardless of this problem. Nevertheless, you
6856 *** may want to report the problem to your system manager and/or to
6857 *** bug-libtool@gnu.org
6858
6859 _LT_EOF
6860 fi ;;
6861 esac
6862 fi
6863 break
6864 fi
6865 done
6866 IFS="$lt_save_ifs"
6867 MAGIC_CMD="$lt_save_MAGIC_CMD"
6868 ;;
6869 esac
6870 fi
6871
6872 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6873 if test -n "$MAGIC_CMD"; then
6874 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
6875 $as_echo "$MAGIC_CMD" >&6; }
6876 else
6877 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6878 $as_echo "no" >&6; }
6879 fi
6880
6881
6882 else
6883 MAGIC_CMD=:
6884 fi
6885 fi
6886
6887 fi
6888 ;;
6889 esac
6890
6891 # Use C for the default configuration in the libtool script
6892
6893 lt_save_CC="$CC"
6894 ac_ext=c
6895 ac_cpp='$CPP $CPPFLAGS'
6896 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6897 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6898 ac_compiler_gnu=$ac_cv_c_compiler_gnu
6899
6900
6901 # Source file extension for C test sources.
6902 ac_ext=c
6903
6904 # Object file extension for compiled C test sources.
6905 objext=o
6906 objext=$objext
6907
6908 # Code to be used in simple compile tests
6909 lt_simple_compile_test_code="int some_variable = 0;"
6910
6911 # Code to be used in simple link tests
6912 lt_simple_link_test_code='int main(){return(0);}'
6913
6914
6915
6916
6917
6918
6919
6920 # If no C compiler was specified, use CC.
6921 LTCC=${LTCC-"$CC"}
6922
6923 # If no C compiler flags were specified, use CFLAGS.
6924 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
6925
6926 # Allow CC to be a program name with arguments.
6927 compiler=$CC
6928
6929 # Save the default compiler, since it gets overwritten when the other
6930 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
6931 compiler_DEFAULT=$CC
6932
6933 # save warnings/boilerplate of simple test code
6934 ac_outfile=conftest.$ac_objext
6935 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
6936 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
6937 _lt_compiler_boilerplate=`cat conftest.err`
6938 $RM conftest*
6939
6940 ac_outfile=conftest.$ac_objext
6941 echo "$lt_simple_link_test_code" >conftest.$ac_ext
6942 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
6943 _lt_linker_boilerplate=`cat conftest.err`
6944 $RM -r conftest*
6945
6946
6947 ## CAVEAT EMPTOR:
6948 ## There is no encapsulation within the following macros, do not change
6949 ## the running order or otherwise move them around unless you know exactly
6950 ## what you are doing...
6951 if test -n "$compiler"; then
6952
6953 lt_prog_compiler_no_builtin_flag=
6954
6955 if test "$GCC" = yes; then
6956 lt_prog_compiler_no_builtin_flag=' -fno-builtin'
6957
6958 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
6959 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
6960 if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
6961 $as_echo_n "(cached) " >&6
6962 else
6963 lt_cv_prog_compiler_rtti_exceptions=no
6964 ac_outfile=conftest.$ac_objext
6965 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
6966 lt_compiler_flag="-fno-rtti -fno-exceptions"
6967 # Insert the option either (1) after the last *FLAGS variable, or
6968 # (2) before a word containing "conftest.", or (3) at the end.
6969 # Note that $ac_compile itself does not contain backslashes and begins
6970 # with a dollar sign (not a hyphen), so the echo should work correctly.
6971 # The option is referenced via a variable to avoid confusing sed.
6972 lt_compile=`echo "$ac_compile" | $SED \
6973 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
6974 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
6975 -e 's:$: $lt_compiler_flag:'`
6976 (eval echo "\"\$as_me:6977: $lt_compile\"" >&5)
6977 (eval "$lt_compile" 2>conftest.err)
6978 ac_status=$?
6979 cat conftest.err >&5
6980 echo "$as_me:6981: \$? = $ac_status" >&5
6981 if (exit $ac_status) && test -s "$ac_outfile"; then
6982 # The compiler can only warn and ignore the option if not recognized
6983 # So say no if there are warnings other than the usual output.
6984 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
6985 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
6986 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
6987 lt_cv_prog_compiler_rtti_exceptions=yes
6988 fi
6989 fi
6990 $RM conftest*
6991
6992 fi
6993 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
6994 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
6995
6996 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
6997 lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
6998 else
6999 :
7000 fi
7001
7002 fi
7003
7004
7005
7006
7007
7008
7009 lt_prog_compiler_wl=
7010 lt_prog_compiler_pic=
7011 lt_prog_compiler_static=
7012
7013 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
7014 $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
7015
7016 if test "$GCC" = yes; then
7017 lt_prog_compiler_wl='-Wl,'
7018 lt_prog_compiler_static='-static'
7019
7020 case $host_os in
7021 aix*)
7022 # All AIX code is PIC.
7023 if test "$host_cpu" = ia64; then
7024 # AIX 5 now supports IA64 processor
7025 lt_prog_compiler_static='-Bstatic'
7026 fi
7027 ;;
7028
7029 amigaos*)
7030 case $host_cpu in
7031 powerpc)
7032 # see comment about AmigaOS4 .so support
7033 lt_prog_compiler_pic='-fPIC'
7034 ;;
7035 m68k)
7036 # FIXME: we need at least 68020 code to build shared libraries, but
7037 # adding the `-m68020' flag to GCC prevents building anything better,
7038 # like `-m68040'.
7039 lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
7040 ;;
7041 esac
7042 ;;
7043
7044 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
7045 # PIC is the default for these OSes.
7046 ;;
7047
7048 mingw* | cygwin* | pw32* | os2* | cegcc*)
7049 # This hack is so that the source file can tell whether it is being
7050 # built for inclusion in a dll (and should export symbols for example).
7051 # Although the cygwin gcc ignores -fPIC, still need this for old-style
7052 # (--disable-auto-import) libraries
7053 lt_prog_compiler_pic='-DDLL_EXPORT'
7054 ;;
7055
7056 darwin* | rhapsody*)
7057 # PIC is the default on this platform
7058 # Common symbols not allowed in MH_DYLIB files
7059 lt_prog_compiler_pic='-fno-common'
7060 ;;
7061
7062 hpux*)
7063 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
7064 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
7065 # sets the default TLS model and affects inlining.
7066 case $host_cpu in
7067 hppa*64*)
7068 # +Z the default
7069 ;;
7070 *)
7071 lt_prog_compiler_pic='-fPIC'
7072 ;;
7073 esac
7074 ;;
7075
7076 interix[3-9]*)
7077 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
7078 # Instead, we relocate shared libraries at runtime.
7079 ;;
7080
7081 msdosdjgpp*)
7082 # Just because we use GCC doesn't mean we suddenly get shared libraries
7083 # on systems that don't support them.
7084 lt_prog_compiler_can_build_shared=no
7085 enable_shared=no
7086 ;;
7087
7088 *nto* | *qnx*)
7089 # QNX uses GNU C++, but need to define -shared option too, otherwise
7090 # it will coredump.
7091 lt_prog_compiler_pic='-fPIC -shared'
7092 ;;
7093
7094 sysv4*MP*)
7095 if test -d /usr/nec; then
7096 lt_prog_compiler_pic=-Kconform_pic
7097 fi
7098 ;;
7099
7100 *)
7101 lt_prog_compiler_pic='-fPIC'
7102 ;;
7103 esac
7104 else
7105 # PORTME Check for flag to pass linker flags through the system compiler.
7106 case $host_os in
7107 aix*)
7108 lt_prog_compiler_wl='-Wl,'
7109 if test "$host_cpu" = ia64; then
7110 # AIX 5 now supports IA64 processor
7111 lt_prog_compiler_static='-Bstatic'
7112 else
7113 lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
7114 fi
7115 ;;
7116
7117 mingw* | cygwin* | pw32* | os2* | cegcc*)
7118 # This hack is so that the source file can tell whether it is being
7119 # built for inclusion in a dll (and should export symbols for example).
7120 lt_prog_compiler_pic='-DDLL_EXPORT'
7121 ;;
7122
7123 hpux9* | hpux10* | hpux11*)
7124 lt_prog_compiler_wl='-Wl,'
7125 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
7126 # not for PA HP-UX.
7127 case $host_cpu in
7128 hppa*64*|ia64*)
7129 # +Z the default
7130 ;;
7131 *)
7132 lt_prog_compiler_pic='+Z'
7133 ;;
7134 esac
7135 # Is there a better lt_prog_compiler_static that works with the bundled CC?
7136 lt_prog_compiler_static='${wl}-a ${wl}archive'
7137 ;;
7138
7139 irix5* | irix6* | nonstopux*)
7140 lt_prog_compiler_wl='-Wl,'
7141 # PIC (with -KPIC) is the default.
7142 lt_prog_compiler_static='-non_shared'
7143 ;;
7144
7145 linux* | k*bsd*-gnu)
7146 case $cc_basename in
7147 # old Intel for x86_64 which still supported -KPIC.
7148 ecc*)
7149 lt_prog_compiler_wl='-Wl,'
7150 lt_prog_compiler_pic='-KPIC'
7151 lt_prog_compiler_static='-static'
7152 ;;
7153 # icc used to be incompatible with GCC.
7154 # ICC 10 doesn't accept -KPIC any more.
7155 icc* | ifort*)
7156 lt_prog_compiler_wl='-Wl,'
7157 lt_prog_compiler_pic='-fPIC'
7158 lt_prog_compiler_static='-static'
7159 ;;
7160 # Lahey Fortran 8.1.
7161 lf95*)
7162 lt_prog_compiler_wl='-Wl,'
7163 lt_prog_compiler_pic='--shared'
7164 lt_prog_compiler_static='--static'
7165 ;;
7166 pgcc* | pgf77* | pgf90* | pgf95*)
7167 # Portland Group compilers (*not* the Pentium gcc compiler,
7168 # which looks to be a dead project)
7169 lt_prog_compiler_wl='-Wl,'
7170 lt_prog_compiler_pic='-fpic'
7171 lt_prog_compiler_static='-Bstatic'
7172 ;;
7173 ccc*)
7174 lt_prog_compiler_wl='-Wl,'
7175 # All Alpha code is PIC.
7176 lt_prog_compiler_static='-non_shared'
7177 ;;
7178 xl*)
7179 # IBM XL C 8.0/Fortran 10.1 on PPC
7180 lt_prog_compiler_wl='-Wl,'
7181 lt_prog_compiler_pic='-qpic'
7182 lt_prog_compiler_static='-qstaticlink'
7183 ;;
7184 *)
7185 case `$CC -V 2>&1 | sed 5q` in
7186 *Sun\ C*)
7187 # Sun C 5.9
7188 lt_prog_compiler_pic='-KPIC'
7189 lt_prog_compiler_static='-Bstatic'
7190 lt_prog_compiler_wl='-Wl,'
7191 ;;
7192 *Sun\ F*)
7193 # Sun Fortran 8.3 passes all unrecognized flags to the linker
7194 lt_prog_compiler_pic='-KPIC'
7195 lt_prog_compiler_static='-Bstatic'
7196 lt_prog_compiler_wl=''
7197 ;;
7198 esac
7199 ;;
7200 esac
7201 ;;
7202
7203 newsos6)
7204 lt_prog_compiler_pic='-KPIC'
7205 lt_prog_compiler_static='-Bstatic'
7206 ;;
7207
7208 *nto* | *qnx*)
7209 # QNX uses GNU C++, but need to define -shared option too, otherwise
7210 # it will coredump.
7211 lt_prog_compiler_pic='-fPIC -shared'
7212 ;;
7213
7214 osf3* | osf4* | osf5*)
7215 lt_prog_compiler_wl='-Wl,'
7216 # All OSF/1 code is PIC.
7217 lt_prog_compiler_static='-non_shared'
7218 ;;
7219
7220 rdos*)
7221 lt_prog_compiler_static='-non_shared'
7222 ;;
7223
7224 solaris*)
7225 lt_prog_compiler_pic='-KPIC'
7226 lt_prog_compiler_static='-Bstatic'
7227 case $cc_basename in
7228 f77* | f90* | f95*)
7229 lt_prog_compiler_wl='-Qoption ld ';;
7230 *)
7231 lt_prog_compiler_wl='-Wl,';;
7232 esac
7233 ;;
7234
7235 sunos4*)
7236 lt_prog_compiler_wl='-Qoption ld '
7237 lt_prog_compiler_pic='-PIC'
7238 lt_prog_compiler_static='-Bstatic'
7239 ;;
7240
7241 sysv4 | sysv4.2uw2* | sysv4.3*)
7242 lt_prog_compiler_wl='-Wl,'
7243 lt_prog_compiler_pic='-KPIC'
7244 lt_prog_compiler_static='-Bstatic'
7245 ;;
7246
7247 sysv4*MP*)
7248 if test -d /usr/nec ;then
7249 lt_prog_compiler_pic='-Kconform_pic'
7250 lt_prog_compiler_static='-Bstatic'
7251 fi
7252 ;;
7253
7254 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
7255 lt_prog_compiler_wl='-Wl,'
7256 lt_prog_compiler_pic='-KPIC'
7257 lt_prog_compiler_static='-Bstatic'
7258 ;;
7259
7260 unicos*)
7261 lt_prog_compiler_wl='-Wl,'
7262 lt_prog_compiler_can_build_shared=no
7263 ;;
7264
7265 uts4*)
7266 lt_prog_compiler_pic='-pic'
7267 lt_prog_compiler_static='-Bstatic'
7268 ;;
7269
7270 *)
7271 lt_prog_compiler_can_build_shared=no
7272 ;;
7273 esac
7274 fi
7275
7276 case $host_os in
7277 # For platforms which do not support PIC, -DPIC is meaningless:
7278 *djgpp*)
7279 lt_prog_compiler_pic=
7280 ;;
7281 *)
7282 lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
7283 ;;
7284 esac
7285 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
7286 $as_echo "$lt_prog_compiler_pic" >&6; }
7287
7288
7289
7290
7291
7292
7293 #
7294 # Check to make sure the PIC flag actually works.
7295 #
7296 if test -n "$lt_prog_compiler_pic"; then
7297 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
7298 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
7299 if ${lt_cv_prog_compiler_pic_works+:} false; then :
7300 $as_echo_n "(cached) " >&6
7301 else
7302 lt_cv_prog_compiler_pic_works=no
7303 ac_outfile=conftest.$ac_objext
7304 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7305 lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
7306 # Insert the option either (1) after the last *FLAGS variable, or
7307 # (2) before a word containing "conftest.", or (3) at the end.
7308 # Note that $ac_compile itself does not contain backslashes and begins
7309 # with a dollar sign (not a hyphen), so the echo should work correctly.
7310 # The option is referenced via a variable to avoid confusing sed.
7311 lt_compile=`echo "$ac_compile" | $SED \
7312 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7313 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7314 -e 's:$: $lt_compiler_flag:'`
7315 (eval echo "\"\$as_me:7316: $lt_compile\"" >&5)
7316 (eval "$lt_compile" 2>conftest.err)
7317 ac_status=$?
7318 cat conftest.err >&5
7319 echo "$as_me:7320: \$? = $ac_status" >&5
7320 if (exit $ac_status) && test -s "$ac_outfile"; then
7321 # The compiler can only warn and ignore the option if not recognized
7322 # So say no if there are warnings other than the usual output.
7323 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
7324 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7325 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
7326 lt_cv_prog_compiler_pic_works=yes
7327 fi
7328 fi
7329 $RM conftest*
7330
7331 fi
7332 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
7333 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
7334
7335 if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
7336 case $lt_prog_compiler_pic in
7337 "" | " "*) ;;
7338 *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
7339 esac
7340 else
7341 lt_prog_compiler_pic=
7342 lt_prog_compiler_can_build_shared=no
7343 fi
7344
7345 fi
7346
7347
7348
7349
7350
7351
7352 #
7353 # Check to make sure the static flag actually works.
7354 #
7355 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
7356 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
7357 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
7358 if ${lt_cv_prog_compiler_static_works+:} false; then :
7359 $as_echo_n "(cached) " >&6
7360 else
7361 lt_cv_prog_compiler_static_works=no
7362 save_LDFLAGS="$LDFLAGS"
7363 LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
7364 echo "$lt_simple_link_test_code" > conftest.$ac_ext
7365 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
7366 # The linker can only warn and ignore the option if not recognized
7367 # So say no if there are warnings
7368 if test -s conftest.err; then
7369 # Append any errors to the config.log.
7370 cat conftest.err 1>&5
7371 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
7372 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7373 if diff conftest.exp conftest.er2 >/dev/null; then
7374 lt_cv_prog_compiler_static_works=yes
7375 fi
7376 else
7377 lt_cv_prog_compiler_static_works=yes
7378 fi
7379 fi
7380 $RM -r conftest*
7381 LDFLAGS="$save_LDFLAGS"
7382
7383 fi
7384 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
7385 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
7386
7387 if test x"$lt_cv_prog_compiler_static_works" = xyes; then
7388 :
7389 else
7390 lt_prog_compiler_static=
7391 fi
7392
7393
7394
7395
7396
7397
7398
7399 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
7400 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
7401 if ${lt_cv_prog_compiler_c_o+:} false; then :
7402 $as_echo_n "(cached) " >&6
7403 else
7404 lt_cv_prog_compiler_c_o=no
7405 $RM -r conftest 2>/dev/null
7406 mkdir conftest
7407 cd conftest
7408 mkdir out
7409 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7410
7411 lt_compiler_flag="-o out/conftest2.$ac_objext"
7412 # Insert the option either (1) after the last *FLAGS variable, or
7413 # (2) before a word containing "conftest.", or (3) at the end.
7414 # Note that $ac_compile itself does not contain backslashes and begins
7415 # with a dollar sign (not a hyphen), so the echo should work correctly.
7416 lt_compile=`echo "$ac_compile" | $SED \
7417 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7418 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7419 -e 's:$: $lt_compiler_flag:'`
7420 (eval echo "\"\$as_me:7421: $lt_compile\"" >&5)
7421 (eval "$lt_compile" 2>out/conftest.err)
7422 ac_status=$?
7423 cat out/conftest.err >&5
7424 echo "$as_me:7425: \$? = $ac_status" >&5
7425 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7426 then
7427 # The compiler can only warn and ignore the option if not recognized
7428 # So say no if there are warnings
7429 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
7430 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7431 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7432 lt_cv_prog_compiler_c_o=yes
7433 fi
7434 fi
7435 chmod u+w . 2>&5
7436 $RM conftest*
7437 # SGI C++ compiler will create directory out/ii_files/ for
7438 # template instantiation
7439 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7440 $RM out/* && rmdir out
7441 cd ..
7442 $RM -r conftest
7443 $RM conftest*
7444
7445 fi
7446 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
7447 $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
7448
7449
7450
7451
7452
7453
7454 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
7455 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
7456 if ${lt_cv_prog_compiler_c_o+:} false; then :
7457 $as_echo_n "(cached) " >&6
7458 else
7459 lt_cv_prog_compiler_c_o=no
7460 $RM -r conftest 2>/dev/null
7461 mkdir conftest
7462 cd conftest
7463 mkdir out
7464 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7465
7466 lt_compiler_flag="-o out/conftest2.$ac_objext"
7467 # Insert the option either (1) after the last *FLAGS variable, or
7468 # (2) before a word containing "conftest.", or (3) at the end.
7469 # Note that $ac_compile itself does not contain backslashes and begins
7470 # with a dollar sign (not a hyphen), so the echo should work correctly.
7471 lt_compile=`echo "$ac_compile" | $SED \
7472 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7473 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7474 -e 's:$: $lt_compiler_flag:'`
7475 (eval echo "\"\$as_me:7476: $lt_compile\"" >&5)
7476 (eval "$lt_compile" 2>out/conftest.err)
7477 ac_status=$?
7478 cat out/conftest.err >&5
7479 echo "$as_me:7480: \$? = $ac_status" >&5
7480 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7481 then
7482 # The compiler can only warn and ignore the option if not recognized
7483 # So say no if there are warnings
7484 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
7485 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7486 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7487 lt_cv_prog_compiler_c_o=yes
7488 fi
7489 fi
7490 chmod u+w . 2>&5
7491 $RM conftest*
7492 # SGI C++ compiler will create directory out/ii_files/ for
7493 # template instantiation
7494 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7495 $RM out/* && rmdir out
7496 cd ..
7497 $RM -r conftest
7498 $RM conftest*
7499
7500 fi
7501 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
7502 $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
7503
7504
7505
7506
7507 hard_links="nottested"
7508 if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
7509 # do not overwrite the value of need_locks provided by the user
7510 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
7511 $as_echo_n "checking if we can lock with hard links... " >&6; }
7512 hard_links=yes
7513 $RM conftest*
7514 ln conftest.a conftest.b 2>/dev/null && hard_links=no
7515 touch conftest.a
7516 ln conftest.a conftest.b 2>&5 || hard_links=no
7517 ln conftest.a conftest.b 2>/dev/null && hard_links=no
7518 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
7519 $as_echo "$hard_links" >&6; }
7520 if test "$hard_links" = no; then
7521 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
7522 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
7523 need_locks=warn
7524 fi
7525 else
7526 need_locks=no
7527 fi
7528
7529
7530
7531
7532
7533
7534 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
7535 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
7536
7537 runpath_var=
7538 allow_undefined_flag=
7539 always_export_symbols=no
7540 archive_cmds=
7541 archive_expsym_cmds=
7542 compiler_needs_object=no
7543 enable_shared_with_static_runtimes=no
7544 export_dynamic_flag_spec=
7545 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
7546 hardcode_automatic=no
7547 hardcode_direct=no
7548 hardcode_direct_absolute=no
7549 hardcode_libdir_flag_spec=
7550 hardcode_libdir_flag_spec_ld=
7551 hardcode_libdir_separator=
7552 hardcode_minus_L=no
7553 hardcode_shlibpath_var=unsupported
7554 inherit_rpath=no
7555 link_all_deplibs=unknown
7556 module_cmds=
7557 module_expsym_cmds=
7558 old_archive_from_new_cmds=
7559 old_archive_from_expsyms_cmds=
7560 thread_safe_flag_spec=
7561 whole_archive_flag_spec=
7562 # include_expsyms should be a list of space-separated symbols to be *always*
7563 # included in the symbol list
7564 include_expsyms=
7565 # exclude_expsyms can be an extended regexp of symbols to exclude
7566 # it will be wrapped by ` (' and `)$', so one must not match beginning or
7567 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
7568 # as well as any symbol that contains `d'.
7569 exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
7570 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
7571 # platforms (ab)use it in PIC code, but their linkers get confused if
7572 # the symbol is explicitly referenced. Since portable code cannot
7573 # rely on this symbol name, it's probably fine to never include it in
7574 # preloaded symbol tables.
7575 # Exclude shared library initialization/finalization symbols.
7576 extract_expsyms_cmds=
7577
7578 case $host_os in
7579 cygwin* | mingw* | pw32* | cegcc*)
7580 # FIXME: the MSVC++ port hasn't been tested in a loooong time
7581 # When not using gcc, we currently assume that we are using
7582 # Microsoft Visual C++.
7583 if test "$GCC" != yes; then
7584 with_gnu_ld=no
7585 fi
7586 ;;
7587 interix*)
7588 # we just hope/assume this is gcc and not c89 (= MSVC++)
7589 with_gnu_ld=yes
7590 ;;
7591 openbsd*)
7592 with_gnu_ld=no
7593 ;;
7594 esac
7595
7596 ld_shlibs=yes
7597 if test "$with_gnu_ld" = yes; then
7598 # If archive_cmds runs LD, not CC, wlarc should be empty
7599 wlarc='${wl}'
7600
7601 # Set some defaults for GNU ld with shared library support. These
7602 # are reset later if shared libraries are not supported. Putting them
7603 # here allows them to be overridden if necessary.
7604 runpath_var=LD_RUN_PATH
7605 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
7606 export_dynamic_flag_spec='${wl}--export-dynamic'
7607 # ancient GNU ld didn't support --whole-archive et. al.
7608 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
7609 whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
7610 else
7611 whole_archive_flag_spec=
7612 fi
7613 supports_anon_versioning=no
7614 case `$LD -v 2>&1` in
7615 *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
7616 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
7617 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
7618 *\ 2.11.*) ;; # other 2.11 versions
7619 *) supports_anon_versioning=yes ;;
7620 esac
7621
7622 # See if GNU ld supports shared libraries.
7623 case $host_os in
7624 aix[3-9]*)
7625 # On AIX/PPC, the GNU linker is very broken
7626 if test "$host_cpu" != ia64; then
7627 ld_shlibs=no
7628 cat <<_LT_EOF 1>&2
7629
7630 *** Warning: the GNU linker, at least up to release 2.9.1, is reported
7631 *** to be unable to reliably create shared libraries on AIX.
7632 *** Therefore, libtool is disabling shared libraries support. If you
7633 *** really care for shared libraries, you may want to modify your PATH
7634 *** so that a non-GNU linker is found, and then restart.
7635
7636 _LT_EOF
7637 fi
7638 ;;
7639
7640 amigaos*)
7641 case $host_cpu in
7642 powerpc)
7643 # see comment about AmigaOS4 .so support
7644 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7645 archive_expsym_cmds=''
7646 ;;
7647 m68k)
7648 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)'
7649 hardcode_libdir_flag_spec='-L$libdir'
7650 hardcode_minus_L=yes
7651 ;;
7652 esac
7653 ;;
7654
7655 beos*)
7656 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
7657 allow_undefined_flag=unsupported
7658 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
7659 # support --undefined. This deserves some investigation. FIXME
7660 archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7661 else
7662 ld_shlibs=no
7663 fi
7664 ;;
7665
7666 cygwin* | mingw* | pw32* | cegcc*)
7667 # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
7668 # as there is no search path for DLLs.
7669 hardcode_libdir_flag_spec='-L$libdir'
7670 allow_undefined_flag=unsupported
7671 always_export_symbols=no
7672 enable_shared_with_static_runtimes=yes
7673 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
7674
7675 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
7676 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
7677 # If the export-symbols file already is a .def file (1st line
7678 # is EXPORTS), use it as is; otherwise, prepend...
7679 archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
7680 cp $export_symbols $output_objdir/$soname.def;
7681 else
7682 echo EXPORTS > $output_objdir/$soname.def;
7683 cat $export_symbols >> $output_objdir/$soname.def;
7684 fi~
7685 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
7686 else
7687 ld_shlibs=no
7688 fi
7689 ;;
7690
7691 interix[3-9]*)
7692 hardcode_direct=no
7693 hardcode_shlibpath_var=no
7694 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
7695 export_dynamic_flag_spec='${wl}-E'
7696 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
7697 # Instead, shared libraries are loaded at an image base (0x10000000 by
7698 # default) and relocated if they conflict, which is a slow very memory
7699 # consuming and fragmenting process. To avoid this, we pick a random,
7700 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
7701 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
7702 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
7703 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'
7704 ;;
7705
7706 gnu* | linux* | tpf* | k*bsd*-gnu)
7707 tmp_diet=no
7708 if test "$host_os" = linux-dietlibc; then
7709 case $cc_basename in
7710 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
7711 esac
7712 fi
7713 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
7714 && test "$tmp_diet" = no
7715 then
7716 tmp_addflag=
7717 tmp_sharedflag='-shared'
7718 case $cc_basename,$host_cpu in
7719 pgcc*) # Portland Group C compiler
7720 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'
7721 tmp_addflag=' $pic_flag'
7722 ;;
7723 pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
7724 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'
7725 tmp_addflag=' $pic_flag -Mnomain' ;;
7726 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
7727 tmp_addflag=' -i_dynamic' ;;
7728 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
7729 tmp_addflag=' -i_dynamic -nofor_main' ;;
7730 ifc* | ifort*) # Intel Fortran compiler
7731 tmp_addflag=' -nofor_main' ;;
7732 lf95*) # Lahey Fortran 8.1
7733 whole_archive_flag_spec=
7734 tmp_sharedflag='--shared' ;;
7735 xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
7736 tmp_sharedflag='-qmkshrobj'
7737 tmp_addflag= ;;
7738 esac
7739 case `$CC -V 2>&1 | sed 5q` in
7740 *Sun\ C*) # Sun C 5.9
7741 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'
7742 compiler_needs_object=yes
7743 tmp_sharedflag='-G' ;;
7744 *Sun\ F*) # Sun Fortran 8.3
7745 tmp_sharedflag='-G' ;;
7746 esac
7747 archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7748
7749 if test "x$supports_anon_versioning" = xyes; then
7750 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
7751 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
7752 echo "local: *; };" >> $output_objdir/$libname.ver~
7753 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
7754 fi
7755
7756 case $cc_basename in
7757 xlf*)
7758 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
7759 whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
7760 hardcode_libdir_flag_spec=
7761 hardcode_libdir_flag_spec_ld='-rpath $libdir'
7762 archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
7763 if test "x$supports_anon_versioning" = xyes; then
7764 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
7765 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
7766 echo "local: *; };" >> $output_objdir/$libname.ver~
7767 $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
7768 fi
7769 ;;
7770 esac
7771 else
7772 ld_shlibs=no
7773 fi
7774 ;;
7775
7776 netbsd*)
7777 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
7778 archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
7779 wlarc=
7780 else
7781 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7782 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
7783 fi
7784 ;;
7785
7786 solaris*)
7787 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
7788 ld_shlibs=no
7789 cat <<_LT_EOF 1>&2
7790
7791 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
7792 *** create shared libraries on Solaris systems. Therefore, libtool
7793 *** is disabling shared libraries support. We urge you to upgrade GNU
7794 *** binutils to release 2.9.1 or newer. Another option is to modify
7795 *** your PATH or compiler configuration so that the native linker is
7796 *** used, and then restart.
7797
7798 _LT_EOF
7799 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
7800 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7801 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
7802 else
7803 ld_shlibs=no
7804 fi
7805 ;;
7806
7807 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
7808 case `$LD -v 2>&1` in
7809 *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
7810 ld_shlibs=no
7811 cat <<_LT_EOF 1>&2
7812
7813 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
7814 *** reliably create shared libraries on SCO systems. Therefore, libtool
7815 *** is disabling shared libraries support. We urge you to upgrade GNU
7816 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
7817 *** your PATH or compiler configuration so that the native linker is
7818 *** used, and then restart.
7819
7820 _LT_EOF
7821 ;;
7822 *)
7823 # For security reasons, it is highly recommended that you always
7824 # use absolute paths for naming shared libraries, and exclude the
7825 # DT_RUNPATH tag from executables and libraries. But doing so
7826 # requires that you compile everything twice, which is a pain.
7827 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
7828 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
7829 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7830 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
7831 else
7832 ld_shlibs=no
7833 fi
7834 ;;
7835 esac
7836 ;;
7837
7838 sunos4*)
7839 archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
7840 wlarc=
7841 hardcode_direct=yes
7842 hardcode_shlibpath_var=no
7843 ;;
7844
7845 *)
7846 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
7847 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7848 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
7849 else
7850 ld_shlibs=no
7851 fi
7852 ;;
7853 esac
7854
7855 if test "$ld_shlibs" = no; then
7856 runpath_var=
7857 hardcode_libdir_flag_spec=
7858 export_dynamic_flag_spec=
7859 whole_archive_flag_spec=
7860 fi
7861 else
7862 # PORTME fill in a description of your system's linker (not GNU ld)
7863 case $host_os in
7864 aix3*)
7865 allow_undefined_flag=unsupported
7866 always_export_symbols=yes
7867 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'
7868 # Note: this linker hardcodes the directories in LIBPATH if there
7869 # are no directories specified by -L.
7870 hardcode_minus_L=yes
7871 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
7872 # Neither direct hardcoding nor static linking is supported with a
7873 # broken collect2.
7874 hardcode_direct=unsupported
7875 fi
7876 ;;
7877
7878 aix[4-9]*)
7879 if test "$host_cpu" = ia64; then
7880 # On IA64, the linker does run time linking by default, so we don't
7881 # have to do anything special.
7882 aix_use_runtimelinking=no
7883 exp_sym_flag='-Bexport'
7884 no_entry_flag=""
7885 else
7886 # If we're using GNU nm, then we don't want the "-C" option.
7887 # -C means demangle to AIX nm, but means don't demangle with GNU nm
7888 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
7889 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'
7890 else
7891 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'
7892 fi
7893 aix_use_runtimelinking=no
7894
7895 # Test if we are trying to use run time linking or normal
7896 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
7897 # need to do runtime linking.
7898 case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
7899 for ld_flag in $LDFLAGS; do
7900 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
7901 aix_use_runtimelinking=yes
7902 break
7903 fi
7904 done
7905 ;;
7906 esac
7907
7908 exp_sym_flag='-bexport'
7909 no_entry_flag='-bnoentry'
7910 fi
7911
7912 # When large executables or shared objects are built, AIX ld can
7913 # have problems creating the table of contents. If linking a library
7914 # or program results in "error TOC overflow" add -mminimal-toc to
7915 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
7916 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
7917
7918 archive_cmds=''
7919 hardcode_direct=yes
7920 hardcode_direct_absolute=yes
7921 hardcode_libdir_separator=':'
7922 link_all_deplibs=yes
7923 file_list_spec='${wl}-f,'
7924
7925 if test "$GCC" = yes; then
7926 case $host_os in aix4.[012]|aix4.[012].*)
7927 # We only want to do this on AIX 4.2 and lower, the check
7928 # below for broken collect2 doesn't work under 4.3+
7929 collect2name=`${CC} -print-prog-name=collect2`
7930 if test -f "$collect2name" &&
7931 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
7932 then
7933 # We have reworked collect2
7934 :
7935 else
7936 # We have old collect2
7937 hardcode_direct=unsupported
7938 # It fails to find uninstalled libraries when the uninstalled
7939 # path is not listed in the libpath. Setting hardcode_minus_L
7940 # to unsupported forces relinking
7941 hardcode_minus_L=yes
7942 hardcode_libdir_flag_spec='-L$libdir'
7943 hardcode_libdir_separator=
7944 fi
7945 ;;
7946 esac
7947 shared_flag='-shared'
7948 if test "$aix_use_runtimelinking" = yes; then
7949 shared_flag="$shared_flag "'${wl}-G'
7950 fi
7951 else
7952 # not using gcc
7953 if test "$host_cpu" = ia64; then
7954 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
7955 # chokes on -Wl,-G. The following line is correct:
7956 shared_flag='-G'
7957 else
7958 if test "$aix_use_runtimelinking" = yes; then
7959 shared_flag='${wl}-G'
7960 else
7961 shared_flag='${wl}-bM:SRE'
7962 fi
7963 fi
7964 fi
7965
7966 export_dynamic_flag_spec='${wl}-bexpall'
7967 # It seems that -bexpall does not export symbols beginning with
7968 # underscore (_), so it is better to generate a list of symbols to export.
7969 always_export_symbols=yes
7970 if test "$aix_use_runtimelinking" = yes; then
7971 # Warning - without using the other runtime loading flags (-brtl),
7972 # -berok will link without error, but may produce a broken library.
7973 allow_undefined_flag='-berok'
7974 # Determine the default libpath from the value encoded in an
7975 # empty executable.
7976 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7977 /* end confdefs.h. */
7978
7979 int
7980 main ()
7981 {
7982
7983 ;
7984 return 0;
7985 }
7986 _ACEOF
7987 if ac_fn_c_try_link "$LINENO"; then :
7988
7989 lt_aix_libpath_sed='
7990 /Import File Strings/,/^$/ {
7991 /^0/ {
7992 s/^0 *\(.*\)$/\1/
7993 p
7994 }
7995 }'
7996 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
7997 # Check for a 64-bit object if we didn't find anything.
7998 if test -z "$aix_libpath"; then
7999 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8000 fi
8001 fi
8002 rm -f core conftest.err conftest.$ac_objext \
8003 conftest$ac_exeext conftest.$ac_ext
8004 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
8005
8006 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8007 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"
8008 else
8009 if test "$host_cpu" = ia64; then
8010 hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
8011 allow_undefined_flag="-z nodefs"
8012 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"
8013 else
8014 # Determine the default libpath from the value encoded in an
8015 # empty executable.
8016 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8017 /* end confdefs.h. */
8018
8019 int
8020 main ()
8021 {
8022
8023 ;
8024 return 0;
8025 }
8026 _ACEOF
8027 if ac_fn_c_try_link "$LINENO"; then :
8028
8029 lt_aix_libpath_sed='
8030 /Import File Strings/,/^$/ {
8031 /^0/ {
8032 s/^0 *\(.*\)$/\1/
8033 p
8034 }
8035 }'
8036 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8037 # Check for a 64-bit object if we didn't find anything.
8038 if test -z "$aix_libpath"; then
8039 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8040 fi
8041 fi
8042 rm -f core conftest.err conftest.$ac_objext \
8043 conftest$ac_exeext conftest.$ac_ext
8044 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
8045
8046 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8047 # Warning - without using the other run time loading flags,
8048 # -berok will link without error, but may produce a broken library.
8049 no_undefined_flag=' ${wl}-bernotok'
8050 allow_undefined_flag=' ${wl}-berok'
8051 # Exported symbols can be pulled into shared objects from archives
8052 whole_archive_flag_spec='$convenience'
8053 archive_cmds_need_lc=yes
8054 # This is similar to how AIX traditionally builds its shared libraries.
8055 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'
8056 fi
8057 fi
8058 ;;
8059
8060 amigaos*)
8061 case $host_cpu in
8062 powerpc)
8063 # see comment about AmigaOS4 .so support
8064 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8065 archive_expsym_cmds=''
8066 ;;
8067 m68k)
8068 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)'
8069 hardcode_libdir_flag_spec='-L$libdir'
8070 hardcode_minus_L=yes
8071 ;;
8072 esac
8073 ;;
8074
8075 bsdi[45]*)
8076 export_dynamic_flag_spec=-rdynamic
8077 ;;
8078
8079 cygwin* | mingw* | pw32* | cegcc*)
8080 # When not using gcc, we currently assume that we are using
8081 # Microsoft Visual C++.
8082 # hardcode_libdir_flag_spec is actually meaningless, as there is
8083 # no search path for DLLs.
8084 hardcode_libdir_flag_spec=' '
8085 allow_undefined_flag=unsupported
8086 # Tell ltmain to make .lib files, not .a files.
8087 libext=lib
8088 # Tell ltmain to make .dll files, not .so files.
8089 shrext_cmds=".dll"
8090 # FIXME: Setting linknames here is a bad hack.
8091 archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
8092 # The linker will automatically build a .lib file if we build a DLL.
8093 old_archive_from_new_cmds='true'
8094 # FIXME: Should let the user specify the lib program.
8095 old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
8096 fix_srcfile_path='`cygpath -w "$srcfile"`'
8097 enable_shared_with_static_runtimes=yes
8098 ;;
8099
8100 darwin* | rhapsody*)
8101
8102
8103 archive_cmds_need_lc=no
8104 hardcode_direct=no
8105 hardcode_automatic=yes
8106 hardcode_shlibpath_var=unsupported
8107 whole_archive_flag_spec=''
8108 link_all_deplibs=yes
8109 allow_undefined_flag="$_lt_dar_allow_undefined"
8110 case $cc_basename in
8111 ifort*) _lt_dar_can_shared=yes ;;
8112 *) _lt_dar_can_shared=$GCC ;;
8113 esac
8114 if test "$_lt_dar_can_shared" = "yes"; then
8115 output_verbose_link_cmd=echo
8116 archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
8117 module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
8118 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}"
8119 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}"
8120
8121 else
8122 ld_shlibs=no
8123 fi
8124
8125 ;;
8126
8127 dgux*)
8128 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8129 hardcode_libdir_flag_spec='-L$libdir'
8130 hardcode_shlibpath_var=no
8131 ;;
8132
8133 freebsd1*)
8134 ld_shlibs=no
8135 ;;
8136
8137 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
8138 # support. Future versions do this automatically, but an explicit c++rt0.o
8139 # does not break anything, and helps significantly (at the cost of a little
8140 # extra space).
8141 freebsd2.2*)
8142 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
8143 hardcode_libdir_flag_spec='-R$libdir'
8144 hardcode_direct=yes
8145 hardcode_shlibpath_var=no
8146 ;;
8147
8148 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
8149 freebsd2*)
8150 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8151 hardcode_direct=yes
8152 hardcode_minus_L=yes
8153 hardcode_shlibpath_var=no
8154 ;;
8155
8156 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
8157 freebsd* | dragonfly*)
8158 archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
8159 hardcode_libdir_flag_spec='-R$libdir'
8160 hardcode_direct=yes
8161 hardcode_shlibpath_var=no
8162 ;;
8163
8164 hpux9*)
8165 if test "$GCC" = yes; then
8166 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'
8167 else
8168 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'
8169 fi
8170 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8171 hardcode_libdir_separator=:
8172 hardcode_direct=yes
8173
8174 # hardcode_minus_L: Not really in the search PATH,
8175 # but as the default location of the library.
8176 hardcode_minus_L=yes
8177 export_dynamic_flag_spec='${wl}-E'
8178 ;;
8179
8180 hpux10*)
8181 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
8182 archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8183 else
8184 archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
8185 fi
8186 if test "$with_gnu_ld" = no; then
8187 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8188 hardcode_libdir_flag_spec_ld='+b $libdir'
8189 hardcode_libdir_separator=:
8190 hardcode_direct=yes
8191 hardcode_direct_absolute=yes
8192 export_dynamic_flag_spec='${wl}-E'
8193 # hardcode_minus_L: Not really in the search PATH,
8194 # but as the default location of the library.
8195 hardcode_minus_L=yes
8196 fi
8197 ;;
8198
8199 hpux11*)
8200 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
8201 case $host_cpu in
8202 hppa*64*)
8203 archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8204 ;;
8205 ia64*)
8206 archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8207 ;;
8208 *)
8209 archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8210 ;;
8211 esac
8212 else
8213 case $host_cpu in
8214 hppa*64*)
8215 archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8216 ;;
8217 ia64*)
8218 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8219 ;;
8220 *)
8221 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8222 ;;
8223 esac
8224 fi
8225 if test "$with_gnu_ld" = no; then
8226 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8227 hardcode_libdir_separator=:
8228
8229 case $host_cpu in
8230 hppa*64*|ia64*)
8231 hardcode_direct=no
8232 hardcode_shlibpath_var=no
8233 ;;
8234 *)
8235 hardcode_direct=yes
8236 hardcode_direct_absolute=yes
8237 export_dynamic_flag_spec='${wl}-E'
8238
8239 # hardcode_minus_L: Not really in the search PATH,
8240 # but as the default location of the library.
8241 hardcode_minus_L=yes
8242 ;;
8243 esac
8244 fi
8245 ;;
8246
8247 irix5* | irix6* | nonstopux*)
8248 if test "$GCC" = yes; then
8249 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'
8250 # Try to use the -exported_symbol ld option, if it does not
8251 # work, assume that -exports_file does not work either and
8252 # implicitly export all symbols.
8253 save_LDFLAGS="$LDFLAGS"
8254 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
8255 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8256 /* end confdefs.h. */
8257 int foo(void) {}
8258 _ACEOF
8259 if ac_fn_c_try_link "$LINENO"; then :
8260 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'
8261
8262 fi
8263 rm -f core conftest.err conftest.$ac_objext \
8264 conftest$ac_exeext conftest.$ac_ext
8265 LDFLAGS="$save_LDFLAGS"
8266 else
8267 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'
8268 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'
8269 fi
8270 archive_cmds_need_lc='no'
8271 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8272 hardcode_libdir_separator=:
8273 inherit_rpath=yes
8274 link_all_deplibs=yes
8275 ;;
8276
8277 netbsd*)
8278 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
8279 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
8280 else
8281 archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
8282 fi
8283 hardcode_libdir_flag_spec='-R$libdir'
8284 hardcode_direct=yes
8285 hardcode_shlibpath_var=no
8286 ;;
8287
8288 newsos6)
8289 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8290 hardcode_direct=yes
8291 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8292 hardcode_libdir_separator=:
8293 hardcode_shlibpath_var=no
8294 ;;
8295
8296 *nto* | *qnx*)
8297 ;;
8298
8299 openbsd*)
8300 if test -f /usr/libexec/ld.so; then
8301 hardcode_direct=yes
8302 hardcode_shlibpath_var=no
8303 hardcode_direct_absolute=yes
8304 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
8305 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8306 archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
8307 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8308 export_dynamic_flag_spec='${wl}-E'
8309 else
8310 case $host_os in
8311 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
8312 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8313 hardcode_libdir_flag_spec='-R$libdir'
8314 ;;
8315 *)
8316 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8317 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8318 ;;
8319 esac
8320 fi
8321 else
8322 ld_shlibs=no
8323 fi
8324 ;;
8325
8326 os2*)
8327 hardcode_libdir_flag_spec='-L$libdir'
8328 hardcode_minus_L=yes
8329 allow_undefined_flag=unsupported
8330 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'
8331 old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
8332 ;;
8333
8334 osf3*)
8335 if test "$GCC" = yes; then
8336 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8337 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'
8338 else
8339 allow_undefined_flag=' -expect_unresolved \*'
8340 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'
8341 fi
8342 archive_cmds_need_lc='no'
8343 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8344 hardcode_libdir_separator=:
8345 ;;
8346
8347 osf4* | osf5*) # as osf3* with the addition of -msym flag
8348 if test "$GCC" = yes; then
8349 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8350 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'
8351 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8352 else
8353 allow_undefined_flag=' -expect_unresolved \*'
8354 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'
8355 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~
8356 $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'
8357
8358 # Both c and cxx compiler support -rpath directly
8359 hardcode_libdir_flag_spec='-rpath $libdir'
8360 fi
8361 archive_cmds_need_lc='no'
8362 hardcode_libdir_separator=:
8363 ;;
8364
8365 solaris*)
8366 no_undefined_flag=' -z defs'
8367 if test "$GCC" = yes; then
8368 wlarc='${wl}'
8369 archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8370 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8371 $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8372 else
8373 case `$CC -V 2>&1` in
8374 *"Compilers 5.0"*)
8375 wlarc=''
8376 archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
8377 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8378 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
8379 ;;
8380 *)
8381 wlarc='${wl}'
8382 archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
8383 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8384 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8385 ;;
8386 esac
8387 fi
8388 hardcode_libdir_flag_spec='-R$libdir'
8389 hardcode_shlibpath_var=no
8390 case $host_os in
8391 solaris2.[0-5] | solaris2.[0-5].*) ;;
8392 *)
8393 # The compiler driver will combine and reorder linker options,
8394 # but understands `-z linker_flag'. GCC discards it without `$wl',
8395 # but is careful enough not to reorder.
8396 # Supported since Solaris 2.6 (maybe 2.5.1?)
8397 if test "$GCC" = yes; then
8398 whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
8399 else
8400 whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
8401 fi
8402 ;;
8403 esac
8404 link_all_deplibs=yes
8405 ;;
8406
8407 sunos4*)
8408 if test "x$host_vendor" = xsequent; then
8409 # Use $CC to link under sequent, because it throws in some extra .o
8410 # files that make .init and .fini sections work.
8411 archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
8412 else
8413 archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
8414 fi
8415 hardcode_libdir_flag_spec='-L$libdir'
8416 hardcode_direct=yes
8417 hardcode_minus_L=yes
8418 hardcode_shlibpath_var=no
8419 ;;
8420
8421 sysv4)
8422 case $host_vendor in
8423 sni)
8424 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8425 hardcode_direct=yes # is this really true???
8426 ;;
8427 siemens)
8428 ## LD is ld it makes a PLAMLIB
8429 ## CC just makes a GrossModule.
8430 archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
8431 reload_cmds='$CC -r -o $output$reload_objs'
8432 hardcode_direct=no
8433 ;;
8434 motorola)
8435 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8436 hardcode_direct=no #Motorola manual says yes, but my tests say they lie
8437 ;;
8438 esac
8439 runpath_var='LD_RUN_PATH'
8440 hardcode_shlibpath_var=no
8441 ;;
8442
8443 sysv4.3*)
8444 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8445 hardcode_shlibpath_var=no
8446 export_dynamic_flag_spec='-Bexport'
8447 ;;
8448
8449 sysv4*MP*)
8450 if test -d /usr/nec; then
8451 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8452 hardcode_shlibpath_var=no
8453 runpath_var=LD_RUN_PATH
8454 hardcode_runpath_var=yes
8455 ld_shlibs=yes
8456 fi
8457 ;;
8458
8459 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
8460 no_undefined_flag='${wl}-z,text'
8461 archive_cmds_need_lc=no
8462 hardcode_shlibpath_var=no
8463 runpath_var='LD_RUN_PATH'
8464
8465 if test "$GCC" = yes; then
8466 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8467 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8468 else
8469 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8470 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8471 fi
8472 ;;
8473
8474 sysv5* | sco3.2v5* | sco5v6*)
8475 # Note: We can NOT use -z defs as we might desire, because we do not
8476 # link with -lc, and that would cause any symbols used from libc to
8477 # always be unresolved, which means just about no library would
8478 # ever link correctly. If we're not using GNU ld we use -z text
8479 # though, which does catch some bad symbols but isn't as heavy-handed
8480 # as -z defs.
8481 no_undefined_flag='${wl}-z,text'
8482 allow_undefined_flag='${wl}-z,nodefs'
8483 archive_cmds_need_lc=no
8484 hardcode_shlibpath_var=no
8485 hardcode_libdir_flag_spec='${wl}-R,$libdir'
8486 hardcode_libdir_separator=':'
8487 link_all_deplibs=yes
8488 export_dynamic_flag_spec='${wl}-Bexport'
8489 runpath_var='LD_RUN_PATH'
8490
8491 if test "$GCC" = yes; then
8492 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8493 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8494 else
8495 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8496 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8497 fi
8498 ;;
8499
8500 uts4*)
8501 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8502 hardcode_libdir_flag_spec='-L$libdir'
8503 hardcode_shlibpath_var=no
8504 ;;
8505
8506 *)
8507 ld_shlibs=no
8508 ;;
8509 esac
8510
8511 if test x$host_vendor = xsni; then
8512 case $host in
8513 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
8514 export_dynamic_flag_spec='${wl}-Blargedynsym'
8515 ;;
8516 esac
8517 fi
8518 fi
8519
8520 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
8521 $as_echo "$ld_shlibs" >&6; }
8522 test "$ld_shlibs" = no && can_build_shared=no
8523
8524 with_gnu_ld=$with_gnu_ld
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540 #
8541 # Do we need to explicitly link libc?
8542 #
8543 case "x$archive_cmds_need_lc" in
8544 x|xyes)
8545 # Assume -lc should be added
8546 archive_cmds_need_lc=yes
8547
8548 if test "$enable_shared" = yes && test "$GCC" = yes; then
8549 case $archive_cmds in
8550 *'~'*)
8551 # FIXME: we may have to deal with multi-command sequences.
8552 ;;
8553 '$CC '*)
8554 # Test whether the compiler implicitly links with -lc since on some
8555 # systems, -lgcc has to come before -lc. If gcc already passes -lc
8556 # to ld, don't add -lc before -lgcc.
8557 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
8558 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
8559 $RM conftest*
8560 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
8561
8562 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
8563 (eval $ac_compile) 2>&5
8564 ac_status=$?
8565 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8566 test $ac_status = 0; } 2>conftest.err; then
8567 soname=conftest
8568 lib=conftest
8569 libobjs=conftest.$ac_objext
8570 deplibs=
8571 wl=$lt_prog_compiler_wl
8572 pic_flag=$lt_prog_compiler_pic
8573 compiler_flags=-v
8574 linker_flags=-v
8575 verstring=
8576 output_objdir=.
8577 libname=conftest
8578 lt_save_allow_undefined_flag=$allow_undefined_flag
8579 allow_undefined_flag=
8580 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
8581 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
8582 ac_status=$?
8583 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8584 test $ac_status = 0; }
8585 then
8586 archive_cmds_need_lc=no
8587 else
8588 archive_cmds_need_lc=yes
8589 fi
8590 allow_undefined_flag=$lt_save_allow_undefined_flag
8591 else
8592 cat conftest.err 1>&5
8593 fi
8594 $RM conftest*
8595 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5
8596 $as_echo "$archive_cmds_need_lc" >&6; }
8597 ;;
8598 esac
8599 fi
8600 ;;
8601 esac
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
8760 $as_echo_n "checking dynamic linker characteristics... " >&6; }
8761
8762 if test "$GCC" = yes; then
8763 case $host_os in
8764 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
8765 *) lt_awk_arg="/^libraries:/" ;;
8766 esac
8767 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
8768 if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
8769 # if the path contains ";" then we assume it to be the separator
8770 # otherwise default to the standard path separator (i.e. ":") - it is
8771 # assumed that no part of a normal pathname contains ";" but that should
8772 # okay in the real world where ";" in dirpaths is itself problematic.
8773 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
8774 else
8775 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
8776 fi
8777 # Ok, now we have the path, separated by spaces, we can step through it
8778 # and add multilib dir if necessary.
8779 lt_tmp_lt_search_path_spec=
8780 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
8781 for lt_sys_path in $lt_search_path_spec; do
8782 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
8783 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
8784 else
8785 test -d "$lt_sys_path" && \
8786 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
8787 fi
8788 done
8789 lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
8790 BEGIN {RS=" "; FS="/|\n";} {
8791 lt_foo="";
8792 lt_count=0;
8793 for (lt_i = NF; lt_i > 0; lt_i--) {
8794 if ($lt_i != "" && $lt_i != ".") {
8795 if ($lt_i == "..") {
8796 lt_count++;
8797 } else {
8798 if (lt_count == 0) {
8799 lt_foo="/" $lt_i lt_foo;
8800 } else {
8801 lt_count--;
8802 }
8803 }
8804 }
8805 }
8806 if (lt_foo != "") { lt_freq[lt_foo]++; }
8807 if (lt_freq[lt_foo] == 1) { print lt_foo; }
8808 }'`
8809 sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
8810 else
8811 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
8812 fi
8813 library_names_spec=
8814 libname_spec='lib$name'
8815 soname_spec=
8816 shrext_cmds=".so"
8817 postinstall_cmds=
8818 postuninstall_cmds=
8819 finish_cmds=
8820 finish_eval=
8821 shlibpath_var=
8822 shlibpath_overrides_runpath=unknown
8823 version_type=none
8824 dynamic_linker="$host_os ld.so"
8825 sys_lib_dlsearch_path_spec="/lib /usr/lib"
8826 need_lib_prefix=unknown
8827 hardcode_into_libs=no
8828
8829 # when you set need_version to no, make sure it does not cause -set_version
8830 # flags to be left without arguments
8831 need_version=unknown
8832
8833 case $host_os in
8834 aix3*)
8835 version_type=linux
8836 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
8837 shlibpath_var=LIBPATH
8838
8839 # AIX 3 has no versioning support, so we append a major version to the name.
8840 soname_spec='${libname}${release}${shared_ext}$major'
8841 ;;
8842
8843 aix[4-9]*)
8844 version_type=linux
8845 need_lib_prefix=no
8846 need_version=no
8847 hardcode_into_libs=yes
8848 if test "$host_cpu" = ia64; then
8849 # AIX 5 supports IA64
8850 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
8851 shlibpath_var=LD_LIBRARY_PATH
8852 else
8853 # With GCC up to 2.95.x, collect2 would create an import file
8854 # for dependence libraries. The import file would start with
8855 # the line `#! .'. This would cause the generated library to
8856 # depend on `.', always an invalid library. This was fixed in
8857 # development snapshots of GCC prior to 3.0.
8858 case $host_os in
8859 aix4 | aix4.[01] | aix4.[01].*)
8860 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
8861 echo ' yes '
8862 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
8863 :
8864 else
8865 can_build_shared=no
8866 fi
8867 ;;
8868 esac
8869 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
8870 # soname into executable. Probably we can add versioning support to
8871 # collect2, so additional links can be useful in future.
8872 if test "$aix_use_runtimelinking" = yes; then
8873 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
8874 # instead of lib<name>.a to let people know that these are not
8875 # typical AIX shared libraries.
8876 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
8877 else
8878 # We preserve .a as extension for shared libraries through AIX4.2
8879 # and later when we are not doing run time linking.
8880 library_names_spec='${libname}${release}.a $libname.a'
8881 soname_spec='${libname}${release}${shared_ext}$major'
8882 fi
8883 shlibpath_var=LIBPATH
8884 fi
8885 ;;
8886
8887 amigaos*)
8888 case $host_cpu in
8889 powerpc)
8890 # Since July 2007 AmigaOS4 officially supports .so libraries.
8891 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
8892 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
8893 ;;
8894 m68k)
8895 library_names_spec='$libname.ixlibrary $libname.a'
8896 # Create ${libname}_ixlibrary.a entries in /sys/libs.
8897 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'
8898 ;;
8899 esac
8900 ;;
8901
8902 beos*)
8903 library_names_spec='${libname}${shared_ext}'
8904 dynamic_linker="$host_os ld.so"
8905 shlibpath_var=LIBRARY_PATH
8906 ;;
8907
8908 bsdi[45]*)
8909 version_type=linux
8910 need_version=no
8911 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
8912 soname_spec='${libname}${release}${shared_ext}$major'
8913 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
8914 shlibpath_var=LD_LIBRARY_PATH
8915 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
8916 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
8917 # the default ld.so.conf also contains /usr/contrib/lib and
8918 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
8919 # libtool to hard-code these into programs
8920 ;;
8921
8922 cygwin* | mingw* | pw32* | cegcc*)
8923 version_type=windows
8924 shrext_cmds=".dll"
8925 need_version=no
8926 need_lib_prefix=no
8927
8928 case $GCC,$host_os in
8929 yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
8930 library_names_spec='$libname.dll.a'
8931 # DLL is installed to $(libdir)/../bin by postinstall_cmds
8932 postinstall_cmds='base_file=`basename \${file}`~
8933 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
8934 dldir=$destdir/`dirname \$dlpath`~
8935 test -d \$dldir || mkdir -p \$dldir~
8936 $install_prog $dir/$dlname \$dldir/$dlname~
8937 chmod a+x \$dldir/$dlname~
8938 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
8939 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
8940 fi'
8941 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
8942 dlpath=$dir/\$dldll~
8943 $RM \$dlpath'
8944 shlibpath_overrides_runpath=yes
8945
8946 case $host_os in
8947 cygwin*)
8948 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
8949 #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
8950 soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
8951 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
8952 ;;
8953 mingw* | cegcc*)
8954 # MinGW DLLs use traditional 'lib' prefix
8955 #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
8956 soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
8957 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
8958 if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
8959 # It is most probably a Windows format PATH printed by
8960 # mingw gcc, but we are running on Cygwin. Gcc prints its search
8961 # path with ; separators, and with drive letters. We can handle the
8962 # drive letters (cygwin fileutils understands them), so leave them,
8963 # especially as we might pass files found there to a mingw objdump,
8964 # which wouldn't understand a cygwinified path. Ahh.
8965 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
8966 else
8967 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
8968 fi
8969 ;;
8970 pw32*)
8971 # pw32 DLLs use 'pw' prefix rather than 'lib'
8972 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
8973 ;;
8974 esac
8975 ;;
8976
8977 *)
8978 library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
8979 ;;
8980 esac
8981 dynamic_linker='Win32 ld.exe'
8982 # FIXME: first we should search . and the directory the executable is in
8983 shlibpath_var=PATH
8984 ;;
8985
8986 darwin* | rhapsody*)
8987 dynamic_linker="$host_os dyld"
8988 version_type=darwin
8989 need_lib_prefix=no
8990 need_version=no
8991 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
8992 soname_spec='${libname}${release}${major}$shared_ext'
8993 shlibpath_overrides_runpath=yes
8994 shlibpath_var=DYLD_LIBRARY_PATH
8995 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
8996
8997 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
8998 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
8999 ;;
9000
9001 dgux*)
9002 version_type=linux
9003 need_lib_prefix=no
9004 need_version=no
9005 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
9006 soname_spec='${libname}${release}${shared_ext}$major'
9007 shlibpath_var=LD_LIBRARY_PATH
9008 ;;
9009
9010 freebsd1*)
9011 dynamic_linker=no
9012 ;;
9013
9014 freebsd* | dragonfly*)
9015 # DragonFly does not have aout. When/if they implement a new
9016 # versioning mechanism, adjust this.
9017 if test -x /usr/bin/objformat; then
9018 objformat=`/usr/bin/objformat`
9019 else
9020 case $host_os in
9021 freebsd[123]*) objformat=aout ;;
9022 *) objformat=elf ;;
9023 esac
9024 fi
9025 version_type=freebsd-$objformat
9026 case $version_type in
9027 freebsd-elf*)
9028 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9029 need_version=no
9030 need_lib_prefix=no
9031 ;;
9032 freebsd-*)
9033 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
9034 need_version=yes
9035 ;;
9036 esac
9037 shlibpath_var=LD_LIBRARY_PATH
9038 case $host_os in
9039 freebsd2*)
9040 shlibpath_overrides_runpath=yes
9041 ;;
9042 freebsd3.[01]* | freebsdelf3.[01]*)
9043 shlibpath_overrides_runpath=yes
9044 hardcode_into_libs=yes
9045 ;;
9046 freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
9047 freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
9048 shlibpath_overrides_runpath=no
9049 hardcode_into_libs=yes
9050 ;;
9051 *) # from 4.6 on, and DragonFly
9052 shlibpath_overrides_runpath=yes
9053 hardcode_into_libs=yes
9054 ;;
9055 esac
9056 ;;
9057
9058 gnu*)
9059 version_type=linux
9060 need_lib_prefix=no
9061 need_version=no
9062 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
9063 soname_spec='${libname}${release}${shared_ext}$major'
9064 shlibpath_var=LD_LIBRARY_PATH
9065 hardcode_into_libs=yes
9066 ;;
9067
9068 hpux9* | hpux10* | hpux11*)
9069 # Give a soname corresponding to the major version so that dld.sl refuses to
9070 # link against other versions.
9071 version_type=sunos
9072 need_lib_prefix=no
9073 need_version=no
9074 case $host_cpu in
9075 ia64*)
9076 shrext_cmds='.so'
9077 hardcode_into_libs=yes
9078 dynamic_linker="$host_os dld.so"
9079 shlibpath_var=LD_LIBRARY_PATH
9080 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9081 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9082 soname_spec='${libname}${release}${shared_ext}$major'
9083 if test "X$HPUX_IA64_MODE" = X32; then
9084 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
9085 else
9086 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
9087 fi
9088 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9089 ;;
9090 hppa*64*)
9091 shrext_cmds='.sl'
9092 hardcode_into_libs=yes
9093 dynamic_linker="$host_os dld.sl"
9094 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
9095 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9096 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9097 soname_spec='${libname}${release}${shared_ext}$major'
9098 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
9099 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9100 ;;
9101 *)
9102 shrext_cmds='.sl'
9103 dynamic_linker="$host_os dld.sl"
9104 shlibpath_var=SHLIB_PATH
9105 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
9106 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9107 soname_spec='${libname}${release}${shared_ext}$major'
9108 ;;
9109 esac
9110 # HP-UX runs *really* slowly unless shared libraries are mode 555.
9111 postinstall_cmds='chmod 555 $lib'
9112 ;;
9113
9114 interix[3-9]*)
9115 version_type=linux
9116 need_lib_prefix=no
9117 need_version=no
9118 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9119 soname_spec='${libname}${release}${shared_ext}$major'
9120 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
9121 shlibpath_var=LD_LIBRARY_PATH
9122 shlibpath_overrides_runpath=no
9123 hardcode_into_libs=yes
9124 ;;
9125
9126 irix5* | irix6* | nonstopux*)
9127 case $host_os in
9128 nonstopux*) version_type=nonstopux ;;
9129 *)
9130 if test "$lt_cv_prog_gnu_ld" = yes; then
9131 version_type=linux
9132 else
9133 version_type=irix
9134 fi ;;
9135 esac
9136 need_lib_prefix=no
9137 need_version=no
9138 soname_spec='${libname}${release}${shared_ext}$major'
9139 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
9140 case $host_os in
9141 irix5* | nonstopux*)
9142 libsuff= shlibsuff=
9143 ;;
9144 *)
9145 case $LD in # libtool.m4 will add one of these switches to LD
9146 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
9147 libsuff= shlibsuff= libmagic=32-bit;;
9148 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
9149 libsuff=32 shlibsuff=N32 libmagic=N32;;
9150 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
9151 libsuff=64 shlibsuff=64 libmagic=64-bit;;
9152 *) libsuff= shlibsuff= libmagic=never-match;;
9153 esac
9154 ;;
9155 esac
9156 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
9157 shlibpath_overrides_runpath=no
9158 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
9159 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
9160 hardcode_into_libs=yes
9161 ;;
9162
9163 # No shared lib support for Linux oldld, aout, or coff.
9164 linux*oldld* | linux*aout* | linux*coff*)
9165 dynamic_linker=no
9166 ;;
9167
9168 # This must be Linux ELF.
9169 linux* | k*bsd*-gnu)
9170 version_type=linux
9171 need_lib_prefix=no
9172 need_version=no
9173 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9174 soname_spec='${libname}${release}${shared_ext}$major'
9175 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
9176 shlibpath_var=LD_LIBRARY_PATH
9177 shlibpath_overrides_runpath=no
9178 # Some binutils ld are patched to set DT_RUNPATH
9179 save_LDFLAGS=$LDFLAGS
9180 save_libdir=$libdir
9181 eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
9182 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
9183 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9184 /* end confdefs.h. */
9185
9186 int
9187 main ()
9188 {
9189
9190 ;
9191 return 0;
9192 }
9193 _ACEOF
9194 if ac_fn_c_try_link "$LINENO"; then :
9195 if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
9196 shlibpath_overrides_runpath=yes
9197 fi
9198 fi
9199 rm -f core conftest.err conftest.$ac_objext \
9200 conftest$ac_exeext conftest.$ac_ext
9201 LDFLAGS=$save_LDFLAGS
9202 libdir=$save_libdir
9203
9204 # This implies no fast_install, which is unacceptable.
9205 # Some rework will be needed to allow for fast_install
9206 # before this can be enabled.
9207 hardcode_into_libs=yes
9208
9209 # Append ld.so.conf contents to the search path
9210 if test -f /etc/ld.so.conf; then
9211 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' ' '`
9212 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
9213 fi
9214
9215 # We used to test for /lib/ld.so.1 and disable shared libraries on
9216 # powerpc, because MkLinux only supported shared libraries with the
9217 # GNU dynamic linker. Since this was broken with cross compilers,
9218 # most powerpc-linux boxes support dynamic linking these days and
9219 # people can always --disable-shared, the test was removed, and we
9220 # assume the GNU/Linux dynamic linker is in use.
9221 dynamic_linker='GNU/Linux ld.so'
9222 ;;
9223
9224 netbsd*)
9225 version_type=sunos
9226 need_lib_prefix=no
9227 need_version=no
9228 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
9229 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9230 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9231 dynamic_linker='NetBSD (a.out) ld.so'
9232 else
9233 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9234 soname_spec='${libname}${release}${shared_ext}$major'
9235 dynamic_linker='NetBSD ld.elf_so'
9236 fi
9237 shlibpath_var=LD_LIBRARY_PATH
9238 shlibpath_overrides_runpath=yes
9239 hardcode_into_libs=yes
9240 ;;
9241
9242 newsos6)
9243 version_type=linux
9244 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9245 shlibpath_var=LD_LIBRARY_PATH
9246 shlibpath_overrides_runpath=yes
9247 ;;
9248
9249 *nto* | *qnx*)
9250 version_type=qnx
9251 need_lib_prefix=no
9252 need_version=no
9253 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9254 soname_spec='${libname}${release}${shared_ext}$major'
9255 shlibpath_var=LD_LIBRARY_PATH
9256 shlibpath_overrides_runpath=no
9257 hardcode_into_libs=yes
9258 dynamic_linker='ldqnx.so'
9259 ;;
9260
9261 openbsd*)
9262 version_type=sunos
9263 sys_lib_dlsearch_path_spec="/usr/lib"
9264 need_lib_prefix=no
9265 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
9266 case $host_os in
9267 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
9268 *) need_version=no ;;
9269 esac
9270 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9271 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9272 shlibpath_var=LD_LIBRARY_PATH
9273 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
9274 case $host_os in
9275 openbsd2.[89] | openbsd2.[89].*)
9276 shlibpath_overrides_runpath=no
9277 ;;
9278 *)
9279 shlibpath_overrides_runpath=yes
9280 ;;
9281 esac
9282 else
9283 shlibpath_overrides_runpath=yes
9284 fi
9285 ;;
9286
9287 os2*)
9288 libname_spec='$name'
9289 shrext_cmds=".dll"
9290 need_lib_prefix=no
9291 library_names_spec='$libname${shared_ext} $libname.a'
9292 dynamic_linker='OS/2 ld.exe'
9293 shlibpath_var=LIBPATH
9294 ;;
9295
9296 osf3* | osf4* | osf5*)
9297 version_type=osf
9298 need_lib_prefix=no
9299 need_version=no
9300 soname_spec='${libname}${release}${shared_ext}$major'
9301 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9302 shlibpath_var=LD_LIBRARY_PATH
9303 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
9304 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
9305 ;;
9306
9307 rdos*)
9308 dynamic_linker=no
9309 ;;
9310
9311 solaris*)
9312 version_type=linux
9313 need_lib_prefix=no
9314 need_version=no
9315 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9316 soname_spec='${libname}${release}${shared_ext}$major'
9317 shlibpath_var=LD_LIBRARY_PATH
9318 shlibpath_overrides_runpath=yes
9319 hardcode_into_libs=yes
9320 # ldd complains unless libraries are executable
9321 postinstall_cmds='chmod +x $lib'
9322 ;;
9323
9324 sunos4*)
9325 version_type=sunos
9326 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9327 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
9328 shlibpath_var=LD_LIBRARY_PATH
9329 shlibpath_overrides_runpath=yes
9330 if test "$with_gnu_ld" = yes; then
9331 need_lib_prefix=no
9332 fi
9333 need_version=yes
9334 ;;
9335
9336 sysv4 | sysv4.3*)
9337 version_type=linux
9338 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9339 soname_spec='${libname}${release}${shared_ext}$major'
9340 shlibpath_var=LD_LIBRARY_PATH
9341 case $host_vendor in
9342 sni)
9343 shlibpath_overrides_runpath=no
9344 need_lib_prefix=no
9345 runpath_var=LD_RUN_PATH
9346 ;;
9347 siemens)
9348 need_lib_prefix=no
9349 ;;
9350 motorola)
9351 need_lib_prefix=no
9352 need_version=no
9353 shlibpath_overrides_runpath=no
9354 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
9355 ;;
9356 esac
9357 ;;
9358
9359 sysv4*MP*)
9360 if test -d /usr/nec ;then
9361 version_type=linux
9362 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
9363 soname_spec='$libname${shared_ext}.$major'
9364 shlibpath_var=LD_LIBRARY_PATH
9365 fi
9366 ;;
9367
9368 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
9369 version_type=freebsd-elf
9370 need_lib_prefix=no
9371 need_version=no
9372 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9373 soname_spec='${libname}${release}${shared_ext}$major'
9374 shlibpath_var=LD_LIBRARY_PATH
9375 shlibpath_overrides_runpath=yes
9376 hardcode_into_libs=yes
9377 if test "$with_gnu_ld" = yes; then
9378 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
9379 else
9380 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
9381 case $host_os in
9382 sco3.2v5*)
9383 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
9384 ;;
9385 esac
9386 fi
9387 sys_lib_dlsearch_path_spec='/usr/lib'
9388 ;;
9389
9390 tpf*)
9391 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
9392 version_type=linux
9393 need_lib_prefix=no
9394 need_version=no
9395 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9396 shlibpath_var=LD_LIBRARY_PATH
9397 shlibpath_overrides_runpath=no
9398 hardcode_into_libs=yes
9399 ;;
9400
9401 uts4*)
9402 version_type=linux
9403 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9404 soname_spec='${libname}${release}${shared_ext}$major'
9405 shlibpath_var=LD_LIBRARY_PATH
9406 ;;
9407
9408 *)
9409 dynamic_linker=no
9410 ;;
9411 esac
9412 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
9413 $as_echo "$dynamic_linker" >&6; }
9414 test "$dynamic_linker" = no && can_build_shared=no
9415
9416 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
9417 if test "$GCC" = yes; then
9418 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
9419 fi
9420
9421 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
9422 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
9423 fi
9424 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
9425 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
9426 fi
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
9515 $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
9516 hardcode_action=
9517 if test -n "$hardcode_libdir_flag_spec" ||
9518 test -n "$runpath_var" ||
9519 test "X$hardcode_automatic" = "Xyes" ; then
9520
9521 # We can hardcode non-existent directories.
9522 if test "$hardcode_direct" != no &&
9523 # If the only mechanism to avoid hardcoding is shlibpath_var, we
9524 # have to relink, otherwise we might link with an installed library
9525 # when we should be linking with a yet-to-be-installed one
9526 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
9527 test "$hardcode_minus_L" != no; then
9528 # Linking always hardcodes the temporary library directory.
9529 hardcode_action=relink
9530 else
9531 # We can link without hardcoding, and we can hardcode nonexisting dirs.
9532 hardcode_action=immediate
9533 fi
9534 else
9535 # We cannot hardcode anything, or else we can only hardcode existing
9536 # directories.
9537 hardcode_action=unsupported
9538 fi
9539 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
9540 $as_echo "$hardcode_action" >&6; }
9541
9542 if test "$hardcode_action" = relink ||
9543 test "$inherit_rpath" = yes; then
9544 # Fast installation is not supported
9545 enable_fast_install=no
9546 elif test "$shlibpath_overrides_runpath" = yes ||
9547 test "$enable_shared" = no; then
9548 # Fast installation is not necessary
9549 enable_fast_install=needless
9550 fi
9551
9552
9553
9554
9555
9556
9557 if test "x$enable_dlopen" != xyes; then
9558 enable_dlopen=unknown
9559 enable_dlopen_self=unknown
9560 enable_dlopen_self_static=unknown
9561 else
9562 lt_cv_dlopen=no
9563 lt_cv_dlopen_libs=
9564
9565 case $host_os in
9566 beos*)
9567 lt_cv_dlopen="load_add_on"
9568 lt_cv_dlopen_libs=
9569 lt_cv_dlopen_self=yes
9570 ;;
9571
9572 mingw* | pw32* | cegcc*)
9573 lt_cv_dlopen="LoadLibrary"
9574 lt_cv_dlopen_libs=
9575 ;;
9576
9577 cygwin*)
9578 lt_cv_dlopen="dlopen"
9579 lt_cv_dlopen_libs=
9580 ;;
9581
9582 darwin*)
9583 # if libdl is installed we need to link against it
9584 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
9585 $as_echo_n "checking for dlopen in -ldl... " >&6; }
9586 if ${ac_cv_lib_dl_dlopen+:} false; then :
9587 $as_echo_n "(cached) " >&6
9588 else
9589 ac_check_lib_save_LIBS=$LIBS
9590 LIBS="-ldl $LIBS"
9591 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9592 /* end confdefs.h. */
9593
9594 /* Override any GCC internal prototype to avoid an error.
9595 Use char because int might match the return type of a GCC
9596 builtin and then its argument prototype would still apply. */
9597 #ifdef __cplusplus
9598 extern "C"
9599 #endif
9600 char dlopen ();
9601 int
9602 main ()
9603 {
9604 return dlopen ();
9605 ;
9606 return 0;
9607 }
9608 _ACEOF
9609 if ac_fn_c_try_link "$LINENO"; then :
9610 ac_cv_lib_dl_dlopen=yes
9611 else
9612 ac_cv_lib_dl_dlopen=no
9613 fi
9614 rm -f core conftest.err conftest.$ac_objext \
9615 conftest$ac_exeext conftest.$ac_ext
9616 LIBS=$ac_check_lib_save_LIBS
9617 fi
9618 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
9619 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
9620 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
9621 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
9622 else
9623
9624 lt_cv_dlopen="dyld"
9625 lt_cv_dlopen_libs=
9626 lt_cv_dlopen_self=yes
9627
9628 fi
9629
9630 ;;
9631
9632 *)
9633 ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
9634 if test "x$ac_cv_func_shl_load" = xyes; then :
9635 lt_cv_dlopen="shl_load"
9636 else
9637 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
9638 $as_echo_n "checking for shl_load in -ldld... " >&6; }
9639 if ${ac_cv_lib_dld_shl_load+:} false; then :
9640 $as_echo_n "(cached) " >&6
9641 else
9642 ac_check_lib_save_LIBS=$LIBS
9643 LIBS="-ldld $LIBS"
9644 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9645 /* end confdefs.h. */
9646
9647 /* Override any GCC internal prototype to avoid an error.
9648 Use char because int might match the return type of a GCC
9649 builtin and then its argument prototype would still apply. */
9650 #ifdef __cplusplus
9651 extern "C"
9652 #endif
9653 char shl_load ();
9654 int
9655 main ()
9656 {
9657 return shl_load ();
9658 ;
9659 return 0;
9660 }
9661 _ACEOF
9662 if ac_fn_c_try_link "$LINENO"; then :
9663 ac_cv_lib_dld_shl_load=yes
9664 else
9665 ac_cv_lib_dld_shl_load=no
9666 fi
9667 rm -f core conftest.err conftest.$ac_objext \
9668 conftest$ac_exeext conftest.$ac_ext
9669 LIBS=$ac_check_lib_save_LIBS
9670 fi
9671 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
9672 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
9673 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
9674 lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
9675 else
9676 ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
9677 if test "x$ac_cv_func_dlopen" = xyes; then :
9678 lt_cv_dlopen="dlopen"
9679 else
9680 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
9681 $as_echo_n "checking for dlopen in -ldl... " >&6; }
9682 if ${ac_cv_lib_dl_dlopen+:} false; then :
9683 $as_echo_n "(cached) " >&6
9684 else
9685 ac_check_lib_save_LIBS=$LIBS
9686 LIBS="-ldl $LIBS"
9687 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9688 /* end confdefs.h. */
9689
9690 /* Override any GCC internal prototype to avoid an error.
9691 Use char because int might match the return type of a GCC
9692 builtin and then its argument prototype would still apply. */
9693 #ifdef __cplusplus
9694 extern "C"
9695 #endif
9696 char dlopen ();
9697 int
9698 main ()
9699 {
9700 return dlopen ();
9701 ;
9702 return 0;
9703 }
9704 _ACEOF
9705 if ac_fn_c_try_link "$LINENO"; then :
9706 ac_cv_lib_dl_dlopen=yes
9707 else
9708 ac_cv_lib_dl_dlopen=no
9709 fi
9710 rm -f core conftest.err conftest.$ac_objext \
9711 conftest$ac_exeext conftest.$ac_ext
9712 LIBS=$ac_check_lib_save_LIBS
9713 fi
9714 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
9715 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
9716 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
9717 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
9718 else
9719 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
9720 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
9721 if ${ac_cv_lib_svld_dlopen+:} false; then :
9722 $as_echo_n "(cached) " >&6
9723 else
9724 ac_check_lib_save_LIBS=$LIBS
9725 LIBS="-lsvld $LIBS"
9726 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9727 /* end confdefs.h. */
9728
9729 /* Override any GCC internal prototype to avoid an error.
9730 Use char because int might match the return type of a GCC
9731 builtin and then its argument prototype would still apply. */
9732 #ifdef __cplusplus
9733 extern "C"
9734 #endif
9735 char dlopen ();
9736 int
9737 main ()
9738 {
9739 return dlopen ();
9740 ;
9741 return 0;
9742 }
9743 _ACEOF
9744 if ac_fn_c_try_link "$LINENO"; then :
9745 ac_cv_lib_svld_dlopen=yes
9746 else
9747 ac_cv_lib_svld_dlopen=no
9748 fi
9749 rm -f core conftest.err conftest.$ac_objext \
9750 conftest$ac_exeext conftest.$ac_ext
9751 LIBS=$ac_check_lib_save_LIBS
9752 fi
9753 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
9754 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
9755 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
9756 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
9757 else
9758 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
9759 $as_echo_n "checking for dld_link in -ldld... " >&6; }
9760 if ${ac_cv_lib_dld_dld_link+:} false; then :
9761 $as_echo_n "(cached) " >&6
9762 else
9763 ac_check_lib_save_LIBS=$LIBS
9764 LIBS="-ldld $LIBS"
9765 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9766 /* end confdefs.h. */
9767
9768 /* Override any GCC internal prototype to avoid an error.
9769 Use char because int might match the return type of a GCC
9770 builtin and then its argument prototype would still apply. */
9771 #ifdef __cplusplus
9772 extern "C"
9773 #endif
9774 char dld_link ();
9775 int
9776 main ()
9777 {
9778 return dld_link ();
9779 ;
9780 return 0;
9781 }
9782 _ACEOF
9783 if ac_fn_c_try_link "$LINENO"; then :
9784 ac_cv_lib_dld_dld_link=yes
9785 else
9786 ac_cv_lib_dld_dld_link=no
9787 fi
9788 rm -f core conftest.err conftest.$ac_objext \
9789 conftest$ac_exeext conftest.$ac_ext
9790 LIBS=$ac_check_lib_save_LIBS
9791 fi
9792 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
9793 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
9794 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
9795 lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
9796 fi
9797
9798
9799 fi
9800
9801
9802 fi
9803
9804
9805 fi
9806
9807
9808 fi
9809
9810
9811 fi
9812
9813 ;;
9814 esac
9815
9816 if test "x$lt_cv_dlopen" != xno; then
9817 enable_dlopen=yes
9818 else
9819 enable_dlopen=no
9820 fi
9821
9822 case $lt_cv_dlopen in
9823 dlopen)
9824 save_CPPFLAGS="$CPPFLAGS"
9825 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
9826
9827 save_LDFLAGS="$LDFLAGS"
9828 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
9829
9830 save_LIBS="$LIBS"
9831 LIBS="$lt_cv_dlopen_libs $LIBS"
9832
9833 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
9834 $as_echo_n "checking whether a program can dlopen itself... " >&6; }
9835 if ${lt_cv_dlopen_self+:} false; then :
9836 $as_echo_n "(cached) " >&6
9837 else
9838 if test "$cross_compiling" = yes; then :
9839 lt_cv_dlopen_self=cross
9840 else
9841 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
9842 lt_status=$lt_dlunknown
9843 cat > conftest.$ac_ext <<_LT_EOF
9844 #line 9845 "configure"
9845 #include "confdefs.h"
9846
9847 #if HAVE_DLFCN_H
9848 #include <dlfcn.h>
9849 #endif
9850
9851 #include <stdio.h>
9852
9853 #ifdef RTLD_GLOBAL
9854 # define LT_DLGLOBAL RTLD_GLOBAL
9855 #else
9856 # ifdef DL_GLOBAL
9857 # define LT_DLGLOBAL DL_GLOBAL
9858 # else
9859 # define LT_DLGLOBAL 0
9860 # endif
9861 #endif
9862
9863 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
9864 find out it does not work in some platform. */
9865 #ifndef LT_DLLAZY_OR_NOW
9866 # ifdef RTLD_LAZY
9867 # define LT_DLLAZY_OR_NOW RTLD_LAZY
9868 # else
9869 # ifdef DL_LAZY
9870 # define LT_DLLAZY_OR_NOW DL_LAZY
9871 # else
9872 # ifdef RTLD_NOW
9873 # define LT_DLLAZY_OR_NOW RTLD_NOW
9874 # else
9875 # ifdef DL_NOW
9876 # define LT_DLLAZY_OR_NOW DL_NOW
9877 # else
9878 # define LT_DLLAZY_OR_NOW 0
9879 # endif
9880 # endif
9881 # endif
9882 # endif
9883 #endif
9884
9885 void fnord() { int i=42;}
9886 int main ()
9887 {
9888 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
9889 int status = $lt_dlunknown;
9890
9891 if (self)
9892 {
9893 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
9894 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
9895 /* dlclose (self); */
9896 }
9897 else
9898 puts (dlerror ());
9899
9900 return status;
9901 }
9902 _LT_EOF
9903 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
9904 (eval $ac_link) 2>&5
9905 ac_status=$?
9906 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
9907 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
9908 (./conftest; exit; ) >&5 2>/dev/null
9909 lt_status=$?
9910 case x$lt_status in
9911 x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
9912 x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
9913 x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
9914 esac
9915 else :
9916 # compilation failed
9917 lt_cv_dlopen_self=no
9918 fi
9919 fi
9920 rm -fr conftest*
9921
9922
9923 fi
9924 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
9925 $as_echo "$lt_cv_dlopen_self" >&6; }
9926
9927 if test "x$lt_cv_dlopen_self" = xyes; then
9928 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
9929 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
9930 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
9931 if ${lt_cv_dlopen_self_static+:} false; then :
9932 $as_echo_n "(cached) " >&6
9933 else
9934 if test "$cross_compiling" = yes; then :
9935 lt_cv_dlopen_self_static=cross
9936 else
9937 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
9938 lt_status=$lt_dlunknown
9939 cat > conftest.$ac_ext <<_LT_EOF
9940 #line 9941 "configure"
9941 #include "confdefs.h"
9942
9943 #if HAVE_DLFCN_H
9944 #include <dlfcn.h>
9945 #endif
9946
9947 #include <stdio.h>
9948
9949 #ifdef RTLD_GLOBAL
9950 # define LT_DLGLOBAL RTLD_GLOBAL
9951 #else
9952 # ifdef DL_GLOBAL
9953 # define LT_DLGLOBAL DL_GLOBAL
9954 # else
9955 # define LT_DLGLOBAL 0
9956 # endif
9957 #endif
9958
9959 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
9960 find out it does not work in some platform. */
9961 #ifndef LT_DLLAZY_OR_NOW
9962 # ifdef RTLD_LAZY
9963 # define LT_DLLAZY_OR_NOW RTLD_LAZY
9964 # else
9965 # ifdef DL_LAZY
9966 # define LT_DLLAZY_OR_NOW DL_LAZY
9967 # else
9968 # ifdef RTLD_NOW
9969 # define LT_DLLAZY_OR_NOW RTLD_NOW
9970 # else
9971 # ifdef DL_NOW
9972 # define LT_DLLAZY_OR_NOW DL_NOW
9973 # else
9974 # define LT_DLLAZY_OR_NOW 0
9975 # endif
9976 # endif
9977 # endif
9978 # endif
9979 #endif
9980
9981 void fnord() { int i=42;}
9982 int main ()
9983 {
9984 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
9985 int status = $lt_dlunknown;
9986
9987 if (self)
9988 {
9989 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
9990 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
9991 /* dlclose (self); */
9992 }
9993 else
9994 puts (dlerror ());
9995
9996 return status;
9997 }
9998 _LT_EOF
9999 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
10000 (eval $ac_link) 2>&5
10001 ac_status=$?
10002 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10003 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
10004 (./conftest; exit; ) >&5 2>/dev/null
10005 lt_status=$?
10006 case x$lt_status in
10007 x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
10008 x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
10009 x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
10010 esac
10011 else :
10012 # compilation failed
10013 lt_cv_dlopen_self_static=no
10014 fi
10015 fi
10016 rm -fr conftest*
10017
10018
10019 fi
10020 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
10021 $as_echo "$lt_cv_dlopen_self_static" >&6; }
10022 fi
10023
10024 CPPFLAGS="$save_CPPFLAGS"
10025 LDFLAGS="$save_LDFLAGS"
10026 LIBS="$save_LIBS"
10027 ;;
10028 esac
10029
10030 case $lt_cv_dlopen_self in
10031 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
10032 *) enable_dlopen_self=unknown ;;
10033 esac
10034
10035 case $lt_cv_dlopen_self_static in
10036 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
10037 *) enable_dlopen_self_static=unknown ;;
10038 esac
10039 fi
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057 striplib=
10058 old_striplib=
10059 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
10060 $as_echo_n "checking whether stripping libraries is possible... " >&6; }
10061 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
10062 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
10063 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
10064 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10065 $as_echo "yes" >&6; }
10066 else
10067 # FIXME - insert some real tests, host_os isn't really good enough
10068 case $host_os in
10069 darwin*)
10070 if test -n "$STRIP" ; then
10071 striplib="$STRIP -x"
10072 old_striplib="$STRIP -S"
10073 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10074 $as_echo "yes" >&6; }
10075 else
10076 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10077 $as_echo "no" >&6; }
10078 fi
10079 ;;
10080 *)
10081 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10082 $as_echo "no" >&6; }
10083 ;;
10084 esac
10085 fi
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098 # Report which library types will actually be built
10099 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
10100 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
10101 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
10102 $as_echo "$can_build_shared" >&6; }
10103
10104 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
10105 $as_echo_n "checking whether to build shared libraries... " >&6; }
10106 test "$can_build_shared" = "no" && enable_shared=no
10107
10108 # On AIX, shared libraries and static libraries use the same namespace, and
10109 # are all built from PIC.
10110 case $host_os in
10111 aix3*)
10112 test "$enable_shared" = yes && enable_static=no
10113 if test -n "$RANLIB"; then
10114 archive_cmds="$archive_cmds~\$RANLIB \$lib"
10115 postinstall_cmds='$RANLIB $lib'
10116 fi
10117 ;;
10118
10119 aix[4-9]*)
10120 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
10121 test "$enable_shared" = yes && enable_static=no
10122 fi
10123 ;;
10124 esac
10125 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
10126 $as_echo "$enable_shared" >&6; }
10127
10128 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
10129 $as_echo_n "checking whether to build static libraries... " >&6; }
10130 # Make sure either enable_shared or enable_static is yes.
10131 test "$enable_shared" = yes || enable_static=yes
10132 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
10133 $as_echo "$enable_static" >&6; }
10134
10135
10136
10137
10138 fi
10139 ac_ext=c
10140 ac_cpp='$CPP $CPPFLAGS'
10141 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
10142 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
10143 ac_compiler_gnu=$ac_cv_c_compiler_gnu
10144
10145 CC="$lt_save_CC"
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159 ac_config_commands="$ac_config_commands libtool"
10160
10161
10162
10163
10164 # Only expand once:
10165
10166
10167
10168 LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
10169 LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
10170 LT_REVISION=$INTERFACE_AGE
10171 LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
10172
10173
10174
10175
10176
10177
10178
10179 ac_aux_dir=
10180 for ac_dir in $srcdir/build-scripts; do
10181 if test -f "$ac_dir/install-sh"; then
10182 ac_aux_dir=$ac_dir
10183 ac_install_sh="$ac_aux_dir/install-sh -c"
10184 break
10185 elif test -f "$ac_dir/install.sh"; then
10186 ac_aux_dir=$ac_dir
10187 ac_install_sh="$ac_aux_dir/install.sh -c"
10188 break
10189 elif test -f "$ac_dir/shtool"; then
10190 ac_aux_dir=$ac_dir
10191 ac_install_sh="$ac_aux_dir/shtool install -c"
10192 break
10193 fi
10194 done
10195 if test -z "$ac_aux_dir"; then
10196 as_fn_error $? "cannot find install-sh, install.sh, or shtool in $srcdir/build-scripts" "$LINENO" 5
10197 fi
10198
10199 # These three variables are undocumented and unsupported,
10200 # and are intended to be withdrawn in a future Autoconf release.
10201 # They can cause serious problems if a builder's source tree is in a directory
10202 # whose full name contains unusual characters.
10203 ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
10204 ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
10205 ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
10206
10207
10208
10209
10210 ac_ext=c
10211 ac_cpp='$CPP $CPPFLAGS'
10212 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
10213 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
10214 ac_compiler_gnu=$ac_cv_c_compiler_gnu
10215 if test -n "$ac_tool_prefix"; then
10216 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
10217 set dummy ${ac_tool_prefix}gcc; ac_word=$2
10218 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10219 $as_echo_n "checking for $ac_word... " >&6; }
10220 if ${ac_cv_prog_CC+:} false; then :
10221 $as_echo_n "(cached) " >&6
10222 else
10223 if test -n "$CC"; then
10224 ac_cv_prog_CC="$CC" # Let the user override the test.
10225 else
10226 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10227 for as_dir in $PATH
10228 do
10229 IFS=$as_save_IFS
10230 test -z "$as_dir" && as_dir=.
10231 for ac_exec_ext in '' $ac_executable_extensions; do
10232 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10233 ac_cv_prog_CC="${ac_tool_prefix}gcc"
10234 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10235 break 2
10236 fi
10237 done
10238 done
10239 IFS=$as_save_IFS
10240
10241 fi
10242 fi
10243 CC=$ac_cv_prog_CC
10244 if test -n "$CC"; then
10245 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
10246 $as_echo "$CC" >&6; }
10247 else
10248 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10249 $as_echo "no" >&6; }
10250 fi
10251
10252
10253 fi
10254 if test -z "$ac_cv_prog_CC"; then
10255 ac_ct_CC=$CC
10256 # Extract the first word of "gcc", so it can be a program name with args.
10257 set dummy gcc; ac_word=$2
10258 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10259 $as_echo_n "checking for $ac_word... " >&6; }
10260 if ${ac_cv_prog_ac_ct_CC+:} false; then :
10261 $as_echo_n "(cached) " >&6
10262 else
10263 if test -n "$ac_ct_CC"; then
10264 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
10265 else
10266 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10267 for as_dir in $PATH
10268 do
10269 IFS=$as_save_IFS
10270 test -z "$as_dir" && as_dir=.
10271 for ac_exec_ext in '' $ac_executable_extensions; do
10272 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10273 ac_cv_prog_ac_ct_CC="gcc"
10274 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10275 break 2
10276 fi
10277 done
10278 done
10279 IFS=$as_save_IFS
10280
10281 fi
10282 fi
10283 ac_ct_CC=$ac_cv_prog_ac_ct_CC
10284 if test -n "$ac_ct_CC"; then
10285 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
10286 $as_echo "$ac_ct_CC" >&6; }
10287 else
10288 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10289 $as_echo "no" >&6; }
10290 fi
10291
10292 if test "x$ac_ct_CC" = x; then
10293 CC=""
10294 else
10295 case $cross_compiling:$ac_tool_warned in
10296 yes:)
10297 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
10298 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
10299 ac_tool_warned=yes ;;
10300 esac
10301 CC=$ac_ct_CC
10302 fi
10303 else
10304 CC="$ac_cv_prog_CC"
10305 fi
10306
10307 if test -z "$CC"; then
10308 if test -n "$ac_tool_prefix"; then
10309 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
10310 set dummy ${ac_tool_prefix}cc; ac_word=$2
10311 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10312 $as_echo_n "checking for $ac_word... " >&6; }
10313 if ${ac_cv_prog_CC+:} false; then :
10314 $as_echo_n "(cached) " >&6
10315 else
10316 if test -n "$CC"; then
10317 ac_cv_prog_CC="$CC" # Let the user override the test.
10318 else
10319 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10320 for as_dir in $PATH
10321 do
10322 IFS=$as_save_IFS
10323 test -z "$as_dir" && as_dir=.
10324 for ac_exec_ext in '' $ac_executable_extensions; do
10325 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10326 ac_cv_prog_CC="${ac_tool_prefix}cc"
10327 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10328 break 2
10329 fi
10330 done
10331 done
10332 IFS=$as_save_IFS
10333
10334 fi
10335 fi
10336 CC=$ac_cv_prog_CC
10337 if test -n "$CC"; then
10338 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
10339 $as_echo "$CC" >&6; }
10340 else
10341 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10342 $as_echo "no" >&6; }
10343 fi
10344
10345
10346 fi
10347 fi
10348 if test -z "$CC"; then
10349 # Extract the first word of "cc", so it can be a program name with args.
10350 set dummy cc; ac_word=$2
10351 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10352 $as_echo_n "checking for $ac_word... " >&6; }
10353 if ${ac_cv_prog_CC+:} false; then :
10354 $as_echo_n "(cached) " >&6
10355 else
10356 if test -n "$CC"; then
10357 ac_cv_prog_CC="$CC" # Let the user override the test.
10358 else
10359 ac_prog_rejected=no
10360 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10361 for as_dir in $PATH
10362 do
10363 IFS=$as_save_IFS
10364 test -z "$as_dir" && as_dir=.
10365 for ac_exec_ext in '' $ac_executable_extensions; do
10366 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10367 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
10368 ac_prog_rejected=yes
10369 continue
10370 fi
10371 ac_cv_prog_CC="cc"
10372 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10373 break 2
10374 fi
10375 done
10376 done
10377 IFS=$as_save_IFS
10378
10379 if test $ac_prog_rejected = yes; then
10380 # We found a bogon in the path, so make sure we never use it.
10381 set dummy $ac_cv_prog_CC
10382 shift
10383 if test $# != 0; then
10384 # We chose a different compiler from the bogus one.
10385 # However, it has the same basename, so the bogon will be chosen
10386 # first if we set CC to just the basename; use the full file name.
10387 shift
10388 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
10389 fi
10390 fi
10391 fi
10392 fi
10393 CC=$ac_cv_prog_CC
10394 if test -n "$CC"; then
10395 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
10396 $as_echo "$CC" >&6; }
10397 else
10398 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10399 $as_echo "no" >&6; }
10400 fi
10401
10402
10403 fi
10404 if test -z "$CC"; then
10405 if test -n "$ac_tool_prefix"; then
10406 for ac_prog in cl.exe
10407 do
10408 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
10409 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
10410 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10411 $as_echo_n "checking for $ac_word... " >&6; }
10412 if ${ac_cv_prog_CC+:} false; then :
10413 $as_echo_n "(cached) " >&6
10414 else
10415 if test -n "$CC"; then
10416 ac_cv_prog_CC="$CC" # Let the user override the test.
10417 else
10418 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10419 for as_dir in $PATH
10420 do
10421 IFS=$as_save_IFS
10422 test -z "$as_dir" && as_dir=.
10423 for ac_exec_ext in '' $ac_executable_extensions; do
10424 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10425 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
10426 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10427 break 2
10428 fi
10429 done
10430 done
10431 IFS=$as_save_IFS
10432
10433 fi
10434 fi
10435 CC=$ac_cv_prog_CC
10436 if test -n "$CC"; then
10437 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
10438 $as_echo "$CC" >&6; }
10439 else
10440 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10441 $as_echo "no" >&6; }
10442 fi
10443
10444
10445 test -n "$CC" && break
10446 done
10447 fi
10448 if test -z "$CC"; then
10449 ac_ct_CC=$CC
10450 for ac_prog in cl.exe
10451 do
10452 # Extract the first word of "$ac_prog", so it can be a program name with args.
10453 set dummy $ac_prog; ac_word=$2
10454 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10455 $as_echo_n "checking for $ac_word... " >&6; }
10456 if ${ac_cv_prog_ac_ct_CC+:} false; then :
10457 $as_echo_n "(cached) " >&6
10458 else
10459 if test -n "$ac_ct_CC"; then
10460 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
10461 else
10462 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10463 for as_dir in $PATH
10464 do
10465 IFS=$as_save_IFS
10466 test -z "$as_dir" && as_dir=.
10467 for ac_exec_ext in '' $ac_executable_extensions; do
10468 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10469 ac_cv_prog_ac_ct_CC="$ac_prog"
10470 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10471 break 2
10472 fi
10473 done
10474 done
10475 IFS=$as_save_IFS
10476
10477 fi
10478 fi
10479 ac_ct_CC=$ac_cv_prog_ac_ct_CC
10480 if test -n "$ac_ct_CC"; then
10481 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
10482 $as_echo "$ac_ct_CC" >&6; }
10483 else
10484 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10485 $as_echo "no" >&6; }
10486 fi
10487
10488
10489 test -n "$ac_ct_CC" && break
10490 done
10491
10492 if test "x$ac_ct_CC" = x; then
10493 CC=""
10494 else
10495 case $cross_compiling:$ac_tool_warned in
10496 yes:)
10497 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
10498 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
10499 ac_tool_warned=yes ;;
10500 esac
10501 CC=$ac_ct_CC
10502 fi
10503 fi
10504
10505 fi
10506
10507
10508 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
10509 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
10510 as_fn_error $? "no acceptable C compiler found in \$PATH
10511 See \`config.log' for more details" "$LINENO" 5; }
10512
10513 # Provide some information about the compiler.
10514 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
10515 set X $ac_compile
10516 ac_compiler=$2
10517 for ac_option in --version -v -V -qversion; do
10518 { { ac_try="$ac_compiler $ac_option >&5"
10519 case "(($ac_try" in
10520 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10521 *) ac_try_echo=$ac_try;;
10522 esac
10523 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
10524 $as_echo "$ac_try_echo"; } >&5
10525 (eval "$ac_compiler $ac_option >&5") 2>conftest.err
10526 ac_status=$?
10527 if test -s conftest.err; then
10528 sed '10a\
10529 ... rest of stderr output deleted ...
10530 10q' conftest.err >conftest.er1
10531 cat conftest.er1 >&5
10532 fi
10533 rm -f conftest.er1 conftest.err
10534 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10535 test $ac_status = 0; }
10536 done
10537
10538 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
10539 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
10540 if ${ac_cv_c_compiler_gnu+:} false; then :
10541 $as_echo_n "(cached) " >&6
10542 else
10543 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10544 /* end confdefs.h. */
10545
10546 int
10547 main ()
10548 {
10549 #ifndef __GNUC__
10550 choke me
10551 #endif
10552
10553 ;
10554 return 0;
10555 }
10556 _ACEOF
10557 if ac_fn_c_try_compile "$LINENO"; then :
10558 ac_compiler_gnu=yes
10559 else
10560 ac_compiler_gnu=no
10561 fi
10562 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10563 ac_cv_c_compiler_gnu=$ac_compiler_gnu
10564
10565 fi
10566 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
10567 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
10568 if test $ac_compiler_gnu = yes; then
10569 GCC=yes
10570 else
10571 GCC=
10572 fi
10573 ac_test_CFLAGS=${CFLAGS+set}
10574 ac_save_CFLAGS=$CFLAGS
10575 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
10576 $as_echo_n "checking whether $CC accepts -g... " >&6; }
10577 if ${ac_cv_prog_cc_g+:} false; then :
10578 $as_echo_n "(cached) " >&6
10579 else
10580 ac_save_c_werror_flag=$ac_c_werror_flag
10581 ac_c_werror_flag=yes
10582 ac_cv_prog_cc_g=no
10583 CFLAGS="-g"
10584 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10585 /* end confdefs.h. */
10586
10587 int
10588 main ()
10589 {
10590
10591 ;
10592 return 0;
10593 }
10594 _ACEOF
10595 if ac_fn_c_try_compile "$LINENO"; then :
10596 ac_cv_prog_cc_g=yes
10597 else
10598 CFLAGS=""
10599 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10600 /* end confdefs.h. */
10601
10602 int
10603 main ()
10604 {
10605
10606 ;
10607 return 0;
10608 }
10609 _ACEOF
10610 if ac_fn_c_try_compile "$LINENO"; then :
10611
10612 else
10613 ac_c_werror_flag=$ac_save_c_werror_flag
10614 CFLAGS="-g"
10615 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10616 /* end confdefs.h. */
10617
10618 int
10619 main ()
10620 {
10621
10622 ;
10623 return 0;
10624 }
10625 _ACEOF
10626 if ac_fn_c_try_compile "$LINENO"; then :
10627 ac_cv_prog_cc_g=yes
10628 fi
10629 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10630 fi
10631 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10632 fi
10633 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10634 ac_c_werror_flag=$ac_save_c_werror_flag
10635 fi
10636 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
10637 $as_echo "$ac_cv_prog_cc_g" >&6; }
10638 if test "$ac_test_CFLAGS" = set; then
10639 CFLAGS=$ac_save_CFLAGS
10640 elif test $ac_cv_prog_cc_g = yes; then
10641 if test "$GCC" = yes; then
10642 CFLAGS="-g -O2"
10643 else
10644 CFLAGS="-g"
10645 fi
10646 else
10647 if test "$GCC" = yes; then
10648 CFLAGS="-O2"
10649 else
10650 CFLAGS=
10651 fi
10652 fi
10653 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
10654 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
10655 if ${ac_cv_prog_cc_c89+:} false; then :
10656 $as_echo_n "(cached) " >&6
10657 else
10658 ac_cv_prog_cc_c89=no
10659 ac_save_CC=$CC
10660 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10661 /* end confdefs.h. */
10662 #include <stdarg.h>
10663 #include <stdio.h>
10664 struct stat;
10665 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
10666 struct buf { int x; };
10667 FILE * (*rcsopen) (struct buf *, struct stat *, int);
10668 static char *e (p, i)
10669 char **p;
10670 int i;
10671 {
10672 return p[i];
10673 }
10674 static char *f (char * (*g) (char **, int), char **p, ...)
10675 {
10676 char *s;
10677 va_list v;
10678 va_start (v,p);
10679 s = g (p, va_arg (v,int));
10680 va_end (v);
10681 return s;
10682 }
10683
10684 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
10685 function prototypes and stuff, but not '\xHH' hex character constants.
10686 These don't provoke an error unfortunately, instead are silently treated
10687 as 'x'. The following induces an error, until -std is added to get
10688 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
10689 array size at least. It's necessary to write '\x00'==0 to get something
10690 that's true only with -std. */
10691 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
10692
10693 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
10694 inside strings and character constants. */
10695 #define FOO(x) 'x'
10696 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
10697
10698 int test (int i, double x);
10699 struct s1 {int (*f) (int a);};
10700 struct s2 {int (*f) (double a);};
10701 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
10702 int argc;
10703 char **argv;
10704 int
10705 main ()
10706 {
10707 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
10708 ;
10709 return 0;
10710 }
10711 _ACEOF
10712 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
10713 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
10714 do
10715 CC="$ac_save_CC $ac_arg"
10716 if ac_fn_c_try_compile "$LINENO"; then :
10717 ac_cv_prog_cc_c89=$ac_arg
10718 fi
10719 rm -f core conftest.err conftest.$ac_objext
10720 test "x$ac_cv_prog_cc_c89" != "xno" && break
10721 done
10722 rm -f conftest.$ac_ext
10723 CC=$ac_save_CC
10724
10725 fi
10726 # AC_CACHE_VAL
10727 case "x$ac_cv_prog_cc_c89" in
10728 x)
10729 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
10730 $as_echo "none needed" >&6; } ;;
10731 xno)
10732 { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
10733 $as_echo "unsupported" >&6; } ;;
10734 *)
10735 CC="$CC $ac_cv_prog_cc_c89"
10736 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
10737 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
10738 esac
10739 if test "x$ac_cv_prog_cc_c89" != xno; then :
10740
10741 fi
10742
10743 ac_ext=c
10744 ac_cpp='$CPP $CPPFLAGS'
10745 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
10746 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
10747 ac_compiler_gnu=$ac_cv_c_compiler_gnu
10748
10749 # Find a good install program. We prefer a C program (faster),
10750 # so one script is as good as another. But avoid the broken or
10751 # incompatible versions:
10752 # SysV /etc/install, /usr/sbin/install
10753 # SunOS /usr/etc/install
10754 # IRIX /sbin/install
10755 # AIX /bin/install
10756 # AmigaOS /C/install, which installs bootblocks on floppy discs
10757 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
10758 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
10759 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
10760 # OS/2's system install, which has a completely different semantic
10761 # ./install, which can be erroneously created by make from ./install.sh.
10762 # Reject install programs that cannot install multiple files.
10763 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
10764 $as_echo_n "checking for a BSD-compatible install... " >&6; }
10765 if test -z "$INSTALL"; then
10766 if ${ac_cv_path_install+:} false; then :
10767 $as_echo_n "(cached) " >&6
10768 else
10769 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10770 for as_dir in $PATH
10771 do
10772 IFS=$as_save_IFS
10773 test -z "$as_dir" && as_dir=.
10774 # Account for people who put trailing slashes in PATH elements.
10775 case $as_dir/ in #((
10776 ./ | .// | /[cC]/* | \
10777 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
10778 ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
10779 /usr/ucb/* ) ;;
10780 *)
10781 # OSF1 and SCO ODT 3.0 have their own names for install.
10782 # Don't use installbsd from OSF since it installs stuff as root
10783 # by default.
10784 for ac_prog in ginstall scoinst install; do
10785 for ac_exec_ext in '' $ac_executable_extensions; do
10786 if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
10787 if test $ac_prog = install &&
10788 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
10789 # AIX install. It has an incompatible calling convention.
10790 :
10791 elif test $ac_prog = install &&
10792 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
10793 # program-specific install script used by HP pwplus--don't use.
10794 :
10795 else
10796 rm -rf conftest.one conftest.two conftest.dir
10797 echo one > conftest.one
10798 echo two > conftest.two
10799 mkdir conftest.dir
10800 if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
10801 test -s conftest.one && test -s conftest.two &&
10802 test -s conftest.dir/conftest.one &&
10803 test -s conftest.dir/conftest.two
10804 then
10805 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
10806 break 3
10807 fi
10808 fi
10809 fi
10810 done
10811 done
10812 ;;
10813 esac
10814
10815 done
10816 IFS=$as_save_IFS
10817
10818 rm -rf conftest.one conftest.two conftest.dir
10819
10820 fi
10821 if test "${ac_cv_path_install+set}" = set; then
10822 INSTALL=$ac_cv_path_install
10823 else
10824 # As a last resort, use the slow shell script. Don't cache a
10825 # value for INSTALL within a source directory, because that will
10826 # break other packages using the cache if that directory is
10827 # removed, or if the value is a relative name.
10828 INSTALL=$ac_install_sh
10829 fi
10830 fi
10831 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
10832 $as_echo "$INSTALL" >&6; }
10833
10834 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
10835 # It thinks the first close brace ends the variable substitution.
10836 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
10837
10838 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
10839
10840 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
10841
10842 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
10843 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
10844 set x ${MAKE-make}
10845 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
10846 if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
10847 $as_echo_n "(cached) " >&6
10848 else
10849 cat >conftest.make <<\_ACEOF
10850 SHELL = /bin/sh
10851 all:
10852 @echo '@@@%%%=$(MAKE)=@@@%%%'
10853 _ACEOF
10854 # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
10855 case `${MAKE-make} -f conftest.make 2>/dev/null` in
10856 *@@@%%%=?*=@@@%%%*)
10857 eval ac_cv_prog_make_${ac_make}_set=yes;;
10858 *)
10859 eval ac_cv_prog_make_${ac_make}_set=no;;
10860 esac
10861 rm -f conftest.make
10862 fi
10863 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
10864 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10865 $as_echo "yes" >&6; }
10866 SET_MAKE=
10867 else
10868 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10869 $as_echo "no" >&6; }
10870 SET_MAKE="MAKE=${MAKE-make}"
10871 fi
10872
10873 if test -z "$host_alias"; then
10874 hostaliaswindres=
10875 else
10876 hostaliaswindres="$host_alias-windres"
10877 fi
10878 for ac_prog in windres $hostaliaswindres $host_os-windres
10879 do
10880 # Extract the first word of "$ac_prog", so it can be a program name with args.
10881 set dummy $ac_prog; ac_word=$2
10882 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10883 $as_echo_n "checking for $ac_word... " >&6; }
10884 if ${ac_cv_prog_WINDRES+:} false; then :
10885 $as_echo_n "(cached) " >&6
10886 else
10887 if test -n "$WINDRES"; then
10888 ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test.
10889 else
10890 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10891 for as_dir in $PATH
10892 do
10893 IFS=$as_save_IFS
10894 test -z "$as_dir" && as_dir=.
10895 for ac_exec_ext in '' $ac_executable_extensions; do
10896 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10897 ac_cv_prog_WINDRES="$ac_prog"
10898 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10899 break 2
10900 fi
10901 done
10902 done
10903 IFS=$as_save_IFS
10904
10905 fi
10906 fi
10907 WINDRES=$ac_cv_prog_WINDRES
10908 if test -n "$WINDRES"; then
10909 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5
10910 $as_echo "$WINDRES" >&6; }
10911 else
10912 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10913 $as_echo "no" >&6; }
10914 fi
10915
10916
10917 test -n "$WINDRES" && break
10918 done
10919
10920
10921 case "$host" in
10922 *-*-cygwin*)
10923 # We build SDL on cygwin without the UNIX emulation layer
10924 BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
10925 BASE_LDFLAGS="-mno-cygwin"
10926 ;;
10927 *)
10928 BASE_CFLAGS="-D_GNU_SOURCE=1"
10929 BASE_LDFLAGS=""
10930 ;;
10931 esac
10932 BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
10933 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
10934 BUILD_LDFLAGS="$LDFLAGS"
10935 EXTRA_LDFLAGS="$BASE_LDFLAGS"
10936 ## These are common directories to find software packages
10937 #for path in /usr/freeware /usr/pkg /usr/local; do
10938 # if test -d $path/include; then
10939 # EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
10940 # fi
10941 # if test -d $path/lib; then
10942 # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
10943 # fi
10944 #done
10945 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
10946 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
10947 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
10948
10949 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
10950 $as_echo_n "checking for an ANSI C-conforming const... " >&6; }
10951 if ${ac_cv_c_const+:} false; then :
10952 $as_echo_n "(cached) " >&6
10953 else
10954 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10955 /* end confdefs.h. */
10956
10957 int
10958 main ()
10959 {
10960
10961 #ifndef __cplusplus
10962 /* Ultrix mips cc rejects this sort of thing. */
10963 typedef int charset[2];
10964 const charset cs = { 0, 0 };
10965 /* SunOS 4.1.1 cc rejects this. */
10966 char const *const *pcpcc;
10967 char **ppc;
10968 /* NEC SVR4.0.2 mips cc rejects this. */
10969 struct point {int x, y;};
10970 static struct point const zero = {0,0};
10971 /* AIX XL C 1.02.0.0 rejects this.
10972 It does not let you subtract one const X* pointer from another in
10973 an arm of an if-expression whose if-part is not a constant
10974 expression */
10975 const char *g = "string";
10976 pcpcc = &g + (g ? g-g : 0);
10977 /* HPUX 7.0 cc rejects these. */
10978 ++pcpcc;
10979 ppc = (char**) pcpcc;
10980 pcpcc = (char const *const *) ppc;
10981 { /* SCO 3.2v4 cc rejects this sort of thing. */
10982 char tx;
10983 char *t = &tx;
10984 char const *s = 0 ? (char *) 0 : (char const *) 0;
10985
10986 *t++ = 0;
10987 if (s) return 0;
10988 }
10989 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
10990 int x[] = {25, 17};
10991 const int *foo = &x[0];
10992 ++foo;
10993 }
10994 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
10995 typedef const int *iptr;
10996 iptr p = 0;
10997 ++p;
10998 }
10999 { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
11000 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
11001 struct s { int j; const int *ap[3]; } bx;
11002 struct s *b = &bx; b->j = 5;
11003 }
11004 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
11005 const int foo = 10;
11006 if (!foo) return 0;
11007 }
11008 return !cs[0] && !zero.x;
11009 #endif
11010
11011 ;
11012 return 0;
11013 }
11014 _ACEOF
11015 if ac_fn_c_try_compile "$LINENO"; then :
11016 ac_cv_c_const=yes
11017 else
11018 ac_cv_c_const=no
11019 fi
11020 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11021 fi
11022 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
11023 $as_echo "$ac_cv_c_const" >&6; }
11024 if test $ac_cv_c_const = no; then
11025
11026 $as_echo "#define const /**/" >>confdefs.h
11027
11028 fi
11029
11030
11031 # Check whether --enable-dependency-tracking was given.
11032 if test "${enable_dependency_tracking+set}" = set; then :
11033 enableval=$enable_dependency_tracking;
11034 else
11035 enable_dependency_tracking=yes
11036 fi
11037
11038 if test x$enable_dependency_tracking = xyes; then
11039 have_gcc_mmd_mt=no
11040 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -MMD -MT option" >&5
11041 $as_echo_n "checking for GCC -MMD -MT option... " >&6; }
11042 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11043 /* end confdefs.h. */
11044
11045 #if !defined(__GNUC__) || __GNUC__ < 3
11046 #error Dependency tracking requires GCC 3.0 or newer
11047 #endif
11048
11049 int
11050 main ()
11051 {
11052
11053
11054 ;
11055 return 0;
11056 }
11057 _ACEOF
11058 if ac_fn_c_try_compile "$LINENO"; then :
11059
11060 have_gcc_mmd_mt=yes
11061
11062 fi
11063 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11064 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmd_mt" >&5
11065 $as_echo "$have_gcc_mmd_mt" >&6; }
11066
11067 if test x$have_gcc_mmd_mt = xyes; then
11068 DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
11069 fi
11070 fi
11071
11072 case "$host" in
11073 *mingw32ce*)
11074 #VERSION_SOURCES="$srcdir/version.rc"
11075 EXE=".exe"
11076 ;;
11077 *-*-cygwin* | *-*-mingw32*)
11078 VERSION_SOURCES="$srcdir/version.rc"
11079 EXE=".exe"
11080 if test "$build" != "$host"; then # cross-compiling
11081 # Default cross-compile location
11082 ac_default_prefix=/usr/local/cross-tools/$host
11083 else
11084 # Look for the location of the tools and install there
11085 if test "$BUILD_PREFIX" != ""; then
11086 ac_default_prefix=$BUILD_PREFIX
11087 fi
11088 fi
11089 ;;
11090 *)
11091 EXE=""
11092 ;;
11093 esac
11094
11095 # Standard C sources
11096 SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
11097
11098 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
11099
11100 CheckVisibilityHidden()
11101 {
11102 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5
11103 $as_echo_n "checking for GCC -fvisibility=hidden option... " >&6; }
11104 have_gcc_fvisibility=no
11105
11106 visibility_CFLAGS="-fvisibility=hidden"
11107 save_CFLAGS="$CFLAGS"
11108 CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
11109 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11110 /* end confdefs.h. */
11111
11112 #if !defined(__GNUC__) || __GNUC__ < 4
11113 #error SDL only uses visibility attributes in GCC 4 or newer
11114 #endif
11115
11116 int
11117 main ()
11118 {
11119
11120
11121 ;
11122 return 0;
11123 }
11124 _ACEOF
11125 if ac_fn_c_try_compile "$LINENO"; then :
11126
11127 have_gcc_fvisibility=yes
11128
11129 fi
11130 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11131 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5
11132 $as_echo "$have_gcc_fvisibility" >&6; }
11133 CFLAGS="$save_CFLAGS"
11134
11135 if test x$have_gcc_fvisibility = xyes; then
11136 EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
11137 fi
11138 }
11139
11140
11141 find_lib()
11142 {
11143 gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
11144 gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
11145 env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`
11146 if test "$cross_compiling" = yes; then
11147 host_lib_path=""
11148 else
11149 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
11150 fi
11151 for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
11152 lib=`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`
11153 if test x$lib != x; then
11154 echo $lib
11155 return
11156 fi
11157 done
11158 }
11159
11160 SDL_VERSION=2.0.7
11161
11162
11163 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
11164 if test -n "$ac_tool_prefix"; then
11165 # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
11166 set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
11167 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11168 $as_echo_n "checking for $ac_word... " >&6; }
11169 if ${ac_cv_path_PKG_CONFIG+:} false; then :
11170 $as_echo_n "(cached) " >&6
11171 else
11172 case $PKG_CONFIG in
11173 [\\/]* | ?:[\\/]*)
11174 ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
11175 ;;
11176 *)
11177 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11178 for as_dir in $PATH
11179 do
11180 IFS=$as_save_IFS
11181 test -z "$as_dir" && as_dir=.
11182 for ac_exec_ext in '' $ac_executable_extensions; do
11183 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
11184 ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
11185 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11186 break 2
11187 fi
11188 done
11189 done
11190 IFS=$as_save_IFS
11191
11192 ;;
11193 esac
11194 fi
11195 PKG_CONFIG=$ac_cv_path_PKG_CONFIG
11196 if test -n "$PKG_CONFIG"; then
11197 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
11198 $as_echo "$PKG_CONFIG" >&6; }
11199 else
11200 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11201 $as_echo "no" >&6; }
11202 fi
11203
11204
11205 fi
11206 if test -z "$ac_cv_path_PKG_CONFIG"; then
11207 ac_pt_PKG_CONFIG=$PKG_CONFIG
11208 # Extract the first word of "pkg-config", so it can be a program name with args.
11209 set dummy pkg-config; ac_word=$2
11210 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11211 $as_echo_n "checking for $ac_word... " >&6; }
11212 if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
11213 $as_echo_n "(cached) " >&6
11214 else
11215 case $ac_pt_PKG_CONFIG in
11216 [\\/]* | ?:[\\/]*)
11217 ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
11218 ;;
11219 *)
11220 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11221 for as_dir in $PATH
11222 do
11223 IFS=$as_save_IFS
11224 test -z "$as_dir" && as_dir=.
11225 for ac_exec_ext in '' $ac_executable_extensions; do
11226 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
11227 ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
11228 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11229 break 2
11230 fi
11231 done
11232 done
11233 IFS=$as_save_IFS
11234
11235 ;;
11236 esac
11237 fi
11238 ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
11239 if test -n "$ac_pt_PKG_CONFIG"; then
11240 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
11241 $as_echo "$ac_pt_PKG_CONFIG" >&6; }
11242 else
11243 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11244 $as_echo "no" >&6; }
11245 fi
11246
11247 if test "x$ac_pt_PKG_CONFIG" = x; then
11248 PKG_CONFIG=""
11249 else
11250 case $cross_compiling:$ac_tool_warned in
11251 yes:)
11252 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
11253 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
11254 ac_tool_warned=yes ;;
11255 esac
11256 PKG_CONFIG=$ac_pt_PKG_CONFIG
11257 fi
11258 else
11259 PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
11260 fi
11261
11262 fi
11263 if test -n "$PKG_CONFIG"; then
11264 _pkg_min_version=0.9.0
11265 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
11266 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
11267 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
11268 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11269 $as_echo "yes" >&6; }
11270 else
11271 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11272 $as_echo "no" >&6; }
11273 PKG_CONFIG=""
11274 fi
11275
11276 fi
11277
11278 # Check whether --with-sdl-prefix was given.
11279 if test "${with_sdl_prefix+set}" = set; then :
11280 withval=$with_sdl_prefix; sdl_prefix="$withval"
11281 else
11282 sdl_prefix=""
11283 fi
11284
11285
11286 # Check whether --with-sdl-exec-prefix was given.
11287 if test "${with_sdl_exec_prefix+set}" = set; then :
11288 withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval"
11289 else
11290 sdl_exec_prefix=""
11291 fi
11292
11293 # Check whether --enable-sdltest was given.
11294 if test "${enable_sdltest+set}" = set; then :
11295 enableval=$enable_sdltest;
11296 else
11297 enable_sdltest=yes
11298 fi
11299
11300
11301 min_sdl_version=$SDL_VERSION
11302
11303 if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
11304
11305 pkg_failed=no
11306 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL" >&5
11307 $as_echo_n "checking for SDL... " >&6; }
11308
11309 if test -n "$PKG_CONFIG"; then
11310 if test -n "$SDL_CFLAGS"; then
11311 pkg_cv_SDL_CFLAGS="$SDL_CFLAGS"
11312 else
11313 if test -n "$PKG_CONFIG" && \
11314 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5
11315 ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5
11316 ac_status=$?
11317 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
11318 test $ac_status = 0; }; then
11319 pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl2 >= $min_sdl_version" 2>/dev/null`
11320 else
11321 pkg_failed=yes
11322 fi
11323 fi
11324 else
11325 pkg_failed=untried
11326 fi
11327 if test -n "$PKG_CONFIG"; then
11328 if test -n "$SDL_LIBS"; then
11329 pkg_cv_SDL_LIBS="$SDL_LIBS"
11330 else
11331 if test -n "$PKG_CONFIG" && \
11332 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5
11333 ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5
11334 ac_status=$?
11335 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
11336 test $ac_status = 0; }; then
11337 pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl2 >= $min_sdl_version" 2>/dev/null`
11338 else
11339 pkg_failed=yes
11340 fi
11341 fi
11342 else
11343 pkg_failed=untried
11344 fi
11345
11346
11347
11348 if test $pkg_failed = yes; then
11349
11350 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
11351 _pkg_short_errors_supported=yes
11352 else
11353 _pkg_short_errors_supported=no
11354 fi
11355 if test $_pkg_short_errors_supported = yes; then
11356 SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "sdl2 >= $min_sdl_version"`
11357 else
11358 SDL_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "sdl2 >= $min_sdl_version"`
11359 fi
11360 # Put the nasty error message in config.log where it belongs
11361 echo "$SDL_PKG_ERRORS" >&5
11362
11363 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11364 $as_echo "no" >&6; }
11365 sdl_pc=no
11366 elif test $pkg_failed = untried; then
11367 sdl_pc=no
11368 else
11369 SDL_CFLAGS=$pkg_cv_SDL_CFLAGS
11370 SDL_LIBS=$pkg_cv_SDL_LIBS
11371 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11372 $as_echo "yes" >&6; }
11373 sdl_pc=yes
11374 fi
11375 else
11376 sdl_pc=no
11377 if test x$sdl_exec_prefix != x ; then
11378 sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
11379 if test x${SDL2_CONFIG+set} != xset ; then
11380 SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config
11381 fi
11382 fi
11383 if test x$sdl_prefix != x ; then
11384 sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
11385 if test x${SDL2_CONFIG+set} != xset ; then
11386 SDL2_CONFIG=$sdl_prefix/bin/sdl2-config
11387 fi
11388 fi
11389 fi
11390
11391 if test "x$sdl_pc" = xyes ; then
11392 no_sdl=""
11393 SDL2_CONFIG="pkg-config sdl2"
11394 else
11395 as_save_PATH="$PATH"
11396 if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
11397 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
11398 fi
11399 # Extract the first word of "sdl2-config", so it can be a program name with args.
11400 set dummy sdl2-config; ac_word=$2
11401 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11402 $as_echo_n "checking for $ac_word... " >&6; }
11403 if ${ac_cv_path_SDL2_CONFIG+:} false; then :
11404 $as_echo_n "(cached) " >&6
11405 else
11406 case $SDL2_CONFIG in
11407 [\\/]* | ?:[\\/]*)
11408 ac_cv_path_SDL2_CONFIG="$SDL2_CONFIG" # Let the user override the test with a path.
11409 ;;
11410 *)
11411 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11412 for as_dir in $PATH
11413 do
11414 IFS=$as_save_IFS
11415 test -z "$as_dir" && as_dir=.
11416 for ac_exec_ext in '' $ac_executable_extensions; do
11417 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
11418 ac_cv_path_SDL2_CONFIG="$as_dir/$ac_word$ac_exec_ext"
11419 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11420 break 2
11421 fi
11422 done
11423 done
11424 IFS=$as_save_IFS
11425
11426 test -z "$ac_cv_path_SDL2_CONFIG" && ac_cv_path_SDL2_CONFIG="no"
11427 ;;
11428 esac
11429 fi
11430 SDL2_CONFIG=$ac_cv_path_SDL2_CONFIG
11431 if test -n "$SDL2_CONFIG"; then
11432 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDL2_CONFIG" >&5
11433 $as_echo "$SDL2_CONFIG" >&6; }
11434 else
11435 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11436 $as_echo "no" >&6; }
11437 fi
11438
11439
11440 PATH="$as_save_PATH"
11441 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5
11442 $as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; }
11443 no_sdl=""
11444
11445 if test "$SDL2_CONFIG" = "no" ; then
11446 no_sdl=yes
11447 else
11448 SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
11449 SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
11450
11451 sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
11452 sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
11453 sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
11454 sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
11455 sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \
11456 sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
11457 if test "x$enable_sdltest" = "xyes" ; then
11458 ac_save_CFLAGS="$CFLAGS"
11459 ac_save_CXXFLAGS="$CXXFLAGS"
11460 ac_save_LIBS="$LIBS"
11461 CFLAGS="$CFLAGS $SDL_CFLAGS"
11462 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
11463 LIBS="$LIBS $SDL_LIBS"
11464 rm -f conf.sdltest
11465 if test "$cross_compiling" = yes; then :
11466 echo $ac_n "cross compiling; assumed OK... $ac_c"
11467 else
11468 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11469 /* end confdefs.h. */
11470
11471 #include <stdio.h>
11472 #include <stdlib.h>
11473 #include <string.h>
11474 #include "SDL.h"
11475
11476 char*
11477 my_strdup (char *str)
11478 {
11479 char *new_str;
11480
11481 if (str)
11482 {
11483 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
11484 strcpy (new_str, str);
11485 }
11486 else
11487 new_str = NULL;
11488
11489 return new_str;
11490 }
11491
11492 int main (int argc, char *argv[])
11493 {
11494 int major, minor, micro;
11495 char *tmp_version;
11496
11497 /* This hangs on some systems (?)
11498 system ("touch conf.sdltest");
11499 */
11500 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
11501
11502 /* HP/UX 9 (%@#!) writes to sscanf strings */
11503 tmp_version = my_strdup("$min_sdl_version");
11504 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
11505 printf("%s, bad version string\n", "$min_sdl_version");
11506 exit(1);
11507 }
11508
11509 if (($sdl_major_version > major) ||
11510 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
11511 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
11512 {
11513 return 0;
11514 }
11515 else
11516 {
11517 printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
11518 printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro);
11519 printf("*** best to upgrade to the required version.\n");
11520 printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n");
11521 printf("*** to point to the correct copy of sdl2-config, and remove the file\n");
11522 printf("*** config.cache before re-running configure\n");
11523 return 1;
11524 }
11525 }
11526
11527
11528 _ACEOF
11529 if ac_fn_c_try_run "$LINENO"; then :
11530
11531 else
11532 no_sdl=yes
11533 fi
11534 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
11535 conftest.$ac_objext conftest.beam conftest.$ac_ext
11536 fi
11537
11538 CFLAGS="$ac_save_CFLAGS"
11539 CXXFLAGS="$ac_save_CXXFLAGS"
11540 LIBS="$ac_save_LIBS"
11541 fi
11542 fi
11543 if test "x$no_sdl" = x ; then
11544 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11545 $as_echo "yes" >&6; }
11546 else
11547 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11548 $as_echo "no" >&6; }
11549 fi
11550 fi
11551 if test "x$no_sdl" = x ; then
11552 :
11553 else
11554 if test "$SDL2_CONFIG" = "no" ; then
11555 echo "*** The sdl2-config script installed by SDL could not be found"
11556 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
11557 echo "*** your path, or set the SDL2_CONFIG environment variable to the"
11558 echo "*** full path to sdl2-config."
11559 else
11560 if test -f conf.sdltest ; then
11561 :
11562 else
11563 echo "*** Could not run SDL test program, checking why..."
11564 CFLAGS="$CFLAGS $SDL_CFLAGS"
11565 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
11566 LIBS="$LIBS $SDL_LIBS"
11567 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11568 /* end confdefs.h. */
11569
11570 #include <stdio.h>
11571 #include "SDL.h"
11572
11573 int main(int argc, char *argv[])
11574 { return 0; }
11575 #undef main
11576 #define main K_and_R_C_main
11577
11578 int
11579 main ()
11580 {
11581 return 0;
11582 ;
11583 return 0;
11584 }
11585 _ACEOF
11586 if ac_fn_c_try_link "$LINENO"; then :
11587 echo "*** The test program compiled, but did not run. This usually means"
11588 echo "*** that the run-time linker is not finding SDL or finding the wrong"
11589 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
11590 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
11591 echo "*** to the installed location Also, make sure you have run ldconfig if that"
11592 echo "*** is required on your system"
11593 echo "***"
11594 echo "*** If you have an old version installed, it is best to remove it, although"
11595 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
11596 else
11597 echo "*** The test program failed to compile or link. See the file config.log for the"
11598 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
11599 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
11600 echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG"
11601 fi
11602 rm -f core conftest.err conftest.$ac_objext \
11603 conftest$ac_exeext conftest.$ac_ext
11604 CFLAGS="$ac_save_CFLAGS"
11605 CXXFLAGS="$ac_save_CXXFLAGS"
11606 LIBS="$ac_save_LIBS"
11607 fi
11608 fi
11609 SDL_CFLAGS=""
11610 SDL_LIBS=""
11611 as_fn_error $? "*** SDL version $SDL_VERSION not found!" "$LINENO" 5
11612
11613 fi
11614
11615
11616 rm -f conf.sdltest
11617
11618 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
11619 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
11620
11621 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5
11622 $as_echo_n "checking for pow in -lm... " >&6; }
11623 if ${ac_cv_lib_m_pow+:} false; then :
11624 $as_echo_n "(cached) " >&6
11625 else
11626 ac_check_lib_save_LIBS=$LIBS
11627 LIBS="-lm $LIBS"
11628 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11629 /* end confdefs.h. */
11630
11631 /* Override any GCC internal prototype to avoid an error.
11632 Use char because int might match the return type of a GCC
11633 builtin and then its argument prototype would still apply. */
11634 #ifdef __cplusplus
11635 extern "C"
11636 #endif
11637 char pow ();
11638 int
11639 main ()
11640 {
11641 return pow ();
11642 ;
11643 return 0;
11644 }
11645 _ACEOF
11646 if ac_fn_c_try_link "$LINENO"; then :
11647 ac_cv_lib_m_pow=yes
11648 else
11649 ac_cv_lib_m_pow=no
11650 fi
11651 rm -f core conftest.err conftest.$ac_objext \
11652 conftest$ac_exeext conftest.$ac_ext
11653 LIBS=$ac_check_lib_save_LIBS
11654 fi
11655 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5
11656 $as_echo "$ac_cv_lib_m_pow" >&6; }
11657 if test "x$ac_cv_lib_m_pow" = xyes; then :
11658 LIBM="-lm"
11659 fi
11660
11661
11662 for ac_header in signal.h
11663 do :
11664 ac_fn_c_check_header_mongrel "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default"
11665 if test "x$ac_cv_header_signal_h" = xyes; then :
11666 cat >>confdefs.h <<_ACEOF
11667 #define HAVE_SIGNAL_H 1
11668 _ACEOF
11669 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"
11670 fi
11671
11672 done
11673
11674 for ac_func in setbuf
11675 do :
11676 ac_fn_c_check_func "$LINENO" "setbuf" "ac_cv_func_setbuf"
11677 if test "x$ac_cv_func_setbuf" = xyes; then :
11678 cat >>confdefs.h <<_ACEOF
11679 #define HAVE_SETBUF 1
11680 _ACEOF
11681 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"
11682 fi
11683 done
11684
11685
11686
11687 CheckVisibilityHidden
11688
11689 # Check whether --enable-music-cmd was given.
11690 if test "${enable_music_cmd+set}" = set; then :
11691 enableval=$enable_music_cmd;
11692 else
11693 enable_music_cmd=detect
11694 fi
11695
11696 if test "x$enable_music_cmd" != xno; then
11697 for ac_func in fork vfork
11698 do :
11699 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
11700 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
11701 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
11702 cat >>confdefs.h <<_ACEOF
11703 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
11704 _ACEOF
11705
11706 fi
11707 done
11708
11709 if test "x$ac_cv_func_fork" = "xyes"; then
11710 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
11711 elif test "x$ac_cv_func_vfork" = "xyes"; then
11712 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
11713 elif test "x$enable_music_cmd" = "xyes"; then
11714 as_fn_error $? "external music player not available on your platform" "$LINENO" 5
11715 else
11716 enable_music_cmd=no
11717 fi
11718 if test "x$enable_music_cmd" != xno; then
11719 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD"
11720 fi
11721 fi
11722
11723 # Check whether --enable-music-wave was given.
11724 if test "${enable_music_wave+set}" = set; then :
11725 enableval=$enable_music_wave;
11726 else
11727 enable_music_wave=yes
11728 fi
11729
11730 if test x$enable_music_wave = xyes; then
11731 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV"
11732 fi
11733
11734 # Check whether --enable-music-mod was given.
11735 if test "${enable_music_mod+set}" = set; then :
11736 enableval=$enable_music_mod;
11737 else
11738 enable_music_mod=yes
11739 fi
11740
11741
11742 # Check whether --enable-music-mod-modplug was given.
11743 if test "${enable_music_mod_modplug+set}" = set; then :
11744 enableval=$enable_music_mod_modplug;
11745 else
11746 enable_music_mod_modplug=yes
11747 fi
11748
11749 # Check whether --enable-music-mod-modplug-shared was given.
11750 if test "${enable_music_mod_modplug_shared+set}" = set; then :
11751 enableval=$enable_music_mod_modplug_shared;
11752 else
11753 enable_music_mod_modplug_shared=yes
11754 fi
11755
11756 if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then
11757
11758 pkg_failed=no
11759 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MODPLUG" >&5
11760 $as_echo_n "checking for MODPLUG... " >&6; }
11761
11762 if test -n "$PKG_CONFIG"; then
11763 if test -n "$MODPLUG_CFLAGS"; then
11764 pkg_cv_MODPLUG_CFLAGS="$MODPLUG_CFLAGS"
11765 else
11766 if test -n "$PKG_CONFIG" && \
11767 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmodplug >= 0.8.8\""; } >&5
11768 ($PKG_CONFIG --exists --print-errors "libmodplug >= 0.8.8") 2>&5
11769 ac_status=$?
11770 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
11771 test $ac_status = 0; }; then
11772 pkg_cv_MODPLUG_CFLAGS=`$PKG_CONFIG --cflags "libmodplug >= 0.8.8" 2>/dev/null`
11773 else
11774 pkg_failed=yes
11775 fi
11776 fi
11777 else
11778 pkg_failed=untried
11779 fi
11780 if test -n "$PKG_CONFIG"; then
11781 if test -n "$MODPLUG_LIBS"; then
11782 pkg_cv_MODPLUG_LIBS="$MODPLUG_LIBS"
11783 else
11784 if test -n "$PKG_CONFIG" && \
11785 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmodplug >= 0.8.8\""; } >&5
11786 ($PKG_CONFIG --exists --print-errors "libmodplug >= 0.8.8") 2>&5
11787 ac_status=$?
11788 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
11789 test $ac_status = 0; }; then
11790 pkg_cv_MODPLUG_LIBS=`$PKG_CONFIG --libs "libmodplug >= 0.8.8" 2>/dev/null`
11791 else
11792 pkg_failed=yes
11793 fi
11794 fi
11795 else
11796 pkg_failed=untried
11797 fi
11798
11799
11800
11801 if test $pkg_failed = yes; then
11802
11803 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
11804 _pkg_short_errors_supported=yes
11805 else
11806 _pkg_short_errors_supported=no
11807 fi
11808 if test $_pkg_short_errors_supported = yes; then
11809 MODPLUG_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libmodplug >= 0.8.8"`
11810 else
11811 MODPLUG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libmodplug >= 0.8.8"`
11812 fi
11813 # Put the nasty error message in config.log where it belongs
11814 echo "$MODPLUG_PKG_ERRORS" >&5
11815
11816 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11817 $as_echo "no" >&6; }
11818 ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default"
11819 if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then :
11820 have_libmodplug_hdr=yes
11821 fi
11822
11823
11824 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5
11825 $as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; }
11826 if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then :
11827 $as_echo_n "(cached) " >&6
11828 else
11829 ac_check_lib_save_LIBS=$LIBS
11830 LIBS="-lmodplug $LIBS"
11831 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11832 /* end confdefs.h. */
11833
11834 /* Override any GCC internal prototype to avoid an error.
11835 Use char because int might match the return type of a GCC
11836 builtin and then its argument prototype would still apply. */
11837 #ifdef __cplusplus
11838 extern "C"
11839 #endif
11840 char ModPlug_Load ();
11841 int
11842 main ()
11843 {
11844 return ModPlug_Load ();
11845 ;
11846 return 0;
11847 }
11848 _ACEOF
11849 if ac_fn_c_try_link "$LINENO"; then :
11850 ac_cv_lib_modplug_ModPlug_Load=yes
11851 else
11852 ac_cv_lib_modplug_ModPlug_Load=no
11853 fi
11854 rm -f core conftest.err conftest.$ac_objext \
11855 conftest$ac_exeext conftest.$ac_ext
11856 LIBS=$ac_check_lib_save_LIBS
11857 fi
11858 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5
11859 $as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; }
11860 if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then :
11861 have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"
11862 fi
11863
11864
11865 elif test $pkg_failed = untried; then
11866 ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default"
11867 if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then :
11868 have_libmodplug_hdr=yes
11869 fi
11870
11871
11872 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5
11873 $as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; }
11874 if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then :
11875 $as_echo_n "(cached) " >&6
11876 else
11877 ac_check_lib_save_LIBS=$LIBS
11878 LIBS="-lmodplug $LIBS"
11879 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11880 /* end confdefs.h. */
11881
11882 /* Override any GCC internal prototype to avoid an error.
11883 Use char because int might match the return type of a GCC
11884 builtin and then its argument prototype would still apply. */
11885 #ifdef __cplusplus
11886 extern "C"
11887 #endif
11888 char ModPlug_Load ();
11889 int
11890 main ()
11891 {
11892 return ModPlug_Load ();
11893 ;
11894 return 0;
11895 }
11896 _ACEOF
11897 if ac_fn_c_try_link "$LINENO"; then :
11898 ac_cv_lib_modplug_ModPlug_Load=yes
11899 else
11900 ac_cv_lib_modplug_ModPlug_Load=no
11901 fi
11902 rm -f core conftest.err conftest.$ac_objext \
11903 conftest$ac_exeext conftest.$ac_ext
11904 LIBS=$ac_check_lib_save_LIBS
11905 fi
11906 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5
11907 $as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; }
11908 if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then :
11909 have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"
11910 fi
11911
11912
11913 else
11914 MODPLUG_CFLAGS=$pkg_cv_MODPLUG_CFLAGS
11915 MODPLUG_LIBS=$pkg_cv_MODPLUG_LIBS
11916 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11917 $as_echo "yes" >&6; }
11918 have_libmodplug_hdr=yes
11919 have_libmodplug_lib=yes
11920
11921 fi
11922
11923 if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
11924 have_libmodplug=yes
11925 case "$host" in
11926 *-*-darwin*)
11927 modplug_lib=`find_lib libmodplug.dylib`
11928 ;;
11929 *-*-cygwin* | *-*-mingw32*)
11930 modplug_lib=`find_lib "libmodplug*.dll"`
11931 ;;
11932 *)
11933 modplug_lib=`find_lib "libmodplug[0-9]*.so.*"`
11934 if test x$modplug_lib = x; then
11935 modplug_lib=`find_lib "libmodplug.so.*"`
11936 fi
11937 ;;
11938 esac
11939 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS"
11940 if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then
11941 echo "-- dynamic libmodplug -> $modplug_lib"
11942 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
11943 else
11944 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
11945 fi
11946 else
11947 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&5
11948 $as_echo "$as_me: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&2;}
11949 fi
11950 fi
11951
11952 # Check whether --enable-music-mod-mikmod was given.
11953 if test "${enable_music_mod_mikmod+set}" = set; then :
11954 enableval=$enable_music_mod_mikmod;
11955 else
11956 enable_music_mod_mikmod=no
11957 fi
11958
11959 # Check whether --enable-music-mod-mikmod-shared was given.
11960 if test "${enable_music_mod_mikmod_shared+set}" = set; then :
11961 enableval=$enable_music_mod_mikmod_shared;
11962 else
11963 enable_music_mod_mikmod_shared=yes
11964 fi
11965
11966 if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then
11967 have_libmikmod=no
11968 libmikmod_maj=3
11969 libmikmod_min=1
11970 libmikmod_rev=10
11971 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
11972 CFLAGS_SAVED="$CFLAGS"
11973 LIBS_SAVED="$LIBS"
11974 # Extract the first word of "libmikmod-config", so it can be a program name with args.
11975 set dummy libmikmod-config; ac_word=$2
11976 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11977 $as_echo_n "checking for $ac_word... " >&6; }
11978 if ${ac_cv_path_LIBMIKMOD_CONFIG+:} false; then :
11979 $as_echo_n "(cached) " >&6
11980 else
11981 case $LIBMIKMOD_CONFIG in
11982 [\\/]* | ?:[\\/]*)
11983 ac_cv_path_LIBMIKMOD_CONFIG="$LIBMIKMOD_CONFIG" # Let the user override the test with a path.
11984 ;;
11985 *)
11986 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11987 for as_dir in $PATH
11988 do
11989 IFS=$as_save_IFS
11990 test -z "$as_dir" && as_dir=.
11991 for ac_exec_ext in '' $ac_executable_extensions; do
11992 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
11993 ac_cv_path_LIBMIKMOD_CONFIG="$as_dir/$ac_word$ac_exec_ext"
11994 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11995 break 2
11996 fi
11997 done
11998 done
11999 IFS=$as_save_IFS
12000
12001 test -z "$ac_cv_path_LIBMIKMOD_CONFIG" && ac_cv_path_LIBMIKMOD_CONFIG="no"
12002 ;;
12003 esac
12004 fi
12005 LIBMIKMOD_CONFIG=$ac_cv_path_LIBMIKMOD_CONFIG
12006 if test -n "$LIBMIKMOD_CONFIG"; then
12007 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBMIKMOD_CONFIG" >&5
12008 $as_echo "$LIBMIKMOD_CONFIG" >&6; }
12009 else
12010 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12011 $as_echo "no" >&6; }
12012 fi
12013
12014
12015 if test "$LIBMIKMOD_CONFIG" != "no" ; then
12016 CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
12017 LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
12018 have_libmikmod=yes
12019 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmikmod - version >= $libmikmod_ver" >&5
12020 $as_echo_n "checking for libmikmod - version >= $libmikmod_ver... " >&6; }
12021 if test "$cross_compiling" = yes; then :
12022 echo $ac_n "cross compiling; assumed OK... $ac_c"
12023 else
12024 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12025 /* end confdefs.h. */
12026
12027 #include "mikmod.h"
12028 #include "stdio.h"
12029
12030 int main(int argc, char **argv)
12031 {
12032 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
12033 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
12034 if(ver>=((maj<<16)|(min<<8)|(rev))) {
12035 printf("yes\n");
12036 return 0;
12037 }
12038 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
12039 return 1;
12040 }
12041
12042 _ACEOF
12043 if ac_fn_c_try_run "$LINENO"; then :
12044
12045 else
12046 have_libmikmod=no
12047 fi
12048 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
12049 conftest.$ac_objext conftest.beam conftest.$ac_ext
12050 fi
12051
12052 fi
12053
12054 if test x$have_libmikmod = xyes; then
12055 case "$host" in
12056 *-*-darwin*)
12057 mikmod_lib=`find_lib libmikmod.dylib`
12058 ;;
12059 *-*-cygwin* | *-*-mingw32*)
12060 mikmod_lib=`find_lib "libmikmod*.dll"`
12061 ;;
12062 *)
12063 mikmod_lib=`find_lib "libmikmod[0-9]*.so.*"`
12064 if test x$mikmod_lib = x; then
12065 mikmod_lib=`find_lib "libmikmod.so.*"`
12066 fi
12067 ;;
12068 esac
12069 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
12070 if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
12071 echo "-- dynamic libmikmod -> $mikmod_lib"
12072 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
12073 else
12074 EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
12075 fi
12076 else
12077 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find MikMod library (http://mikmod.raphnet.net/)" >&5
12078 $as_echo "$as_me: WARNING: *** Unable to find MikMod library (http://mikmod.raphnet.net/)" >&2;}
12079 fi
12080 LIBS="$LIBS_SAVED"
12081 CFLAGS="$CFLAGS_SAVED"
12082 fi
12083
12084 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
12085 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5
12086 $as_echo "$as_me: WARNING: MOD support disabled" >&2;}
12087 fi
12088
12089 # Check whether --enable-music-midi was given.
12090 if test "${enable_music_midi+set}" = set; then :
12091 enableval=$enable_music_midi;
12092 else
12093 enable_music_midi=yes
12094 fi
12095
12096 if test x$enable_music_midi = xyes; then
12097 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID"
12098 # Check whether --enable-music-midi-timidity was given.
12099 if test "${enable_music_midi_timidity+set}" = set; then :
12100 enableval=$enable_music_midi_timidity;
12101 else
12102 enable_music_midi_timidity=yes
12103 fi
12104
12105 if test x$enable_music_midi_timidity = xyes; then
12106 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
12107 SOURCES="$SOURCES $srcdir/timidity/*.c"
12108 fi
12109 # Check whether --enable-music-midi-native was given.
12110 if test "${enable_music_midi_native+set}" = set; then :
12111 enableval=$enable_music_midi_native;
12112 else
12113 enable_music_midi_native=yes
12114 fi
12115
12116 if test x$enable_music_midi_native = xyes; then
12117 use_music_midi_native=no
12118 case "$host" in
12119 *mingw32ce*)
12120 use_music_midi_native=no
12121 ;;
12122 *-*-cygwin* | *-*-mingw32*)
12123 use_music_midi_native=yes
12124 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
12125 ;;
12126 *-*-darwin*)
12127 use_music_midi_native=yes
12128 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
12129 ;;
12130 *-*-haiku*)
12131 use_music_midi_native=yes_cpp
12132 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
12133 ;;
12134 esac
12135 if test x$use_music_midi_native = xyes; then
12136 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
12137 SOURCES="$SOURCES $srcdir/native_midi/*.c"
12138 elif test x$use_music_midi_native = xyes_cpp; then
12139 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
12140 SOURCES="$SOURCES $srcdir/native_midi/*.c"
12141 SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
12142 fi
12143 fi
12144 # Check whether --enable-music-midi-fluidsynth was given.
12145 if test "${enable_music_midi_fluidsynth+set}" = set; then :
12146 enableval=$enable_music_midi_fluidsynth;
12147 else
12148 enable_music_midi_fluidsynth=yes
12149 fi
12150
12151 # Check whether --enable-music-midi-fluidsynth-shared was given.
12152 if test "${enable_music_midi_fluidsynth_shared+set}" = set; then :
12153 enableval=$enable_music_midi_fluidsynth_shared;
12154 else
12155 enable_music_midi_fluidsynth_shared=yes
12156 fi
12157
12158 if test x$enable_music_midi_fluidsynth = xyes; then
12159 ac_fn_c_check_header_mongrel "$LINENO" "fluidsynth.h" "ac_cv_header_fluidsynth_h" "$ac_includes_default"
12160 if test "x$ac_cv_header_fluidsynth_h" = xyes; then :
12161 have_fluidsynth_hdr=yes
12162 fi
12163
12164
12165 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fluid_player_add_mem in -lfluidsynth" >&5
12166 $as_echo_n "checking for fluid_player_add_mem in -lfluidsynth... " >&6; }
12167 if ${ac_cv_lib_fluidsynth_fluid_player_add_mem+:} false; then :
12168 $as_echo_n "(cached) " >&6
12169 else
12170 ac_check_lib_save_LIBS=$LIBS
12171 LIBS="-lfluidsynth $LIBS"
12172 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12173 /* end confdefs.h. */
12174
12175 /* Override any GCC internal prototype to avoid an error.
12176 Use char because int might match the return type of a GCC
12177 builtin and then its argument prototype would still apply. */
12178 #ifdef __cplusplus
12179 extern "C"
12180 #endif
12181 char fluid_player_add_mem ();
12182 int
12183 main ()
12184 {
12185 return fluid_player_add_mem ();
12186 ;
12187 return 0;
12188 }
12189 _ACEOF
12190 if ac_fn_c_try_link "$LINENO"; then :
12191 ac_cv_lib_fluidsynth_fluid_player_add_mem=yes
12192 else
12193 ac_cv_lib_fluidsynth_fluid_player_add_mem=no
12194 fi
12195 rm -f core conftest.err conftest.$ac_objext \
12196 conftest$ac_exeext conftest.$ac_ext
12197 LIBS=$ac_check_lib_save_LIBS
12198 fi
12199 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fluidsynth_fluid_player_add_mem" >&5
12200 $as_echo "$ac_cv_lib_fluidsynth_fluid_player_add_mem" >&6; }
12201 if test "x$ac_cv_lib_fluidsynth_fluid_player_add_mem" = xyes; then :
12202 have_fluidsynth_lib=yes
12203 fi
12204
12205 if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
12206 have_fluidsynth=yes
12207 case "$host" in
12208 *-*-darwin*)
12209 fluidsynth_lib=`find_lib libfluidsynth.dylib`
12210 ;;
12211 *-*-cygwin* | *-*-mingw32*)
12212 fluidsynth_lib=`find_lib "fluidsynth*.dll"`
12213 ;;
12214 *)
12215 fluidsynth_lib=`find_lib "libfluidsynth[0-9]*.so.*"`
12216 if test x$fluidsynth_lib = x; then
12217 fluidsynth_lib=`find_lib "libfluidsynth.so.*"`
12218 fi
12219 ;;
12220 esac
12221 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
12222 if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
12223 echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
12224 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
12225 else
12226 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
12227 fi
12228 else
12229 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&5
12230 $as_echo "$as_me: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&2;}
12231 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: FluidSynth support disabled" >&5
12232 $as_echo "$as_me: WARNING: FluidSynth support disabled" >&2;}
12233 fi
12234 fi
12235 fi
12236
12237 if test x$enable_music_midi_timidity != xyes -a \
12238 x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
12239 x$have_fluidsynth != xyes; then
12240 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5
12241 $as_echo "$as_me: WARNING: MIDI support disabled" >&2;}
12242 fi
12243
12244 # Check whether --enable-music-ogg was given.
12245 if test "${enable_music_ogg+set}" = set; then :
12246 enableval=$enable_music_ogg;
12247 else
12248 enable_music_ogg=yes
12249 fi
12250
12251 # Check whether --enable-music-ogg-tremor was given.
12252 if test "${enable_music_ogg_tremor+set}" = set; then :
12253 enableval=$enable_music_ogg_tremor;
12254 else
12255 enable_music_ogg_tremor=no
12256 fi
12257
12258 # Check whether --enable-music-ogg-shared was given.
12259 if test "${enable_music_ogg_shared+set}" = set; then :
12260 enableval=$enable_music_ogg_shared;
12261 else
12262 enable_music_ogg_shared=yes
12263 fi
12264
12265 if test x$enable_music_ogg = xyes; then
12266 LIBS_SAVED="$LIBS"
12267 if test x$enable_music_ogg_tremor = xyes; then
12268 ac_fn_c_check_header_mongrel "$LINENO" "tremor/ivorbisfile.h" "ac_cv_header_tremor_ivorbisfile_h" "$ac_includes_default"
12269 if test "x$ac_cv_header_tremor_ivorbisfile_h" = xyes; then :
12270 have_tremor_hdr=yes
12271 fi
12272
12273
12274 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ov_open_callbacks in -lvorbisidec" >&5
12275 $as_echo_n "checking for ov_open_callbacks in -lvorbisidec... " >&6; }
12276 if ${ac_cv_lib_vorbisidec_ov_open_callbacks+:} false; then :
12277 $as_echo_n "(cached) " >&6
12278 else
12279 ac_check_lib_save_LIBS=$LIBS
12280 LIBS="-lvorbisidec -logg $LIBS"
12281 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12282 /* end confdefs.h. */
12283
12284 /* Override any GCC internal prototype to avoid an error.
12285 Use char because int might match the return type of a GCC
12286 builtin and then its argument prototype would still apply. */
12287 #ifdef __cplusplus
12288 extern "C"
12289 #endif
12290 char ov_open_callbacks ();
12291 int
12292 main ()
12293 {
12294 return ov_open_callbacks ();
12295 ;
12296 return 0;
12297 }
12298 _ACEOF
12299 if ac_fn_c_try_link "$LINENO"; then :
12300 ac_cv_lib_vorbisidec_ov_open_callbacks=yes
12301 else
12302 ac_cv_lib_vorbisidec_ov_open_callbacks=no
12303 fi
12304 rm -f core conftest.err conftest.$ac_objext \
12305 conftest$ac_exeext conftest.$ac_ext
12306 LIBS=$ac_check_lib_save_LIBS
12307 fi
12308 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbisidec_ov_open_callbacks" >&5
12309 $as_echo "$ac_cv_lib_vorbisidec_ov_open_callbacks" >&6; }
12310 if test "x$ac_cv_lib_vorbisidec_ov_open_callbacks" = xyes; then :
12311 have_tremor_lib=yes
12312 fi
12313
12314 if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
12315 case "$host" in
12316 *-*-darwin*)
12317 ogg_lib=`find_lib libvorbisidec.dylib`
12318 ;;
12319 *-*-cygwin* | *-*-mingw32*)
12320 ogg_lib=`find_lib "vorbisidec*.dll"`
12321 ;;
12322 *)
12323 ogg_lib=`find_lib "libvorbisidec[0-9]*.so.*"`
12324 if test x$ogg_lib = x; then
12325 ogg_lib=`find_lib "libvorbisidec.so.*"`
12326 fi
12327 ;;
12328 esac
12329 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
12330 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
12331 echo "-- dynamic libvorbisidec -> $ogg_lib"
12332 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
12333 else
12334 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
12335 fi
12336 else
12337 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&5
12338 $as_echo "$as_me: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&2;}
12339 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ogg Vorbis support disabled" >&5
12340 $as_echo "$as_me: WARNING: Ogg Vorbis support disabled" >&2;}
12341 fi
12342 else
12343 ac_fn_c_check_header_mongrel "$LINENO" "vorbis/vorbisfile.h" "ac_cv_header_vorbis_vorbisfile_h" "$ac_includes_default"
12344 if test "x$ac_cv_header_vorbis_vorbisfile_h" = xyes; then :
12345 have_ogg_hdr=yes
12346 fi
12347
12348
12349 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ov_open_callbacks in -lvorbisfile" >&5
12350 $as_echo_n "checking for ov_open_callbacks in -lvorbisfile... " >&6; }
12351 if ${ac_cv_lib_vorbisfile_ov_open_callbacks+:} false; then :
12352 $as_echo_n "(cached) " >&6
12353 else
12354 ac_check_lib_save_LIBS=$LIBS
12355 LIBS="-lvorbisfile -lvorbis -logg -lm $LIBS"
12356 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12357 /* end confdefs.h. */
12358
12359 /* Override any GCC internal prototype to avoid an error.
12360 Use char because int might match the return type of a GCC
12361 builtin and then its argument prototype would still apply. */
12362 #ifdef __cplusplus
12363 extern "C"
12364 #endif
12365 char ov_open_callbacks ();
12366 int
12367 main ()
12368 {
12369 return ov_open_callbacks ();
12370 ;
12371 return 0;
12372 }
12373 _ACEOF
12374 if ac_fn_c_try_link "$LINENO"; then :
12375 ac_cv_lib_vorbisfile_ov_open_callbacks=yes
12376 else
12377 ac_cv_lib_vorbisfile_ov_open_callbacks=no
12378 fi
12379 rm -f core conftest.err conftest.$ac_objext \
12380 conftest$ac_exeext conftest.$ac_ext
12381 LIBS=$ac_check_lib_save_LIBS
12382 fi
12383 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbisfile_ov_open_callbacks" >&5
12384 $as_echo "$ac_cv_lib_vorbisfile_ov_open_callbacks" >&6; }
12385 if test "x$ac_cv_lib_vorbisfile_ov_open_callbacks" = xyes; then :
12386 have_ogg_lib=yes
12387 fi
12388
12389 if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
12390 case "$host" in
12391 *-*-darwin*)
12392 ogg_lib=`find_lib libvorbisfile.dylib`
12393 ;;
12394 *-*-cygwin* | *-*-mingw32*)
12395 ogg_lib=`find_lib "libvorbisfile*.dll"`
12396 ;;
12397 *)
12398 ogg_lib=`find_lib "libvorbisfile[0-9]*.so.*"`
12399 if test x$ogg_lib = x; then
12400 ogg_lib=`find_lib "libvorbisfile.so.*"`
12401 fi
12402 ;;
12403 esac
12404 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
12405 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
12406 echo "-- dynamic libvorbisfile -> $ogg_lib"
12407 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
12408 else
12409 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
12410 fi
12411 else
12412 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&5
12413 $as_echo "$as_me: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&2;}
12414 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ogg Vorbis support disabled" >&5
12415 $as_echo "$as_me: WARNING: Ogg Vorbis support disabled" >&2;}
12416 fi
12417 fi
12418 LIBS="$LIBS_SAVED"
12419 fi
12420
12421 libflac_ver=8
12422 # Check whether --enable-music-flac was given.
12423 if test "${enable_music_flac+set}" = set; then :
12424 enableval=$enable_music_flac;
12425 else
12426 enable_music_flac=yes
12427 fi
12428
12429 # Check whether --enable-music-flac-shared was given.
12430 if test "${enable_music_flac_shared+set}" = set; then :
12431 enableval=$enable_music_flac_shared;
12432 else
12433 enable_music_flac_shared=yes
12434 fi
12435
12436 if test x$enable_music_flac = xyes; then
12437 ac_fn_c_check_header_mongrel "$LINENO" "FLAC/export.h" "ac_cv_header_FLAC_export_h" "$ac_includes_default"
12438 if test "x$ac_cv_header_FLAC_export_h" = xyes; then :
12439 have_flac_export=yes
12440 fi
12441
12442
12443 if test x$have_flac_export = xyes; then
12444 LIBS_SAVED="$LIBS"
12445 LIBS="-lFLAC"
12446 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libflac so-name version >= $libflac_ver" >&5
12447 $as_echo_n "checking for libflac so-name version >= $libflac_ver... " >&6; }
12448 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12449 /* end confdefs.h. */
12450
12451 #include "FLAC/export.h"
12452 #include "stdio.h"
12453
12454 int
12455 main ()
12456 {
12457
12458 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
12459 #else
12460 #error "old-flac"
12461 #endif
12462
12463 ;
12464 return 0;
12465 }
12466 _ACEOF
12467 if ac_fn_c_try_compile "$LINENO"; then :
12468 have_flac_ver=yes
12469 else
12470 have_flac_ver=no
12471 fi
12472 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12473 LIBS="$LIBS_SAVED"
12474 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_flac_ver" >&5
12475 $as_echo "$have_flac_ver" >&6; }
12476 fi
12477
12478 if test x$have_flac_ver = xyes; then
12479 ac_fn_c_check_header_mongrel "$LINENO" "FLAC/stream_decoder.h" "ac_cv_header_FLAC_stream_decoder_h" "$ac_includes_default"
12480 if test "x$ac_cv_header_FLAC_stream_decoder_h" = xyes; then :
12481 have_flac_hdr=yes
12482 fi
12483
12484
12485 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLAC__stream_decoder_new in -lFLAC" >&5
12486 $as_echo_n "checking for FLAC__stream_decoder_new in -lFLAC... " >&6; }
12487 if ${ac_cv_lib_FLAC_FLAC__stream_decoder_new+:} false; then :
12488 $as_echo_n "(cached) " >&6
12489 else
12490 ac_check_lib_save_LIBS=$LIBS
12491 LIBS="-lFLAC $LIBS"
12492 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12493 /* end confdefs.h. */
12494
12495 /* Override any GCC internal prototype to avoid an error.
12496 Use char because int might match the return type of a GCC
12497 builtin and then its argument prototype would still apply. */
12498 #ifdef __cplusplus
12499 extern "C"
12500 #endif
12501 char FLAC__stream_decoder_new ();
12502 int
12503 main ()
12504 {
12505 return FLAC__stream_decoder_new ();
12506 ;
12507 return 0;
12508 }
12509 _ACEOF
12510 if ac_fn_c_try_link "$LINENO"; then :
12511 ac_cv_lib_FLAC_FLAC__stream_decoder_new=yes
12512 else
12513 ac_cv_lib_FLAC_FLAC__stream_decoder_new=no
12514 fi
12515 rm -f core conftest.err conftest.$ac_objext \
12516 conftest$ac_exeext conftest.$ac_ext
12517 LIBS=$ac_check_lib_save_LIBS
12518 fi
12519 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_FLAC_FLAC__stream_decoder_new" >&5
12520 $as_echo "$ac_cv_lib_FLAC_FLAC__stream_decoder_new" >&6; }
12521 if test "x$ac_cv_lib_FLAC_FLAC__stream_decoder_new" = xyes; then :
12522 have_flac_lib=yes
12523 fi
12524
12525 if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
12526 case "$host" in
12527 *-*-darwin*)
12528 flac_lib=`find_lib libFLAC.dylib`
12529 ;;
12530 *-*-cygwin* | *-*-mingw32*)
12531 flac_lib=`find_lib "libFLAC-*.dll"`
12532 ;;
12533 *)
12534 flac_lib=`find_lib "libFLAC[0-9]*.so.*"`
12535 if test x$flac_lib = x; then
12536 flac_lib=`find_lib "libFLAC.so.*"`
12537 fi
12538 ;;
12539 esac
12540 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
12541 if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
12542 echo "-- dynamic libFLAC -> $flac_lib"
12543 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
12544 else
12545 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
12546 fi
12547 fi
12548 else
12549 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FLAC library (http://flac.sourceforge.net/)" >&5
12550 $as_echo "$as_me: WARNING: *** Unable to find FLAC library (http://flac.sourceforge.net/)" >&2;}
12551 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: FLAC support disabled" >&5
12552 $as_echo "$as_me: WARNING: FLAC support disabled" >&2;}
12553 fi
12554 fi
12555
12556 # Check whether --enable-music-mp3 was given.
12557 if test "${enable_music_mp3+set}" = set; then :
12558 enableval=$enable_music_mp3;
12559 else
12560 enable_music_mp3=yes
12561 fi
12562
12563
12564 # Check whether --enable-music-mp3-mad-gpl was given.
12565 if test "${enable_music_mp3_mad_gpl+set}" = set; then :
12566 enableval=$enable_music_mp3_mad_gpl;
12567 else
12568 enable_music_mp3_mad_gpl=no
12569 fi
12570
12571 # Check whether --enable-music-mp3-mad-gpl-dithering was given.
12572 if test "${enable_music_mp3_mad_gpl_dithering+set}" = set; then :
12573 enableval=$enable_music_mp3_mad_gpl_dithering;
12574 else
12575 enable_music_mp3_mad_gpl_dithering=yes
12576 fi
12577
12578 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
12579 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmad headers" >&5
12580 $as_echo_n "checking for libmad headers... " >&6; }
12581 have_libmad=no
12582 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12583 /* end confdefs.h. */
12584
12585 #include "mad.h"
12586
12587 int
12588 main ()
12589 {
12590
12591
12592 ;
12593 return 0;
12594 }
12595 _ACEOF
12596 if ac_fn_c_try_compile "$LINENO"; then :
12597
12598 have_libmad=yes
12599
12600 fi
12601 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12602 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_libmad" >&5
12603 $as_echo "$have_libmad" >&6; }
12604 if test x$have_libmad = xyes; then
12605 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
12606 if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
12607 { $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
12608 $as_echo "$as_me: WARNING: *** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL" >&2;}
12609 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
12610 fi
12611 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
12612 else
12613 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)" >&5
12614 $as_echo "$as_me: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)" >&2;}
12615 fi
12616 fi
12617
12618 # Check whether --enable-music-mp3-mpg123 was given.
12619 if test "${enable_music_mp3_mpg123+set}" = set; then :
12620 enableval=$enable_music_mp3_mpg123;
12621 else
12622 enable_music_mp3_mpg123=yes
12623 fi
12624
12625 # Check whether --enable-music-mp3-mpg123-shared was given.
12626 if test "${enable_music_mp3_mpg123_shared+set}" = set; then :
12627 enableval=$enable_music_mp3_mpg123_shared;
12628 else
12629 enable_music_mp3_mpg123_shared=yes
12630 fi
12631
12632 if test x$enable_music_mp3_mpg123 = xyes; then
12633 ac_fn_c_check_header_mongrel "$LINENO" "mpg123.h" "ac_cv_header_mpg123_h" "$ac_includes_default"
12634 if test "x$ac_cv_header_mpg123_h" = xyes; then :
12635 have_mpg123_hdr=yes
12636 fi
12637
12638
12639 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpg123_replace_reader_handle in -lmpg123" >&5
12640 $as_echo_n "checking for mpg123_replace_reader_handle in -lmpg123... " >&6; }
12641 if ${ac_cv_lib_mpg123_mpg123_replace_reader_handle+:} false; then :
12642 $as_echo_n "(cached) " >&6
12643 else
12644 ac_check_lib_save_LIBS=$LIBS
12645 LIBS="-lmpg123 $LIBS"
12646 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12647 /* end confdefs.h. */
12648
12649 /* Override any GCC internal prototype to avoid an error.
12650 Use char because int might match the return type of a GCC
12651 builtin and then its argument prototype would still apply. */
12652 #ifdef __cplusplus
12653 extern "C"
12654 #endif
12655 char mpg123_replace_reader_handle ();
12656 int
12657 main ()
12658 {
12659 return mpg123_replace_reader_handle ();
12660 ;
12661 return 0;
12662 }
12663 _ACEOF
12664 if ac_fn_c_try_link "$LINENO"; then :
12665 ac_cv_lib_mpg123_mpg123_replace_reader_handle=yes
12666 else
12667 ac_cv_lib_mpg123_mpg123_replace_reader_handle=no
12668 fi
12669 rm -f core conftest.err conftest.$ac_objext \
12670 conftest$ac_exeext conftest.$ac_ext
12671 LIBS=$ac_check_lib_save_LIBS
12672 fi
12673 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&5
12674 $as_echo "$ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&6; }
12675 if test "x$ac_cv_lib_mpg123_mpg123_replace_reader_handle" = xyes; then :
12676 have_mpg123_lib=yes
12677 fi
12678
12679 if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
12680 have_libmpg123=yes
12681 case "$host" in
12682 *-*-darwin*)
12683 mpg123_lib=`find_lib libmpg123.dylib`
12684 ;;
12685 *-*-cygwin* | *-*-mingw32*)
12686 mpg123_lib=`find_lib "libmpg123*.dll"`
12687 ;;
12688 *)
12689 mpg123_lib=`find_lib "libmpg123.so.*"`
12690 ;;
12691 esac
12692 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
12693 if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
12694 echo "-- dynamic libmpg123 -> $mpg123_lib"
12695 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
12696 else
12697 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
12698 fi
12699 else
12700 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&5
12701 $as_echo "$as_me: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&2;}
12702 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mpg123 support disabled" >&5
12703 $as_echo "$as_me: WARNING: mpg123 support disabled" >&2;}
12704 fi
12705 fi
12706
12707 if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
12708 :
12709 else
12710 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MP3 support disabled" >&5
12711 $as_echo "$as_me: WARNING: MP3 support disabled" >&2;}
12712 fi
12713
12714 # Check whether --enable-music-opus was given.
12715 if test "${enable_music_opus+set}" = set; then :
12716 enableval=$enable_music_opus;
12717 else
12718 enable_music_opus=yes
12719 fi
12720
12721
12722 # Check whether --enable-music-opus-shared was given.
12723 if test "${enable_music_opus_shared+set}" = set; then :
12724 enableval=$enable_music_opus_shared;
12725 else
12726 enable_music_opus_shared=yes
12727 fi
12728
12729 if test x$enable_music_opus = xyes; then
12730 LIBS_SAVED="$LIBS"
12731
12732 pkg_failed=no
12733 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPUSFILE" >&5
12734 $as_echo_n "checking for OPUSFILE... " >&6; }
12735
12736 if test -n "$PKG_CONFIG"; then
12737 if test -n "$OPUSFILE_CFLAGS"; then
12738 pkg_cv_OPUSFILE_CFLAGS="$OPUSFILE_CFLAGS"
12739 else
12740 if test -n "$PKG_CONFIG" && \
12741 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5
12742 ($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5
12743 ac_status=$?
12744 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12745 test $ac_status = 0; }; then
12746 pkg_cv_OPUSFILE_CFLAGS=`$PKG_CONFIG --cflags "opusfile >= 0.2" 2>/dev/null`
12747 else
12748 pkg_failed=yes
12749 fi
12750 fi
12751 else
12752 pkg_failed=untried
12753 fi
12754 if test -n "$PKG_CONFIG"; then
12755 if test -n "$OPUSFILE_LIBS"; then
12756 pkg_cv_OPUSFILE_LIBS="$OPUSFILE_LIBS"
12757 else
12758 if test -n "$PKG_CONFIG" && \
12759 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5
12760 ($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5
12761 ac_status=$?
12762 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12763 test $ac_status = 0; }; then
12764 pkg_cv_OPUSFILE_LIBS=`$PKG_CONFIG --libs "opusfile >= 0.2" 2>/dev/null`
12765 else
12766 pkg_failed=yes
12767 fi
12768 fi
12769 else
12770 pkg_failed=untried
12771 fi
12772
12773
12774
12775 if test $pkg_failed = yes; then
12776
12777 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
12778 _pkg_short_errors_supported=yes
12779 else
12780 _pkg_short_errors_supported=no
12781 fi
12782 if test $_pkg_short_errors_supported = yes; then
12783 OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "opusfile >= 0.2"`
12784 else
12785 OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "opusfile >= 0.2"`
12786 fi
12787 # Put the nasty error message in config.log where it belongs
12788 echo "$OPUSFILE_PKG_ERRORS" >&5
12789
12790 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12791 $as_echo "no" >&6; }
12792 ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
12793 if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
12794 have_opusfile_hdr=yes
12795 fi
12796
12797
12798 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
12799 $as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
12800 if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
12801 $as_echo_n "(cached) " >&6
12802 else
12803 ac_check_lib_save_LIBS=$LIBS
12804 LIBS="-lopusfile -lopus -logg -lm $LIBS"
12805 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12806 /* end confdefs.h. */
12807
12808 /* Override any GCC internal prototype to avoid an error.
12809 Use char because int might match the return type of a GCC
12810 builtin and then its argument prototype would still apply. */
12811 #ifdef __cplusplus
12812 extern "C"
12813 #endif
12814 char op_open_callbacks ();
12815 int
12816 main ()
12817 {
12818 return op_open_callbacks ();
12819 ;
12820 return 0;
12821 }
12822 _ACEOF
12823 if ac_fn_c_try_link "$LINENO"; then :
12824 ac_cv_lib_opusfile_op_open_callbacks=yes
12825 else
12826 ac_cv_lib_opusfile_op_open_callbacks=no
12827 fi
12828 rm -f core conftest.err conftest.$ac_objext \
12829 conftest$ac_exeext conftest.$ac_ext
12830 LIBS=$ac_check_lib_save_LIBS
12831 fi
12832 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
12833 $as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
12834 if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
12835 have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"
12836 fi
12837
12838
12839 elif test $pkg_failed = untried; then
12840 ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
12841 if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
12842 have_opusfile_hdr=yes
12843 fi
12844
12845
12846 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
12847 $as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
12848 if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
12849 $as_echo_n "(cached) " >&6
12850 else
12851 ac_check_lib_save_LIBS=$LIBS
12852 LIBS="-lopusfile -lopus -logg -lm $LIBS"
12853 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12854 /* end confdefs.h. */
12855
12856 /* Override any GCC internal prototype to avoid an error.
12857 Use char because int might match the return type of a GCC
12858 builtin and then its argument prototype would still apply. */
12859 #ifdef __cplusplus
12860 extern "C"
12861 #endif
12862 char op_open_callbacks ();
12863 int
12864 main ()
12865 {
12866 return op_open_callbacks ();
12867 ;
12868 return 0;
12869 }
12870 _ACEOF
12871 if ac_fn_c_try_link "$LINENO"; then :
12872 ac_cv_lib_opusfile_op_open_callbacks=yes
12873 else
12874 ac_cv_lib_opusfile_op_open_callbacks=no
12875 fi
12876 rm -f core conftest.err conftest.$ac_objext \
12877 conftest$ac_exeext conftest.$ac_ext
12878 LIBS=$ac_check_lib_save_LIBS
12879 fi
12880 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
12881 $as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
12882 if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
12883 have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"
12884 fi
12885
12886
12887 else
12888 OPUSFILE_CFLAGS=$pkg_cv_OPUSFILE_CFLAGS
12889 OPUSFILE_LIBS=$pkg_cv_OPUSFILE_LIBS
12890 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12891 $as_echo "yes" >&6; }
12892 have_opusfile_hdr=yes
12893 have_opusfile_lib=yes
12894
12895 fi
12896 LIBS="$LIBS_SAVED"
12897
12898 if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
12899 have_opusfile=yes
12900 case "$host" in
12901 *-*-darwin*)
12902 opusfile_lib=`find_lib libopusfile.dylib`
12903 ;;
12904 *-*-cygwin* | *-*-mingw32*)
12905 opusfile_lib=`find_lib "libopusfile*.dll"`
12906 ;;
12907 *)
12908 opusfile_lib=`find_lib "libopusfile[0-9]*.so.*"`
12909 if test x$opusfile_lib = x; then
12910 opusfile_lib=`find_lib "libopusfile.so.*"`
12911 fi
12912 ;;
12913 esac
12914 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
12915 if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
12916 echo "-- dynamic opusfile -> $opusfile_lib"
12917 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
12918 else
12919 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
12920 fi
12921 else
12922 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&5
12923 $as_echo "$as_me: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&2;}
12924 fi
12925 fi
12926
12927 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
12928
12929 OBJECTS=`echo $SOURCES`
12930 DEPENDS=`echo $SOURCES`
12931 OBJECTS=`echo "$OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
12932 DEPENDS=`echo "$DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\
12933 $(objects)/\2.lo: \1/\2.c\\
12934 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
12935
12936 OBJECTS_CXX=`echo $SOURCES_CXX`
12937 DEPENDS_CXX=`echo $SOURCES_CXX`
12938 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[^ ]*/\([^ ]*\)\.cpp,$(objects)/\1.lo,g'`
12939 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([^ ]*\)/\([^ ]*\)\.cpp,\\
12940 $(objects)/\2.lo: \1/\2.cpp\\
12941 \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
12942 OBJECTS="$OBJECTS $OBJECTS_CXX"
12943 DEPENDS="$DEPENDS $DEPENDS_CXX"
12944 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
12945
12946 VERSION_OBJECTS=`echo $VERSION_SOURCES`
12947 VERSION_DEPENDS=`echo $VERSION_SOURCES`
12948 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.rc,$(objects)/\1.o,g'`
12949 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.rc,\\
12950 $(objects)/\2.o: \1/\2.rc\\
12951 \$(WINDRES) \$< \$@,g'`
12952 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
12953
12954 PLAYWAVE_SOURCES="$srcdir/playwave.c"
12955 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
12956 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
12957 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
12958 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\
12959 $(objects)/\2.lo: \1/\2.c\\
12960 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
12961 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
12962
12963 PLAYMUS_SOURCES="$srcdir/playmus.c"
12964 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
12965 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
12966 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
12967 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\
12968 $(objects)/\2.lo: \1/\2.c\\
12969 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
12970 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987 ac_config_files="$ac_config_files "
12988
12989 cat >confcache <<\_ACEOF
12990 # This file is a shell script that caches the results of configure
12991 # tests run on this system so they can be shared between configure
12992 # scripts and configure runs, see configure's option --config-cache.
12993 # It is not useful on other systems. If it contains results you don't
12994 # want to keep, you may remove or edit it.
12995 #
12996 # config.status only pays attention to the cache file if you give it
12997 # the --recheck option to rerun configure.
12998 #
12999 # `ac_cv_env_foo' variables (set or unset) will be overridden when
13000 # loading this file, other *unset* `ac_cv_foo' will be assigned the
13001 # following values.
13002
13003 _ACEOF
13004
13005 # The following way of writing the cache mishandles newlines in values,
13006 # but we know of no workaround that is simple, portable, and efficient.
13007 # So, we kill variables containing newlines.
13008 # Ultrix sh set writes to stderr and can't be redirected directly,
13009 # and sets the high bit in the cache file unless we assign to the vars.
13010 (
13011 for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
13012 eval ac_val=\$$ac_var
13013 case $ac_val in #(
13014 *${as_nl}*)
13015 case $ac_var in #(
13016 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
13017 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
13018 esac
13019 case $ac_var in #(
13020 _ | IFS | as_nl) ;; #(
13021 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
13022 *) { eval $ac_var=; unset $ac_var;} ;;
13023 esac ;;
13024 esac
13025 done
13026
13027 (set) 2>&1 |
13028 case $as_nl`(ac_space=' '; set) 2>&1` in #(
13029 *${as_nl}ac_space=\ *)
13030 # `set' does not quote correctly, so add quotes: double-quote
13031 # substitution turns \\\\ into \\, and sed turns \\ into \.
13032 sed -n \
13033 "s/'/'\\\\''/g;
13034 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
13035 ;; #(
13036 *)
13037 # `set' quotes correctly as required by POSIX, so do not add quotes.
13038 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
13039 ;;
13040 esac |
13041 sort
13042 ) |
13043 sed '
13044 /^ac_cv_env_/b end
13045 t clear
13046 :clear
13047 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
13048 t end
13049 s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
13050 :end' >>confcache
13051 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
13052 if test -w "$cache_file"; then
13053 if test "x$cache_file" != "x/dev/null"; then
13054 { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
13055 $as_echo "$as_me: updating cache $cache_file" >&6;}
13056 if test ! -f "$cache_file" || test -h "$cache_file"; then
13057 cat confcache >"$cache_file"
13058 else
13059 case $cache_file in #(
13060 */* | ?:*)
13061 mv -f confcache "$cache_file"$$ &&
13062 mv -f "$cache_file"$$ "$cache_file" ;; #(
13063 *)
13064 mv -f confcache "$cache_file" ;;
13065 esac
13066 fi
13067 fi
13068 else
13069 { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
13070 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
13071 fi
13072 fi
13073 rm -f confcache
13074
13075 test "x$prefix" = xNONE && prefix=$ac_default_prefix
13076 # Let make expand exec_prefix.
13077 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
13078
13079 # Transform confdefs.h into DEFS.
13080 # Protect against shell expansion while executing Makefile rules.
13081 # Protect against Makefile macro expansion.
13082 #
13083 # If the first sed substitution is executed (which looks for macros that
13084 # take arguments), then branch to the quote section. Otherwise,
13085 # look for a macro that doesn't take arguments.
13086 ac_script='
13087 :mline
13088 /\\$/{
13089 N
13090 s,\\\n,,
13091 b mline
13092 }
13093 t clear
13094 :clear
13095 s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
13096 t quote
13097 s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
13098 t quote
13099 b any
13100 :quote
13101 s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
13102 s/\[/\\&/g
13103 s/\]/\\&/g
13104 s/\$/$$/g
13105 H
13106 :any
13107 ${
13108 g
13109 s/^\n//
13110 s/\n/ /g
13111 p
13112 }
13113 '
13114 DEFS=`sed -n "$ac_script" confdefs.h`
13115
13116
13117 ac_libobjs=
13118 ac_ltlibobjs=
13119 U=
13120 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
13121 # 1. Remove the extension, and $U if already installed.
13122 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
13123 ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
13124 # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
13125 # will be set to the directory where LIBOBJS objects are built.
13126 as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
13127 as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
13128 done
13129 LIBOBJS=$ac_libobjs
13130
13131 LTLIBOBJS=$ac_ltlibobjs
13132
13133
13134
13135 : "${CONFIG_STATUS=./config.status}"
13136 ac_write_fail=0
13137 ac_clean_files_save=$ac_clean_files
13138 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
13139 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
13140 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
13141 as_write_fail=0
13142 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
13143 #! $SHELL
13144 # Generated by $as_me.
13145 # Run this file to recreate the current configuration.
13146 # Compiler output produced by configure, useful for debugging
13147 # configure, is in config.log if it exists.
13148
13149 debug=false
13150 ac_cs_recheck=false
13151 ac_cs_silent=false
13152
13153 SHELL=\${CONFIG_SHELL-$SHELL}
13154 export SHELL
13155 _ASEOF
13156 cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
13157 ## -------------------- ##
13158 ## M4sh Initialization. ##
13159 ## -------------------- ##
13160
13161 # Be more Bourne compatible
13162 DUALCASE=1; export DUALCASE # for MKS sh
13163 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
13164 emulate sh
13165 NULLCMD=:
13166 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
13167 # is contrary to our usage. Disable this feature.
13168 alias -g '${1+"$@"}'='"$@"'
13169 setopt NO_GLOB_SUBST
13170 else
13171 case `(set -o) 2>/dev/null` in #(
13172 *posix*) :
13173 set -o posix ;; #(
13174 *) :
13175 ;;
13176 esac
13177 fi
13178
13179
13180 as_nl='
13181 '
13182 export as_nl
13183 # Printing a long string crashes Solaris 7 /usr/bin/printf.
13184 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
13185 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
13186 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
13187 # Prefer a ksh shell builtin over an external printf program on Solaris,
13188 # but without wasting forks for bash or zsh.
13189 if test -z "$BASH_VERSION$ZSH_VERSION" \
13190 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
13191 as_echo='print -r --'
13192 as_echo_n='print -rn --'
13193 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
13194 as_echo='printf %s\n'
13195 as_echo_n='printf %s'
13196 else
13197 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
13198 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
13199 as_echo_n='/usr/ucb/echo -n'
13200 else
13201 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
13202 as_echo_n_body='eval
13203 arg=$1;
13204 case $arg in #(
13205 *"$as_nl"*)
13206 expr "X$arg" : "X\\(.*\\)$as_nl";
13207 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
13208 esac;
13209 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
13210 '
13211 export as_echo_n_body
13212 as_echo_n='sh -c $as_echo_n_body as_echo'
13213 fi
13214 export as_echo_body
13215 as_echo='sh -c $as_echo_body as_echo'
13216 fi
13217
13218 # The user is always right.
13219 if test "${PATH_SEPARATOR+set}" != set; then
13220 PATH_SEPARATOR=:
13221 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
13222 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
13223 PATH_SEPARATOR=';'
13224 }
13225 fi
13226
13227
13228 # IFS
13229 # We need space, tab and new line, in precisely that order. Quoting is
13230 # there to prevent editors from complaining about space-tab.
13231 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
13232 # splitting by setting IFS to empty value.)
13233 IFS=" "" $as_nl"
13234
13235 # Find who we are. Look in the path if we contain no directory separator.
13236 as_myself=
13237 case $0 in #((
13238 *[\\/]* ) as_myself=$0 ;;
13239 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
13240 for as_dir in $PATH
13241 do
13242 IFS=$as_save_IFS
13243 test -z "$as_dir" && as_dir=.
13244 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
13245 done
13246 IFS=$as_save_IFS
13247
13248 ;;
13249 esac
13250 # We did not find ourselves, most probably we were run as `sh COMMAND'
13251 # in which case we are not to be found in the path.
13252 if test "x$as_myself" = x; then
13253 as_myself=$0
13254 fi
13255 if test ! -f "$as_myself"; then
13256 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
13257 exit 1
13258 fi
13259
13260 # Unset variables that we do not need and which cause bugs (e.g. in
13261 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
13262 # suppresses any "Segmentation fault" message there. '((' could
13263 # trigger a bug in pdksh 5.2.14.
13264 for as_var in BASH_ENV ENV MAIL MAILPATH
13265 do eval test x\${$as_var+set} = xset \
13266 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
13267 done
13268 PS1='$ '
13269 PS2='> '
13270 PS4='+ '
13271
13272 # NLS nuisances.
13273 LC_ALL=C
13274 export LC_ALL
13275 LANGUAGE=C
13276 export LANGUAGE
13277
13278 # CDPATH.
13279 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
13280
13281
13282 # as_fn_error STATUS ERROR [LINENO LOG_FD]
13283 # ----------------------------------------
13284 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
13285 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
13286 # script with STATUS, using 1 if that was 0.
13287 as_fn_error ()
13288 {
13289 as_status=$1; test $as_status -eq 0 && as_status=1
13290 if test "$4"; then
13291 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
13292 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
13293 fi
13294 $as_echo "$as_me: error: $2" >&2
13295 as_fn_exit $as_status
13296 } # as_fn_error
13297
13298
13299 # as_fn_set_status STATUS
13300 # -----------------------
13301 # Set $? to STATUS, without forking.
13302 as_fn_set_status ()
13303 {
13304 return $1
13305 } # as_fn_set_status
13306
13307 # as_fn_exit STATUS
13308 # -----------------
13309 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
13310 as_fn_exit ()
13311 {
13312 set +e
13313 as_fn_set_status $1
13314 exit $1
13315 } # as_fn_exit
13316
13317 # as_fn_unset VAR
13318 # ---------------
13319 # Portably unset VAR.
13320 as_fn_unset ()
13321 {
13322 { eval $1=; unset $1;}
13323 }
13324 as_unset=as_fn_unset
13325 # as_fn_append VAR VALUE
13326 # ----------------------
13327 # Append the text in VALUE to the end of the definition contained in VAR. Take
13328 # advantage of any shell optimizations that allow amortized linear growth over
13329 # repeated appends, instead of the typical quadratic growth present in naive
13330 # implementations.
13331 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
13332 eval 'as_fn_append ()
13333 {
13334 eval $1+=\$2
13335 }'
13336 else
13337 as_fn_append ()
13338 {
13339 eval $1=\$$1\$2
13340 }
13341 fi # as_fn_append
13342
13343 # as_fn_arith ARG...
13344 # ------------------
13345 # Perform arithmetic evaluation on the ARGs, and store the result in the
13346 # global $as_val. Take advantage of shells that can avoid forks. The arguments
13347 # must be portable across $(()) and expr.
13348 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
13349 eval 'as_fn_arith ()
13350 {
13351 as_val=$(( $* ))
13352 }'
13353 else
13354 as_fn_arith ()
13355 {
13356 as_val=`expr "$@" || test $? -eq 1`
13357 }
13358 fi # as_fn_arith
13359
13360
13361 if expr a : '\(a\)' >/dev/null 2>&1 &&
13362 test "X`expr 00001 : '.*\(...\)'`" = X001; then
13363 as_expr=expr
13364 else
13365 as_expr=false
13366 fi
13367
13368 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
13369 as_basename=basename
13370 else
13371 as_basename=false
13372 fi
13373
13374 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
13375 as_dirname=dirname
13376 else
13377 as_dirname=false
13378 fi
13379
13380 as_me=`$as_basename -- "$0" ||
13381 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
13382 X"$0" : 'X\(//\)$' \| \
13383 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
13384 $as_echo X/"$0" |
13385 sed '/^.*\/\([^/][^/]*\)\/*$/{
13386 s//\1/
13387 q
13388 }
13389 /^X\/\(\/\/\)$/{
13390 s//\1/
13391 q
13392 }
13393 /^X\/\(\/\).*/{
13394 s//\1/
13395 q
13396 }
13397 s/.*/./; q'`
13398
13399 # Avoid depending upon Character Ranges.
13400 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
13401 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
13402 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
13403 as_cr_digits='0123456789'
13404 as_cr_alnum=$as_cr_Letters$as_cr_digits
13405
13406 ECHO_C= ECHO_N= ECHO_T=
13407 case `echo -n x` in #(((((
13408 -n*)
13409 case `echo 'xy\c'` in
13410 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
13411 xy) ECHO_C='\c';;
13412 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
13413 ECHO_T=' ';;
13414 esac;;
13415 *)
13416 ECHO_N='-n';;
13417 esac
13418
13419 rm -f conf$$ conf$$.exe conf$$.file
13420 if test -d conf$$.dir; then
13421 rm -f conf$$.dir/conf$$.file
13422 else
13423 rm -f conf$$.dir
13424 mkdir conf$$.dir 2>/dev/null
13425 fi
13426 if (echo >conf$$.file) 2>/dev/null; then
13427 if ln -s conf$$.file conf$$ 2>/dev/null; then
13428 as_ln_s='ln -s'
13429 # ... but there are two gotchas:
13430 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
13431 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
13432 # In both cases, we have to default to `cp -pR'.
13433 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
13434 as_ln_s='cp -pR'
13435 elif ln conf$$.file conf$$ 2>/dev/null; then
13436 as_ln_s=ln
13437 else
13438 as_ln_s='cp -pR'
13439 fi
13440 else
13441 as_ln_s='cp -pR'
13442 fi
13443 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
13444 rmdir conf$$.dir 2>/dev/null
13445
13446
13447 # as_fn_mkdir_p
13448 # -------------
13449 # Create "$as_dir" as a directory, including parents if necessary.
13450 as_fn_mkdir_p ()
13451 {
13452
13453 case $as_dir in #(
13454 -*) as_dir=./$as_dir;;
13455 esac
13456 test -d "$as_dir" || eval $as_mkdir_p || {
13457 as_dirs=
13458 while :; do
13459 case $as_dir in #(
13460 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
13461 *) as_qdir=$as_dir;;
13462 esac
13463 as_dirs="'$as_qdir' $as_dirs"
13464 as_dir=`$as_dirname -- "$as_dir" ||
13465 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
13466 X"$as_dir" : 'X\(//\)[^/]' \| \
13467 X"$as_dir" : 'X\(//\)$' \| \
13468 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
13469 $as_echo X"$as_dir" |
13470 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
13471 s//\1/
13472 q
13473 }
13474 /^X\(\/\/\)[^/].*/{
13475 s//\1/
13476 q
13477 }
13478 /^X\(\/\/\)$/{
13479 s//\1/
13480 q
13481 }
13482 /^X\(\/\).*/{
13483 s//\1/
13484 q
13485 }
13486 s/.*/./; q'`
13487 test -d "$as_dir" && break
13488 done
13489 test -z "$as_dirs" || eval "mkdir $as_dirs"
13490 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
13491
13492
13493 } # as_fn_mkdir_p
13494 if mkdir -p . 2>/dev/null; then
13495 as_mkdir_p='mkdir -p "$as_dir"'
13496 else
13497 test -d ./-p && rmdir ./-p
13498 as_mkdir_p=false
13499 fi
13500
13501
13502 # as_fn_executable_p FILE
13503 # -----------------------
13504 # Test if FILE is an executable regular file.
13505 as_fn_executable_p ()
13506 {
13507 test -f "$1" && test -x "$1"
13508 } # as_fn_executable_p
13509 as_test_x='test -x'
13510 as_executable_p=as_fn_executable_p
13511
13512 # Sed expression to map a string onto a valid CPP name.
13513 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
13514
13515 # Sed expression to map a string onto a valid variable name.
13516 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
13517
13518
13519 exec 6>&1
13520 ## ----------------------------------- ##
13521 ## Main body of $CONFIG_STATUS script. ##
13522 ## ----------------------------------- ##
13523 _ASEOF
13524 test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
13525
13526 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13527 # Save the log message, to keep $0 and so on meaningful, and to
13528 # report actual input values of CONFIG_FILES etc. instead of their
13529 # values after options handling.
13530 ac_log="
13531 This file was extended by $as_me, which was
13532 generated by GNU Autoconf 2.69. Invocation command line was
13533
13534 CONFIG_FILES = $CONFIG_FILES
13535 CONFIG_HEADERS = $CONFIG_HEADERS
13536 CONFIG_LINKS = $CONFIG_LINKS
13537 CONFIG_COMMANDS = $CONFIG_COMMANDS
13538 $ $0 $@
13539
13540 on `(hostname || uname -n) 2>/dev/null | sed 1q`
13541 "
13542
13543 _ACEOF
13544
13545 case $ac_config_files in *"
13546 "*) set x $ac_config_files; shift; ac_config_files=$*;;
13547 esac
13548
13549
13550
13551 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
13552 # Files that config.status was made for.
13553 config_files="$ac_config_files"
13554 config_commands="$ac_config_commands"
13555
13556 _ACEOF
13557
13558 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13559 ac_cs_usage="\
13560 \`$as_me' instantiates files and other configuration actions
13561 from templates according to the current configuration. Unless the files
13562 and actions are specified as TAGs, all are instantiated by default.
13563
13564 Usage: $0 [OPTION]... [TAG]...
13565
13566 -h, --help print this help, then exit
13567 -V, --version print version number and configuration settings, then exit
13568 --config print configuration, then exit
13569 -q, --quiet, --silent
13570 do not print progress messages
13571 -d, --debug don't remove temporary files
13572 --recheck update $as_me by reconfiguring in the same conditions
13573 --file=FILE[:TEMPLATE]
13574 instantiate the configuration file FILE
13575
13576 Configuration files:
13577 $config_files
13578
13579 Configuration commands:
13580 $config_commands
13581
13582 Report bugs to the package provider."
13583
13584 _ACEOF
13585 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
13586 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
13587 ac_cs_version="\\
13588 config.status
13589 configured by $0, generated by GNU Autoconf 2.69,
13590 with options \\"\$ac_cs_config\\"
13591
13592 Copyright (C) 2012 Free Software Foundation, Inc.
13593 This config.status script is free software; the Free Software Foundation
13594 gives unlimited permission to copy, distribute and modify it."
13595
13596 ac_pwd='$ac_pwd'
13597 srcdir='$srcdir'
13598 INSTALL='$INSTALL'
13599 test -n "\$AWK" || AWK=awk
13600 _ACEOF
13601
13602 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13603 # The default lists apply if the user does not specify any file.
13604 ac_need_defaults=:
13605 while test $# != 0
13606 do
13607 case $1 in
13608 --*=?*)
13609 ac_option=`expr "X$1" : 'X\([^=]*\)='`
13610 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
13611 ac_shift=:
13612 ;;
13613 --*=)
13614 ac_option=`expr "X$1" : 'X\([^=]*\)='`
13615 ac_optarg=
13616 ac_shift=:
13617 ;;
13618 *)
13619 ac_option=$1
13620 ac_optarg=$2
13621 ac_shift=shift
13622 ;;
13623 esac
13624
13625 case $ac_option in
13626 # Handling of the options.
13627 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
13628 ac_cs_recheck=: ;;
13629 --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
13630 $as_echo "$ac_cs_version"; exit ;;
13631 --config | --confi | --conf | --con | --co | --c )
13632 $as_echo "$ac_cs_config"; exit ;;
13633 --debug | --debu | --deb | --de | --d | -d )
13634 debug=: ;;
13635 --file | --fil | --fi | --f )
13636 $ac_shift
13637 case $ac_optarg in
13638 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
13639 '') as_fn_error $? "missing file argument" ;;
13640 esac
13641 as_fn_append CONFIG_FILES " '$ac_optarg'"
13642 ac_need_defaults=false;;
13643 --he | --h | --help | --hel | -h )
13644 $as_echo "$ac_cs_usage"; exit ;;
13645 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
13646 | -silent | --silent | --silen | --sile | --sil | --si | --s)
13647 ac_cs_silent=: ;;
13648
13649 # This is an error.
13650 -*) as_fn_error $? "unrecognized option: \`$1'
13651 Try \`$0 --help' for more information." ;;
13652
13653 *) as_fn_append ac_config_targets " $1"
13654 ac_need_defaults=false ;;
13655
13656 esac
13657 shift
13658 done
13659
13660 ac_configure_extra_args=
13661
13662 if $ac_cs_silent; then
13663 exec 6>/dev/null
13664 ac_configure_extra_args="$ac_configure_extra_args --silent"
13665 fi
13666
13667 _ACEOF
13668 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
13669 if \$ac_cs_recheck; then
13670 set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
13671 shift
13672 \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
13673 CONFIG_SHELL='$SHELL'
13674 export CONFIG_SHELL
13675 exec "\$@"
13676 fi
13677
13678 _ACEOF
13679 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13680 exec 5>>config.log
13681 {
13682 echo
13683 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
13684 ## Running $as_me. ##
13685 _ASBOX
13686 $as_echo "$ac_log"
13687 } >&5
13688
13689 _ACEOF
13690 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
13691 #
13692 # INIT-COMMANDS
13693 #
13694
13695
13696 # The HP-UX ksh and POSIX shell print the target directory to stdout
13697 # if CDPATH is set.
13698 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
13699
13700 sed_quote_subst='$sed_quote_subst'
13701 double_quote_subst='$double_quote_subst'
13702 delay_variable_subst='$delay_variable_subst'
13703 macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
13704 macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
13705 AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`'
13706 DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`'
13707 OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
13708 enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
13709 enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
13710 pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
13711 enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
13712 host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
13713 host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
13714 host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
13715 build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
13716 build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
13717 build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
13718 SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
13719 Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
13720 GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
13721 EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
13722 FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
13723 LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
13724 NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
13725 LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
13726 max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
13727 ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
13728 exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
13729 lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
13730 lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
13731 lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
13732 reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
13733 reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13734 deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
13735 file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
13736 AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
13737 AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
13738 STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
13739 RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
13740 old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13741 old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13742 old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13743 CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
13744 CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
13745 compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
13746 GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
13747 lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
13748 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
13749 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"`'
13750 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"`'
13751 objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
13752 SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
13753 ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
13754 MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
13755 lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
13756 lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
13757 lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
13758 lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
13759 lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
13760 need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
13761 DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
13762 NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
13763 LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
13764 OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
13765 OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
13766 libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
13767 shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13768 extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13769 archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
13770 enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
13771 export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
13772 whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
13773 compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
13774 old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13775 old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13776 archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13777 archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13778 module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13779 module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13780 with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
13781 allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
13782 no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
13783 hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
13784 hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
13785 hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
13786 hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
13787 hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
13788 hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
13789 hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
13790 hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
13791 inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
13792 link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
13793 fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
13794 always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
13795 export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13796 exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
13797 include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
13798 prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13799 file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
13800 variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
13801 need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
13802 need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
13803 version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
13804 runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
13805 shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
13806 shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
13807 libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
13808 library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
13809 soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
13810 postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13811 postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13812 finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
13813 finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
13814 hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
13815 sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
13816 sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
13817 hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
13818 enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
13819 enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
13820 enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
13821 old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
13822 striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
13823
13824 LTCC='$LTCC'
13825 LTCFLAGS='$LTCFLAGS'
13826 compiler='$compiler_DEFAULT'
13827
13828 # Quote evaled strings.
13829 for var in SED \
13830 GREP \
13831 EGREP \
13832 FGREP \
13833 LD \
13834 NM \
13835 LN_S \
13836 lt_SP2NL \
13837 lt_NL2SP \
13838 reload_flag \
13839 deplibs_check_method \
13840 file_magic_cmd \
13841 AR \
13842 AR_FLAGS \
13843 STRIP \
13844 RANLIB \
13845 CC \
13846 CFLAGS \
13847 compiler \
13848 lt_cv_sys_global_symbol_pipe \
13849 lt_cv_sys_global_symbol_to_cdecl \
13850 lt_cv_sys_global_symbol_to_c_name_address \
13851 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
13852 SHELL \
13853 ECHO \
13854 lt_prog_compiler_no_builtin_flag \
13855 lt_prog_compiler_wl \
13856 lt_prog_compiler_pic \
13857 lt_prog_compiler_static \
13858 lt_cv_prog_compiler_c_o \
13859 need_locks \
13860 DSYMUTIL \
13861 NMEDIT \
13862 LIPO \
13863 OTOOL \
13864 OTOOL64 \
13865 shrext_cmds \
13866 export_dynamic_flag_spec \
13867 whole_archive_flag_spec \
13868 compiler_needs_object \
13869 with_gnu_ld \
13870 allow_undefined_flag \
13871 no_undefined_flag \
13872 hardcode_libdir_flag_spec \
13873 hardcode_libdir_flag_spec_ld \
13874 hardcode_libdir_separator \
13875 fix_srcfile_path \
13876 exclude_expsyms \
13877 include_expsyms \
13878 file_list_spec \
13879 variables_saved_for_relink \
13880 libname_spec \
13881 library_names_spec \
13882 soname_spec \
13883 finish_eval \
13884 old_striplib \
13885 striplib; do
13886 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
13887 *[\\\\\\\`\\"\\\$]*)
13888 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
13889 ;;
13890 *)
13891 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
13892 ;;
13893 esac
13894 done
13895
13896 # Double-quote double-evaled strings.
13897 for var in reload_cmds \
13898 old_postinstall_cmds \
13899 old_postuninstall_cmds \
13900 old_archive_cmds \
13901 extract_expsyms_cmds \
13902 old_archive_from_new_cmds \
13903 old_archive_from_expsyms_cmds \
13904 archive_cmds \
13905 archive_expsym_cmds \
13906 module_cmds \
13907 module_expsym_cmds \
13908 export_symbols_cmds \
13909 prelink_cmds \
13910 postinstall_cmds \
13911 postuninstall_cmds \
13912 finish_cmds \
13913 sys_lib_search_path_spec \
13914 sys_lib_dlsearch_path_spec; do
13915 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
13916 *[\\\\\\\`\\"\\\$]*)
13917 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
13918 ;;
13919 *)
13920 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
13921 ;;
13922 esac
13923 done
13924
13925 # Fix-up fallback echo if it was mangled by the above quoting rules.
13926 case \$lt_ECHO in
13927 *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
13928 ;;
13929 esac
13930
13931 ac_aux_dir='$ac_aux_dir'
13932 xsi_shell='$xsi_shell'
13933 lt_shell_append='$lt_shell_append'
13934
13935 # See if we are running on zsh, and set the options which allow our
13936 # commands through without removal of \ escapes INIT.
13937 if test -n "\${ZSH_VERSION+set}" ; then
13938 setopt NO_GLOB_SUBST
13939 fi
13940
13941
13942 PACKAGE='$PACKAGE'
13943 VERSION='$VERSION'
13944 TIMESTAMP='$TIMESTAMP'
13945 RM='$RM'
13946 ofile='$ofile'
13947
13948
13949
13950
13951 _ACEOF
13952
13953 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13954
13955 # Handling of arguments.
13956 for ac_config_target in $ac_config_targets
13957 do
13958 case $ac_config_target in
13959 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
13960
13961 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
13962 esac
13963 done
13964
13965
13966 # If the user did not use the arguments to specify the items to instantiate,
13967 # then the envvar interface is used. Set only those that are not.
13968 # We use the long form for the default assignment because of an extremely
13969 # bizarre bug on SunOS 4.1.3.
13970 if $ac_need_defaults; then
13971 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
13972 test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
13973 fi
13974
13975 # Have a temporary directory for convenience. Make it in the build tree
13976 # simply because there is no reason against having it here, and in addition,
13977 # creating and moving files from /tmp can sometimes cause problems.
13978 # Hook for its removal unless debugging.
13979 # Note that there is a small window in which the directory will not be cleaned:
13980 # after its creation but before its name has been assigned to `$tmp'.
13981 $debug ||
13982 {
13983 tmp= ac_tmp=
13984 trap 'exit_status=$?
13985 : "${ac_tmp:=$tmp}"
13986 { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
13987 ' 0
13988 trap 'as_fn_exit 1' 1 2 13 15
13989 }
13990 # Create a (secure) tmp directory for tmp files.
13991
13992 {
13993 tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
13994 test -d "$tmp"
13995 } ||
13996 {
13997 tmp=./conf$$-$RANDOM
13998 (umask 077 && mkdir "$tmp")
13999 } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
14000 ac_tmp=$tmp
14001
14002 # Set up the scripts for CONFIG_FILES section.
14003 # No need to generate them if there are no CONFIG_FILES.
14004 # This happens for instance with `./config.status config.h'.
14005 if test -n "$CONFIG_FILES"; then
14006
14007
14008 ac_cr=`echo X | tr X '\015'`
14009 # On cygwin, bash can eat \r inside `` if the user requested igncr.
14010 # But we know of no other shell where ac_cr would be empty at this
14011 # point, so we can use a bashism as a fallback.
14012 if test "x$ac_cr" = x; then
14013 eval ac_cr=\$\'\\r\'
14014 fi
14015 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
14016 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
14017 ac_cs_awk_cr='\\r'
14018 else
14019 ac_cs_awk_cr=$ac_cr
14020 fi
14021
14022 echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
14023 _ACEOF
14024
14025
14026 {
14027 echo "cat >conf$$subs.awk <<_ACEOF" &&
14028 echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
14029 echo "_ACEOF"
14030 } >conf$$subs.sh ||
14031 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
14032 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
14033 ac_delim='%!_!# '
14034 for ac_last_try in false false false false false :; do
14035 . ./conf$$subs.sh ||
14036 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
14037
14038 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
14039 if test $ac_delim_n = $ac_delim_num; then
14040 break
14041 elif $ac_last_try; then
14042 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
14043 else
14044 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
14045 fi
14046 done
14047 rm -f conf$$subs.sh
14048
14049 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
14050 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
14051 _ACEOF
14052 sed -n '
14053 h
14054 s/^/S["/; s/!.*/"]=/
14055 p
14056 g
14057 s/^[^!]*!//
14058 :repl
14059 t repl
14060 s/'"$ac_delim"'$//
14061 t delim
14062 :nl
14063 h
14064 s/\(.\{148\}\)..*/\1/
14065 t more1
14066 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
14067 p
14068 n
14069 b repl
14070 :more1
14071 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
14072 p
14073 g
14074 s/.\{148\}//
14075 t nl
14076 :delim
14077 h
14078 s/\(.\{148\}\)..*/\1/
14079 t more2
14080 s/["\\]/\\&/g; s/^/"/; s/$/"/
14081 p
14082 b
14083 :more2
14084 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
14085 p
14086 g
14087 s/.\{148\}//
14088 t delim
14089 ' <conf$$subs.awk | sed '
14090 /^[^""]/{
14091 N
14092 s/\n//
14093 }
14094 ' >>$CONFIG_STATUS || ac_write_fail=1
14095 rm -f conf$$subs.awk
14096 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
14097 _ACAWK
14098 cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
14099 for (key in S) S_is_set[key] = 1
14100 FS = ""
14101
14102 }
14103 {
14104 line = $ 0
14105 nfields = split(line, field, "@")
14106 substed = 0
14107 len = length(field[1])
14108 for (i = 2; i < nfields; i++) {
14109 key = field[i]
14110 keylen = length(key)
14111 if (S_is_set[key]) {
14112 value = S[key]
14113 line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
14114 len += length(value) + length(field[++i])
14115 substed = 1
14116 } else
14117 len += 1 + keylen
14118 }
14119
14120 print line
14121 }
14122
14123 _ACAWK
14124 _ACEOF
14125 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
14126 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
14127 sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
14128 else
14129 cat
14130 fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
14131 || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
14132 _ACEOF
14133
14134 # VPATH may cause trouble with some makes, so we remove sole $(srcdir),
14135 # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
14136 # trailing colons and then remove the whole line if VPATH becomes empty
14137 # (actually we leave an empty line to preserve line numbers).
14138 if test "x$srcdir" = x.; then
14139 ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
14140 h
14141 s///
14142 s/^/:/
14143 s/[ ]*$/:/
14144 s/:\$(srcdir):/:/g
14145 s/:\${srcdir}:/:/g
14146 s/:@srcdir@:/:/g
14147 s/^:*//
14148 s/:*$//
14149 x
14150 s/\(=[ ]*\).*/\1/
14151 G
14152 s/\n//
14153 s/^[^=]*=[ ]*$//
14154 }'
14155 fi
14156
14157 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
14158 fi # test -n "$CONFIG_FILES"
14159
14160
14161 eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS"
14162 shift
14163 for ac_tag
14164 do
14165 case $ac_tag in
14166 :[FHLC]) ac_mode=$ac_tag; continue;;
14167 esac
14168 case $ac_mode$ac_tag in
14169 :[FHL]*:*);;
14170 :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
14171 :[FH]-) ac_tag=-:-;;
14172 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
14173 esac
14174 ac_save_IFS=$IFS
14175 IFS=:
14176 set x $ac_tag
14177 IFS=$ac_save_IFS
14178 shift
14179 ac_file=$1
14180 shift
14181
14182 case $ac_mode in
14183 :L) ac_source=$1;;
14184 :[FH])
14185 ac_file_inputs=
14186 for ac_f
14187 do
14188 case $ac_f in
14189 -) ac_f="$ac_tmp/stdin";;
14190 *) # Look for the file first in the build tree, then in the source tree
14191 # (if the path is not absolute). The absolute path cannot be DOS-style,
14192 # because $ac_f cannot contain `:'.
14193 test -f "$ac_f" ||
14194 case $ac_f in
14195 [\\/$]*) false;;
14196 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
14197 esac ||
14198 as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
14199 esac
14200 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
14201 as_fn_append ac_file_inputs " '$ac_f'"
14202 done
14203
14204 # Let's still pretend it is `configure' which instantiates (i.e., don't
14205 # use $as_me), people would be surprised to read:
14206 # /* config.h. Generated by config.status. */
14207 configure_input='Generated from '`
14208 $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
14209 `' by configure.'
14210 if test x"$ac_file" != x-; then
14211 configure_input="$ac_file. $configure_input"
14212 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
14213 $as_echo "$as_me: creating $ac_file" >&6;}
14214 fi
14215 # Neutralize special characters interpreted by sed in replacement strings.
14216 case $configure_input in #(
14217 *\&* | *\|* | *\\* )
14218 ac_sed_conf_input=`$as_echo "$configure_input" |
14219 sed 's/[\\\\&|]/\\\\&/g'`;; #(
14220 *) ac_sed_conf_input=$configure_input;;
14221 esac
14222
14223 case $ac_tag in
14224 *:-:* | *:-) cat >"$ac_tmp/stdin" \
14225 || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
14226 esac
14227 ;;
14228 esac
14229
14230 ac_dir=`$as_dirname -- "$ac_file" ||
14231 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
14232 X"$ac_file" : 'X\(//\)[^/]' \| \
14233 X"$ac_file" : 'X\(//\)$' \| \
14234 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
14235 $as_echo X"$ac_file" |
14236 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
14237 s//\1/
14238 q
14239 }
14240 /^X\(\/\/\)[^/].*/{
14241 s//\1/
14242 q
14243 }
14244 /^X\(\/\/\)$/{
14245 s//\1/
14246 q
14247 }
14248 /^X\(\/\).*/{
14249 s//\1/
14250 q
14251 }
14252 s/.*/./; q'`
14253 as_dir="$ac_dir"; as_fn_mkdir_p
14254 ac_builddir=.
14255
14256 case "$ac_dir" in
14257 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
14258 *)
14259 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
14260 # A ".." for each directory in $ac_dir_suffix.
14261 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
14262 case $ac_top_builddir_sub in
14263 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
14264 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
14265 esac ;;
14266 esac
14267 ac_abs_top_builddir=$ac_pwd
14268 ac_abs_builddir=$ac_pwd$ac_dir_suffix
14269 # for backward compatibility:
14270 ac_top_builddir=$ac_top_build_prefix
14271
14272 case $srcdir in
14273 .) # We are building in place.
14274 ac_srcdir=.
14275 ac_top_srcdir=$ac_top_builddir_sub
14276 ac_abs_top_srcdir=$ac_pwd ;;
14277 [\\/]* | ?:[\\/]* ) # Absolute name.
14278 ac_srcdir=$srcdir$ac_dir_suffix;
14279 ac_top_srcdir=$srcdir
14280 ac_abs_top_srcdir=$srcdir ;;
14281 *) # Relative name.
14282 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
14283 ac_top_srcdir=$ac_top_build_prefix$srcdir
14284 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
14285 esac
14286 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
14287
14288
14289 case $ac_mode in
14290 :F)
14291 #
14292 # CONFIG_FILE
14293 #
14294
14295 case $INSTALL in
14296 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
14297 *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
14298 esac
14299 _ACEOF
14300
14301 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
14302 # If the template does not know about datarootdir, expand it.
14303 # FIXME: This hack should be removed a few years after 2.60.
14304 ac_datarootdir_hack=; ac_datarootdir_seen=
14305 ac_sed_dataroot='
14306 /datarootdir/ {
14307 p
14308 q
14309 }
14310 /@datadir@/p
14311 /@docdir@/p
14312 /@infodir@/p
14313 /@localedir@/p
14314 /@mandir@/p'
14315 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
14316 *datarootdir*) ac_datarootdir_seen=yes;;
14317 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
14318 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
14319 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
14320 _ACEOF
14321 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
14322 ac_datarootdir_hack='
14323 s&@datadir@&$datadir&g
14324 s&@docdir@&$docdir&g
14325 s&@infodir@&$infodir&g
14326 s&@localedir@&$localedir&g
14327 s&@mandir@&$mandir&g
14328 s&\\\${datarootdir}&$datarootdir&g' ;;
14329 esac
14330 _ACEOF
14331
14332 # Neutralize VPATH when `$srcdir' = `.'.
14333 # Shell code in configure.ac might set extrasub.
14334 # FIXME: do we really want to maintain this feature?
14335 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
14336 ac_sed_extra="$ac_vpsub
14337 $extrasub
14338 _ACEOF
14339 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
14340 :t
14341 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
14342 s|@configure_input@|$ac_sed_conf_input|;t t
14343 s&@top_builddir@&$ac_top_builddir_sub&;t t
14344 s&@top_build_prefix@&$ac_top_build_prefix&;t t
14345 s&@srcdir@&$ac_srcdir&;t t
14346 s&@abs_srcdir@&$ac_abs_srcdir&;t t
14347 s&@top_srcdir@&$ac_top_srcdir&;t t
14348 s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
14349 s&@builddir@&$ac_builddir&;t t
14350 s&@abs_builddir@&$ac_abs_builddir&;t t
14351 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
14352 s&@INSTALL@&$ac_INSTALL&;t t
14353 $ac_datarootdir_hack
14354 "
14355 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
14356 >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
14357
14358 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
14359 { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
14360 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
14361 "$ac_tmp/out"`; test -z "$ac_out"; } &&
14362 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
14363 which seems to be undefined. Please make sure it is defined" >&5
14364 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
14365 which seems to be undefined. Please make sure it is defined" >&2;}
14366
14367 rm -f "$ac_tmp/stdin"
14368 case $ac_file in
14369 -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
14370 *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
14371 esac \
14372 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
14373 ;;
14374
14375
14376 :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
14377 $as_echo "$as_me: executing $ac_file commands" >&6;}
14378 ;;
14379 esac
14380
14381
14382 case $ac_file$ac_mode in
14383 "libtool":C)
14384
14385 # See if we are running on zsh, and set the options which allow our
14386 # commands through without removal of \ escapes.
14387 if test -n "${ZSH_VERSION+set}" ; then
14388 setopt NO_GLOB_SUBST
14389 fi
14390
14391 cfgfile="${ofile}T"
14392 trap "$RM \"$cfgfile\"; exit 1" 1 2 15
14393 $RM "$cfgfile"
14394
14395 cat <<_LT_EOF >> "$cfgfile"
14396 #! $SHELL
14397
14398 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
14399 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
14400 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
14401 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
14402 #
14403 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
14404 # 2006, 2007, 2008 Free Software Foundation, Inc.
14405 # Written by Gordon Matzigkeit, 1996
14406 #
14407 # This file is part of GNU Libtool.
14408 #
14409 # GNU Libtool is free software; you can redistribute it and/or
14410 # modify it under the terms of the GNU General Public License as
14411 # published by the Free Software Foundation; either version 2 of
14412 # the License, or (at your option) any later version.
14413 #
14414 # As a special exception to the GNU General Public License,
14415 # if you distribute this file as part of a program or library that
14416 # is built using GNU Libtool, you may include this file under the
14417 # same distribution terms that you use for the rest of that program.
14418 #
14419 # GNU Libtool is distributed in the hope that it will be useful,
14420 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14421 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14422 # GNU General Public License for more details.
14423 #
14424 # You should have received a copy of the GNU General Public License
14425 # along with GNU Libtool; see the file COPYING. If not, a copy
14426 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
14427 # obtained by writing to the Free Software Foundation, Inc.,
14428 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14429
14430
14431 # The names of the tagged configurations supported by this script.
14432 available_tags=""
14433
14434 # ### BEGIN LIBTOOL CONFIG
14435
14436 # Which release of libtool.m4 was used?
14437 macro_version=$macro_version
14438 macro_revision=$macro_revision
14439
14440 # Assembler program.
14441 AS=$AS
14442
14443 # DLL creation program.
14444 DLLTOOL=$DLLTOOL
14445
14446 # Object dumper program.
14447 OBJDUMP=$OBJDUMP
14448
14449 # Whether or not to build shared libraries.
14450 build_libtool_libs=$enable_shared
14451
14452 # Whether or not to build static libraries.
14453 build_old_libs=$enable_static
14454
14455 # What type of objects to build.
14456 pic_mode=$pic_mode
14457
14458 # Whether or not to optimize for fast installation.
14459 fast_install=$enable_fast_install
14460
14461 # The host system.
14462 host_alias=$host_alias
14463 host=$host
14464 host_os=$host_os
14465
14466 # The build system.
14467 build_alias=$build_alias
14468 build=$build
14469 build_os=$build_os
14470
14471 # A sed program that does not truncate output.
14472 SED=$lt_SED
14473
14474 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
14475 Xsed="\$SED -e 1s/^X//"
14476
14477 # A grep program that handles long lines.
14478 GREP=$lt_GREP
14479
14480 # An ERE matcher.
14481 EGREP=$lt_EGREP
14482
14483 # A literal string matcher.
14484 FGREP=$lt_FGREP
14485
14486 # A BSD- or MS-compatible name lister.
14487 NM=$lt_NM
14488
14489 # Whether we need soft or hard links.
14490 LN_S=$lt_LN_S
14491
14492 # What is the maximum length of a command?
14493 max_cmd_len=$max_cmd_len
14494
14495 # Object file suffix (normally "o").
14496 objext=$ac_objext
14497
14498 # Executable file suffix (normally "").
14499 exeext=$exeext
14500
14501 # whether the shell understands "unset".
14502 lt_unset=$lt_unset
14503
14504 # turn spaces into newlines.
14505 SP2NL=$lt_lt_SP2NL
14506
14507 # turn newlines into spaces.
14508 NL2SP=$lt_lt_NL2SP
14509
14510 # How to create reloadable object files.
14511 reload_flag=$lt_reload_flag
14512 reload_cmds=$lt_reload_cmds
14513
14514 # Method to check whether dependent libraries are shared objects.
14515 deplibs_check_method=$lt_deplibs_check_method
14516
14517 # Command to use when deplibs_check_method == "file_magic".
14518 file_magic_cmd=$lt_file_magic_cmd
14519
14520 # The archiver.
14521 AR=$lt_AR
14522 AR_FLAGS=$lt_AR_FLAGS
14523
14524 # A symbol stripping program.
14525 STRIP=$lt_STRIP
14526
14527 # Commands used to install an old-style archive.
14528 RANLIB=$lt_RANLIB
14529 old_postinstall_cmds=$lt_old_postinstall_cmds
14530 old_postuninstall_cmds=$lt_old_postuninstall_cmds
14531
14532 # A C compiler.
14533 LTCC=$lt_CC
14534
14535 # LTCC compiler flags.
14536 LTCFLAGS=$lt_CFLAGS
14537
14538 # Take the output of nm and produce a listing of raw symbols and C names.
14539 global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
14540
14541 # Transform the output of nm in a proper C declaration.
14542 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
14543
14544 # Transform the output of nm in a C name address pair.
14545 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
14546
14547 # Transform the output of nm in a C name address pair when lib prefix is needed.
14548 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
14549
14550 # The name of the directory that contains temporary libtool files.
14551 objdir=$objdir
14552
14553 # Shell to use when invoking shell scripts.
14554 SHELL=$lt_SHELL
14555
14556 # An echo program that does not interpret backslashes.
14557 ECHO=$lt_ECHO
14558
14559 # Used to examine libraries when file_magic_cmd begins with "file".
14560 MAGIC_CMD=$MAGIC_CMD
14561
14562 # Must we lock files when doing compilation?
14563 need_locks=$lt_need_locks
14564
14565 # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
14566 DSYMUTIL=$lt_DSYMUTIL
14567
14568 # Tool to change global to local symbols on Mac OS X.
14569 NMEDIT=$lt_NMEDIT
14570
14571 # Tool to manipulate fat objects and archives on Mac OS X.
14572 LIPO=$lt_LIPO
14573
14574 # ldd/readelf like tool for Mach-O binaries on Mac OS X.
14575 OTOOL=$lt_OTOOL
14576
14577 # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
14578 OTOOL64=$lt_OTOOL64
14579
14580 # Old archive suffix (normally "a").
14581 libext=$libext
14582
14583 # Shared library suffix (normally ".so").
14584 shrext_cmds=$lt_shrext_cmds
14585
14586 # The commands to extract the exported symbol list from a shared archive.
14587 extract_expsyms_cmds=$lt_extract_expsyms_cmds
14588
14589 # Variables whose values should be saved in libtool wrapper scripts and
14590 # restored at link time.
14591 variables_saved_for_relink=$lt_variables_saved_for_relink
14592
14593 # Do we need the "lib" prefix for modules?
14594 need_lib_prefix=$need_lib_prefix
14595
14596 # Do we need a version for libraries?
14597 need_version=$need_version
14598
14599 # Library versioning type.
14600 version_type=$version_type
14601
14602 # Shared library runtime path variable.
14603 runpath_var=$runpath_var
14604
14605 # Shared library path variable.
14606 shlibpath_var=$shlibpath_var
14607
14608 # Is shlibpath searched before the hard-coded library search path?
14609 shlibpath_overrides_runpath=$shlibpath_overrides_runpath
14610
14611 # Format of library name prefix.
14612 libname_spec=$lt_libname_spec
14613
14614 # List of archive names. First name is the real one, the rest are links.
14615 # The last name is the one that the linker finds with -lNAME
14616 library_names_spec=$lt_library_names_spec
14617
14618 # The coded name of the library, if different from the real name.
14619 soname_spec=$lt_soname_spec
14620
14621 # Command to use after installation of a shared archive.
14622 postinstall_cmds=$lt_postinstall_cmds
14623
14624 # Command to use after uninstallation of a shared archive.
14625 postuninstall_cmds=$lt_postuninstall_cmds
14626
14627 # Commands used to finish a libtool library installation in a directory.
14628 finish_cmds=$lt_finish_cmds
14629
14630 # As "finish_cmds", except a single script fragment to be evaled but
14631 # not shown.
14632 finish_eval=$lt_finish_eval
14633
14634 # Whether we should hardcode library paths into libraries.
14635 hardcode_into_libs=$hardcode_into_libs
14636
14637 # Compile-time system search path for libraries.
14638 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
14639
14640 # Run-time system search path for libraries.
14641 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
14642
14643 # Whether dlopen is supported.
14644 dlopen_support=$enable_dlopen
14645
14646 # Whether dlopen of programs is supported.
14647 dlopen_self=$enable_dlopen_self
14648
14649 # Whether dlopen of statically linked programs is supported.
14650 dlopen_self_static=$enable_dlopen_self_static
14651
14652 # Commands to strip libraries.
14653 old_striplib=$lt_old_striplib
14654 striplib=$lt_striplib
14655
14656
14657 # The linker used to build libraries.
14658 LD=$lt_LD
14659
14660 # Commands used to build an old-style archive.
14661 old_archive_cmds=$lt_old_archive_cmds
14662
14663 # A language specific compiler.
14664 CC=$lt_compiler
14665
14666 # Is the compiler the GNU compiler?
14667 with_gcc=$GCC
14668
14669 # Compiler flag to turn off builtin functions.
14670 no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
14671
14672 # How to pass a linker flag through the compiler.
14673 wl=$lt_lt_prog_compiler_wl
14674
14675 # Additional compiler flags for building library objects.
14676 pic_flag=$lt_lt_prog_compiler_pic
14677
14678 # Compiler flag to prevent dynamic linking.
14679 link_static_flag=$lt_lt_prog_compiler_static
14680
14681 # Does compiler simultaneously support -c and -o options?
14682 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
14683
14684 # Whether or not to add -lc for building shared libraries.
14685 build_libtool_need_lc=$archive_cmds_need_lc
14686
14687 # Whether or not to disallow shared libs when runtime libs are static.
14688 allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
14689
14690 # Compiler flag to allow reflexive dlopens.
14691 export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
14692
14693 # Compiler flag to generate shared objects directly from archives.
14694 whole_archive_flag_spec=$lt_whole_archive_flag_spec
14695
14696 # Whether the compiler copes with passing no objects directly.
14697 compiler_needs_object=$lt_compiler_needs_object
14698
14699 # Create an old-style archive from a shared archive.
14700 old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
14701
14702 # Create a temporary old-style archive to link instead of a shared archive.
14703 old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
14704
14705 # Commands used to build a shared archive.
14706 archive_cmds=$lt_archive_cmds
14707 archive_expsym_cmds=$lt_archive_expsym_cmds
14708
14709 # Commands used to build a loadable module if different from building
14710 # a shared archive.
14711 module_cmds=$lt_module_cmds
14712 module_expsym_cmds=$lt_module_expsym_cmds
14713
14714 # Whether we are building with GNU ld or not.
14715 with_gnu_ld=$lt_with_gnu_ld
14716
14717 # Flag that allows shared libraries with undefined symbols to be built.
14718 allow_undefined_flag=$lt_allow_undefined_flag
14719
14720 # Flag that enforces no undefined symbols.
14721 no_undefined_flag=$lt_no_undefined_flag
14722
14723 # Flag to hardcode \$libdir into a binary during linking.
14724 # This must work even if \$libdir does not exist
14725 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
14726
14727 # If ld is used when linking, flag to hardcode \$libdir into a binary
14728 # during linking. This must work even if \$libdir does not exist.
14729 hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
14730
14731 # Whether we need a single "-rpath" flag with a separated argument.
14732 hardcode_libdir_separator=$lt_hardcode_libdir_separator
14733
14734 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
14735 # DIR into the resulting binary.
14736 hardcode_direct=$hardcode_direct
14737
14738 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
14739 # DIR into the resulting binary and the resulting library dependency is
14740 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
14741 # library is relocated.
14742 hardcode_direct_absolute=$hardcode_direct_absolute
14743
14744 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
14745 # into the resulting binary.
14746 hardcode_minus_L=$hardcode_minus_L
14747
14748 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
14749 # into the resulting binary.
14750 hardcode_shlibpath_var=$hardcode_shlibpath_var
14751
14752 # Set to "yes" if building a shared library automatically hardcodes DIR
14753 # into the library and all subsequent libraries and executables linked
14754 # against it.
14755 hardcode_automatic=$hardcode_automatic
14756
14757 # Set to yes if linker adds runtime paths of dependent libraries
14758 # to runtime path list.
14759 inherit_rpath=$inherit_rpath
14760
14761 # Whether libtool must link a program against all its dependency libraries.
14762 link_all_deplibs=$link_all_deplibs
14763
14764 # Fix the shell variable \$srcfile for the compiler.
14765 fix_srcfile_path=$lt_fix_srcfile_path
14766
14767 # Set to "yes" if exported symbols are required.
14768 always_export_symbols=$always_export_symbols
14769
14770 # The commands to list exported symbols.
14771 export_symbols_cmds=$lt_export_symbols_cmds
14772
14773 # Symbols that should not be listed in the preloaded symbols.
14774 exclude_expsyms=$lt_exclude_expsyms
14775
14776 # Symbols that must always be exported.
14777 include_expsyms=$lt_include_expsyms
14778
14779 # Commands necessary for linking programs (against libraries) with templates.
14780 prelink_cmds=$lt_prelink_cmds
14781
14782 # Specify filename containing input files.
14783 file_list_spec=$lt_file_list_spec
14784
14785 # How to hardcode a shared library path into an executable.
14786 hardcode_action=$hardcode_action
14787
14788 # ### END LIBTOOL CONFIG
14789
14790 _LT_EOF
14791
14792 case $host_os in
14793 aix3*)
14794 cat <<\_LT_EOF >> "$cfgfile"
14795 # AIX sometimes has problems with the GCC collect2 program. For some
14796 # reason, if we set the COLLECT_NAMES environment variable, the problems
14797 # vanish in a puff of smoke.
14798 if test "X${COLLECT_NAMES+set}" != Xset; then
14799 COLLECT_NAMES=
14800 export COLLECT_NAMES
14801 fi
14802 _LT_EOF
14803 ;;
14804 esac
14805
14806
14807 ltmain="$ac_aux_dir/ltmain.sh"
14808
14809
14810 # We use sed instead of cat because bash on DJGPP gets confused if
14811 # if finds mixed CR/LF and LF-only lines. Since sed operates in
14812 # text mode, it properly converts lines to CR/LF. This bash problem
14813 # is reportedly fixed, but why not run on old versions too?
14814 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
14815 || (rm -f "$cfgfile"; exit 1)
14816
14817 case $xsi_shell in
14818 yes)
14819 cat << \_LT_EOF >> "$cfgfile"
14820
14821 # func_dirname file append nondir_replacement
14822 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
14823 # otherwise set result to NONDIR_REPLACEMENT.
14824 func_dirname ()
14825 {
14826 case ${1} in
14827 */*) func_dirname_result="${1%/*}${2}" ;;
14828 * ) func_dirname_result="${3}" ;;
14829 esac
14830 }
14831
14832 # func_basename file
14833 func_basename ()
14834 {
14835 func_basename_result="${1##*/}"
14836 }
14837
14838 # func_dirname_and_basename file append nondir_replacement
14839 # perform func_basename and func_dirname in a single function
14840 # call:
14841 # dirname: Compute the dirname of FILE. If nonempty,
14842 # add APPEND to the result, otherwise set result
14843 # to NONDIR_REPLACEMENT.
14844 # value returned in "$func_dirname_result"
14845 # basename: Compute filename of FILE.
14846 # value retuned in "$func_basename_result"
14847 # Implementation must be kept synchronized with func_dirname
14848 # and func_basename. For efficiency, we do not delegate to
14849 # those functions but instead duplicate the functionality here.
14850 func_dirname_and_basename ()
14851 {
14852 case ${1} in
14853 */*) func_dirname_result="${1%/*}${2}" ;;
14854 * ) func_dirname_result="${3}" ;;
14855 esac
14856 func_basename_result="${1##*/}"
14857 }
14858
14859 # func_stripname prefix suffix name
14860 # strip PREFIX and SUFFIX off of NAME.
14861 # PREFIX and SUFFIX must not contain globbing or regex special
14862 # characters, hashes, percent signs, but SUFFIX may contain a leading
14863 # dot (in which case that matches only a dot).
14864 func_stripname ()
14865 {
14866 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
14867 # positional parameters, so assign one to ordinary parameter first.
14868 func_stripname_result=${3}
14869 func_stripname_result=${func_stripname_result#"${1}"}
14870 func_stripname_result=${func_stripname_result%"${2}"}
14871 }
14872
14873 # func_opt_split
14874 func_opt_split ()
14875 {
14876 func_opt_split_opt=${1%%=*}
14877 func_opt_split_arg=${1#*=}
14878 }
14879
14880 # func_lo2o object
14881 func_lo2o ()
14882 {
14883 case ${1} in
14884 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
14885 *) func_lo2o_result=${1} ;;
14886 esac
14887 }
14888
14889 # func_xform libobj-or-source
14890 func_xform ()
14891 {
14892 func_xform_result=${1%.*}.lo
14893 }
14894
14895 # func_arith arithmetic-term...
14896 func_arith ()
14897 {
14898 func_arith_result=$(( $* ))
14899 }
14900
14901 # func_len string
14902 # STRING may not start with a hyphen.
14903 func_len ()
14904 {
14905 func_len_result=${#1}
14906 }
14907
14908 _LT_EOF
14909 ;;
14910 *) # Bourne compatible functions.
14911 cat << \_LT_EOF >> "$cfgfile"
14912
14913 # func_dirname file append nondir_replacement
14914 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
14915 # otherwise set result to NONDIR_REPLACEMENT.
14916 func_dirname ()
14917 {
14918 # Extract subdirectory from the argument.
14919 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
14920 if test "X$func_dirname_result" = "X${1}"; then
14921 func_dirname_result="${3}"
14922 else
14923 func_dirname_result="$func_dirname_result${2}"
14924 fi
14925 }
14926
14927 # func_basename file
14928 func_basename ()
14929 {
14930 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
14931 }
14932
14933
14934 # func_stripname prefix suffix name
14935 # strip PREFIX and SUFFIX off of NAME.
14936 # PREFIX and SUFFIX must not contain globbing or regex special
14937 # characters, hashes, percent signs, but SUFFIX may contain a leading
14938 # dot (in which case that matches only a dot).
14939 # func_strip_suffix prefix name
14940 func_stripname ()
14941 {
14942 case ${2} in
14943 .*) func_stripname_result=`$ECHO "X${3}" \
14944 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
14945 *) func_stripname_result=`$ECHO "X${3}" \
14946 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
14947 esac
14948 }
14949
14950 # sed scripts:
14951 my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
14952 my_sed_long_arg='1s/^-[^=]*=//'
14953
14954 # func_opt_split
14955 func_opt_split ()
14956 {
14957 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
14958 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
14959 }
14960
14961 # func_lo2o object
14962 func_lo2o ()
14963 {
14964 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
14965 }
14966
14967 # func_xform libobj-or-source
14968 func_xform ()
14969 {
14970 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
14971 }
14972
14973 # func_arith arithmetic-term...
14974 func_arith ()
14975 {
14976 func_arith_result=`expr "$@"`
14977 }
14978
14979 # func_len string
14980 # STRING may not start with a hyphen.
14981 func_len ()
14982 {
14983 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
14984 }
14985
14986 _LT_EOF
14987 esac
14988
14989 case $lt_shell_append in
14990 yes)
14991 cat << \_LT_EOF >> "$cfgfile"
14992
14993 # func_append var value
14994 # Append VALUE to the end of shell variable VAR.
14995 func_append ()
14996 {
14997 eval "$1+=\$2"
14998 }
14999 _LT_EOF
15000 ;;
15001 *)
15002 cat << \_LT_EOF >> "$cfgfile"
15003
15004 # func_append var value
15005 # Append VALUE to the end of shell variable VAR.
15006 func_append ()
15007 {
15008 eval "$1=\$$1\$2"
15009 }
15010
15011 _LT_EOF
15012 ;;
15013 esac
15014
15015
15016 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
15017 || (rm -f "$cfgfile"; exit 1)
15018
15019 mv -f "$cfgfile" "$ofile" ||
15020 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
15021 chmod +x "$ofile"
15022
15023 ;;
15024
15025 esac
15026 done # for ac_tag
15027
15028
15029 as_fn_exit 0
15030 _ACEOF
15031 ac_clean_files=$ac_clean_files_save
15032
15033 test $ac_write_fail = 0 ||
15034 as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
15035
15036
15037 # configure is writing to config.log, and then calls config.status.
15038 # config.status does its own redirection, appending to config.log.
15039 # Unfortunately, on DOS this fails, as config.log is still kept open
15040 # by configure, so config.status won't be able to write to it; its
15041 # output is simply discarded. So we exec the FD to /dev/null,
15042 # effectively closing config.log, so it can be properly (re)opened and
15043 # appended to by config.status. When coming back to configure, we
15044 # need to make the FD available again.
15045 if test "$no_create" != yes; then
15046 ac_cs_success=:
15047 ac_config_status_args=
15048 test "$silent" = yes &&
15049 ac_config_status_args="$ac_config_status_args --quiet"
15050 exec 5>/dev/null
15051 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
15052 exec 5>>config.log
15053 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
15054 # would make configure fail if this is the last instruction.
15055 $ac_cs_success || as_fn_exit 1
15056 fi
15057 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
15058 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
15059 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
15060 fi
15061
15062 ac_config_files="$ac_config_files Makefile SDL2_mixer.spec SDL2_mixer.pc"
15063
15064 ac_config_commands="$ac_config_commands default"
15065
15066 cat >confcache <<\_ACEOF
15067 # This file is a shell script that caches the results of configure
15068 # tests run on this system so they can be shared between configure
15069 # scripts and configure runs, see configure's option --config-cache.
15070 # It is not useful on other systems. If it contains results you don't
15071 # want to keep, you may remove or edit it.
15072 #
15073 # config.status only pays attention to the cache file if you give it
15074 # the --recheck option to rerun configure.
15075 #
15076 # `ac_cv_env_foo' variables (set or unset) will be overridden when
15077 # loading this file, other *unset* `ac_cv_foo' will be assigned the
15078 # following values.
15079
15080 _ACEOF
15081
15082 # The following way of writing the cache mishandles newlines in values,
15083 # but we know of no workaround that is simple, portable, and efficient.
15084 # So, we kill variables containing newlines.
15085 # Ultrix sh set writes to stderr and can't be redirected directly,
15086 # and sets the high bit in the cache file unless we assign to the vars.
15087 (
15088 for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
15089 eval ac_val=\$$ac_var
15090 case $ac_val in #(
15091 *${as_nl}*)
15092 case $ac_var in #(
15093 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
15094 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
15095 esac
15096 case $ac_var in #(
15097 _ | IFS | as_nl) ;; #(
15098 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
15099 *) { eval $ac_var=; unset $ac_var;} ;;
15100 esac ;;
15101 esac
15102 done
15103
15104 (set) 2>&1 |
15105 case $as_nl`(ac_space=' '; set) 2>&1` in #(
15106 *${as_nl}ac_space=\ *)
15107 # `set' does not quote correctly, so add quotes: double-quote
15108 # substitution turns \\\\ into \\, and sed turns \\ into \.
15109 sed -n \
15110 "s/'/'\\\\''/g;
15111 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
15112 ;; #(
15113 *)
15114 # `set' quotes correctly as required by POSIX, so do not add quotes.
15115 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
15116 ;;
15117 esac |
15118 sort
15119 ) |
15120 sed '
15121 /^ac_cv_env_/b end
15122 t clear
15123 :clear
15124 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
15125 t end
15126 s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
15127 :end' >>confcache
15128 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
15129 if test -w "$cache_file"; then
15130 if test "x$cache_file" != "x/dev/null"; then
15131 { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
15132 $as_echo "$as_me: updating cache $cache_file" >&6;}
15133 if test ! -f "$cache_file" || test -h "$cache_file"; then
15134 cat confcache >"$cache_file"
15135 else
15136 case $cache_file in #(
15137 */* | ?:*)
15138 mv -f confcache "$cache_file"$$ &&
15139 mv -f "$cache_file"$$ "$cache_file" ;; #(
15140 *)
15141 mv -f confcache "$cache_file" ;;
15142 esac
15143 fi
15144 fi
15145 else
15146 { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
15147 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
15148 fi
15149 fi
15150 rm -f confcache
15151
15152 test "x$prefix" = xNONE && prefix=$ac_default_prefix
15153 # Let make expand exec_prefix.
15154 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
15155
15156 # Transform confdefs.h into DEFS.
15157 # Protect against shell expansion while executing Makefile rules.
15158 # Protect against Makefile macro expansion.
15159 #
15160 # If the first sed substitution is executed (which looks for macros that
15161 # take arguments), then branch to the quote section. Otherwise,
15162 # look for a macro that doesn't take arguments.
15163 ac_script='
15164 :mline
15165 /\\$/{
15166 N
15167 s,\\\n,,
15168 b mline
15169 }
15170 t clear
15171 :clear
15172 s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
15173 t quote
15174 s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
15175 t quote
15176 b any
15177 :quote
15178 s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
15179 s/\[/\\&/g
15180 s/\]/\\&/g
15181 s/\$/$$/g
15182 H
15183 :any
15184 ${
15185 g
15186 s/^\n//
15187 s/\n/ /g
15188 p
15189 }
15190 '
15191 DEFS=`sed -n "$ac_script" confdefs.h`
15192
15193
15194 ac_libobjs=
15195 ac_ltlibobjs=
15196 U=
15197 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
15198 # 1. Remove the extension, and $U if already installed.
15199 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
15200 ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
15201 # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
15202 # will be set to the directory where LIBOBJS objects are built.
15203 as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
15204 as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
15205 done
15206 LIBOBJS=$ac_libobjs
15207
15208 LTLIBOBJS=$ac_ltlibobjs
15209
15210
15211
15212 : "${CONFIG_STATUS=./config.status}"
15213 ac_write_fail=0
15214 ac_clean_files_save=$ac_clean_files
15215 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
15216 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
15217 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
15218 as_write_fail=0
15219 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
15220 #! $SHELL
15221 # Generated by $as_me.
15222 # Run this file to recreate the current configuration.
15223 # Compiler output produced by configure, useful for debugging
15224 # configure, is in config.log if it exists.
15225
15226 debug=false
15227 ac_cs_recheck=false
15228 ac_cs_silent=false
15229
15230 SHELL=\${CONFIG_SHELL-$SHELL}
15231 export SHELL
15232 _ASEOF
15233 cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
15234 ## -------------------- ##
15235 ## M4sh Initialization. ##
15236 ## -------------------- ##
15237
15238 # Be more Bourne compatible
15239 DUALCASE=1; export DUALCASE # for MKS sh
15240 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
15241 emulate sh
15242 NULLCMD=:
15243 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
15244 # is contrary to our usage. Disable this feature.
15245 alias -g '${1+"$@"}'='"$@"'
15246 setopt NO_GLOB_SUBST
15247 else
15248 case `(set -o) 2>/dev/null` in #(
15249 *posix*) :
15250 set -o posix ;; #(
15251 *) :
15252 ;;
15253 esac
15254 fi
15255
15256
15257 as_nl='
15258 '
15259 export as_nl
15260 # Printing a long string crashes Solaris 7 /usr/bin/printf.
15261 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
15262 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
15263 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
15264 # Prefer a ksh shell builtin over an external printf program on Solaris,
15265 # but without wasting forks for bash or zsh.
15266 if test -z "$BASH_VERSION$ZSH_VERSION" \
15267 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
15268 as_echo='print -r --'
15269 as_echo_n='print -rn --'
15270 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
15271 as_echo='printf %s\n'
15272 as_echo_n='printf %s'
15273 else
15274 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
15275 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
15276 as_echo_n='/usr/ucb/echo -n'
15277 else
15278 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
15279 as_echo_n_body='eval
15280 arg=$1;
15281 case $arg in #(
15282 *"$as_nl"*)
15283 expr "X$arg" : "X\\(.*\\)$as_nl";
15284 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
15285 esac;
15286 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
15287 '
15288 export as_echo_n_body
15289 as_echo_n='sh -c $as_echo_n_body as_echo'
15290 fi
15291 export as_echo_body
15292 as_echo='sh -c $as_echo_body as_echo'
15293 fi
15294
15295 # The user is always right.
15296 if test "${PATH_SEPARATOR+set}" != set; then
15297 PATH_SEPARATOR=:
15298 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
15299 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
15300 PATH_SEPARATOR=';'
15301 }
15302 fi
15303
15304
15305 # IFS
15306 # We need space, tab and new line, in precisely that order. Quoting is
15307 # there to prevent editors from complaining about space-tab.
15308 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
15309 # splitting by setting IFS to empty value.)
15310 IFS=" "" $as_nl"
15311
15312 # Find who we are. Look in the path if we contain no directory separator.
15313 as_myself=
15314 case $0 in #((
15315 *[\\/]* ) as_myself=$0 ;;
15316 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
15317 for as_dir in $PATH
15318 do
15319 IFS=$as_save_IFS
15320 test -z "$as_dir" && as_dir=.
15321 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
15322 done
15323 IFS=$as_save_IFS
15324
15325 ;;
15326 esac
15327 # We did not find ourselves, most probably we were run as `sh COMMAND'
15328 # in which case we are not to be found in the path.
15329 if test "x$as_myself" = x; then
15330 as_myself=$0
15331 fi
15332 if test ! -f "$as_myself"; then
15333 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
15334 exit 1
15335 fi
15336
15337 # Unset variables that we do not need and which cause bugs (e.g. in
15338 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
15339 # suppresses any "Segmentation fault" message there. '((' could
15340 # trigger a bug in pdksh 5.2.14.
15341 for as_var in BASH_ENV ENV MAIL MAILPATH
15342 do eval test x\${$as_var+set} = xset \
15343 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
15344 done
15345 PS1='$ '
15346 PS2='> '
15347 PS4='+ '
15348
15349 # NLS nuisances.
15350 LC_ALL=C
15351 export LC_ALL
15352 LANGUAGE=C
15353 export LANGUAGE
15354
15355 # CDPATH.
15356 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
15357
15358
15359 # as_fn_error STATUS ERROR [LINENO LOG_FD]
15360 # ----------------------------------------
15361 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
15362 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
15363 # script with STATUS, using 1 if that was 0.
15364 as_fn_error ()
15365 {
15366 as_status=$1; test $as_status -eq 0 && as_status=1
15367 if test "$4"; then
15368 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
15369 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
15370 fi
15371 $as_echo "$as_me: error: $2" >&2
15372 as_fn_exit $as_status
15373 } # as_fn_error
15374
15375
15376 # as_fn_set_status STATUS
15377 # -----------------------
15378 # Set $? to STATUS, without forking.
15379 as_fn_set_status ()
15380 {
15381 return $1
15382 } # as_fn_set_status
15383
15384 # as_fn_exit STATUS
15385 # -----------------
15386 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
15387 as_fn_exit ()
15388 {
15389 set +e
15390 as_fn_set_status $1
15391 exit $1
15392 } # as_fn_exit
15393
15394 # as_fn_unset VAR
15395 # ---------------
15396 # Portably unset VAR.
15397 as_fn_unset ()
15398 {
15399 { eval $1=; unset $1;}
15400 }
15401 as_unset=as_fn_unset
15402 # as_fn_append VAR VALUE
15403 # ----------------------
15404 # Append the text in VALUE to the end of the definition contained in VAR. Take
15405 # advantage of any shell optimizations that allow amortized linear growth over
15406 # repeated appends, instead of the typical quadratic growth present in naive
15407 # implementations.
15408 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
15409 eval 'as_fn_append ()
15410 {
15411 eval $1+=\$2
15412 }'
15413 else
15414 as_fn_append ()
15415 {
15416 eval $1=\$$1\$2
15417 }
15418 fi # as_fn_append
15419
15420 # as_fn_arith ARG...
15421 # ------------------
15422 # Perform arithmetic evaluation on the ARGs, and store the result in the
15423 # global $as_val. Take advantage of shells that can avoid forks. The arguments
15424 # must be portable across $(()) and expr.
15425 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
15426 eval 'as_fn_arith ()
15427 {
15428 as_val=$(( $* ))
15429 }'
15430 else
15431 as_fn_arith ()
15432 {
15433 as_val=`expr "$@" || test $? -eq 1`
15434 }
15435 fi # as_fn_arith
15436
15437
15438 if expr a : '\(a\)' >/dev/null 2>&1 &&
15439 test "X`expr 00001 : '.*\(...\)'`" = X001; then
15440 as_expr=expr
15441 else
15442 as_expr=false
15443 fi
15444
15445 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
15446 as_basename=basename
15447 else
15448 as_basename=false
15449 fi
15450
15451 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
15452 as_dirname=dirname
15453 else
15454 as_dirname=false
15455 fi
15456
15457 as_me=`$as_basename -- "$0" ||
15458 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
15459 X"$0" : 'X\(//\)$' \| \
15460 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
15461 $as_echo X/"$0" |
15462 sed '/^.*\/\([^/][^/]*\)\/*$/{
15463 s//\1/
15464 q
15465 }
15466 /^X\/\(\/\/\)$/{
15467 s//\1/
15468 q
15469 }
15470 /^X\/\(\/\).*/{
15471 s//\1/
15472 q
15473 }
15474 s/.*/./; q'`
15475
15476 # Avoid depending upon Character Ranges.
15477 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
15478 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
15479 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
15480 as_cr_digits='0123456789'
15481 as_cr_alnum=$as_cr_Letters$as_cr_digits
15482
15483 ECHO_C= ECHO_N= ECHO_T=
15484 case `echo -n x` in #(((((
15485 -n*)
15486 case `echo 'xy\c'` in
15487 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
15488 xy) ECHO_C='\c';;
15489 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
15490 ECHO_T=' ';;
15491 esac;;
15492 *)
15493 ECHO_N='-n';;
15494 esac
15495
15496 rm -f conf$$ conf$$.exe conf$$.file
15497 if test -d conf$$.dir; then
15498 rm -f conf$$.dir/conf$$.file
15499 else
15500 rm -f conf$$.dir
15501 mkdir conf$$.dir 2>/dev/null
15502 fi
15503 if (echo >conf$$.file) 2>/dev/null; then
15504 if ln -s conf$$.file conf$$ 2>/dev/null; then
15505 as_ln_s='ln -s'
15506 # ... but there are two gotchas:
15507 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
15508 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
15509 # In both cases, we have to default to `cp -pR'.
15510 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
15511 as_ln_s='cp -pR'
15512 elif ln conf$$.file conf$$ 2>/dev/null; then
15513 as_ln_s=ln
15514 else
15515 as_ln_s='cp -pR'
15516 fi
15517 else
15518 as_ln_s='cp -pR'
15519 fi
15520 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
15521 rmdir conf$$.dir 2>/dev/null
15522
15523
15524 # as_fn_mkdir_p
15525 # -------------
15526 # Create "$as_dir" as a directory, including parents if necessary.
15527 as_fn_mkdir_p ()
15528 {
15529
15530 case $as_dir in #(
15531 -*) as_dir=./$as_dir;;
15532 esac
15533 test -d "$as_dir" || eval $as_mkdir_p || {
15534 as_dirs=
15535 while :; do
15536 case $as_dir in #(
15537 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
15538 *) as_qdir=$as_dir;;
15539 esac
15540 as_dirs="'$as_qdir' $as_dirs"
15541 as_dir=`$as_dirname -- "$as_dir" ||
15542 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
15543 X"$as_dir" : 'X\(//\)[^/]' \| \
15544 X"$as_dir" : 'X\(//\)$' \| \
15545 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
15546 $as_echo X"$as_dir" |
15547 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
15548 s//\1/
15549 q
15550 }
15551 /^X\(\/\/\)[^/].*/{
15552 s//\1/
15553 q
15554 }
15555 /^X\(\/\/\)$/{
15556 s//\1/
15557 q
15558 }
15559 /^X\(\/\).*/{
15560 s//\1/
15561 q
15562 }
15563 s/.*/./; q'`
15564 test -d "$as_dir" && break
15565 done
15566 test -z "$as_dirs" || eval "mkdir $as_dirs"
15567 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
15568
15569
15570 } # as_fn_mkdir_p
15571 if mkdir -p . 2>/dev/null; then
15572 as_mkdir_p='mkdir -p "$as_dir"'
15573 else
15574 test -d ./-p && rmdir ./-p
15575 as_mkdir_p=false
15576 fi
15577
15578
15579 # as_fn_executable_p FILE
15580 # -----------------------
15581 # Test if FILE is an executable regular file.
15582 as_fn_executable_p ()
15583 {
15584 test -f "$1" && test -x "$1"
15585 } # as_fn_executable_p
15586 as_test_x='test -x'
15587 as_executable_p=as_fn_executable_p
15588
15589 # Sed expression to map a string onto a valid CPP name.
15590 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
15591
15592 # Sed expression to map a string onto a valid variable name.
15593 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
15594
15595
15596 exec 6>&1
15597 ## ----------------------------------- ##
15598 ## Main body of $CONFIG_STATUS script. ##
15599 ## ----------------------------------- ##
15600 _ASEOF
15601 test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
15602
15603 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15604 # Save the log message, to keep $0 and so on meaningful, and to
15605 # report actual input values of CONFIG_FILES etc. instead of their
15606 # values after options handling.
15607 ac_log="
15608 This file was extended by $as_me, which was
15609 generated by GNU Autoconf 2.69. Invocation command line was
15610
15611 CONFIG_FILES = $CONFIG_FILES
15612 CONFIG_HEADERS = $CONFIG_HEADERS
15613 CONFIG_LINKS = $CONFIG_LINKS
15614 CONFIG_COMMANDS = $CONFIG_COMMANDS
15615 $ $0 $@
15616
15617 on `(hostname || uname -n) 2>/dev/null | sed 1q`
15618 "
15619
15620 _ACEOF
15621
15622 case $ac_config_files in *"
15623 "*) set x $ac_config_files; shift; ac_config_files=$*;;
15624 esac
15625
15626
15627
15628 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15629 # Files that config.status was made for.
15630 config_files="$ac_config_files"
15631 config_commands="$ac_config_commands"
15632
15633 _ACEOF
15634
15635 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15636 ac_cs_usage="\
15637 \`$as_me' instantiates files and other configuration actions
15638 from templates according to the current configuration. Unless the files
15639 and actions are specified as TAGs, all are instantiated by default.
15640
15641 Usage: $0 [OPTION]... [TAG]...
15642
15643 -h, --help print this help, then exit
15644 -V, --version print version number and configuration settings, then exit
15645 --config print configuration, then exit
15646 -q, --quiet, --silent
15647 do not print progress messages
15648 -d, --debug don't remove temporary files
15649 --recheck update $as_me by reconfiguring in the same conditions
15650 --file=FILE[:TEMPLATE]
15651 instantiate the configuration file FILE
15652
15653 Configuration files:
15654 $config_files
15655
15656 Configuration commands:
15657 $config_commands
15658
15659 Report bugs to the package provider."
15660
15661 _ACEOF
15662 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15663 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
15664 ac_cs_version="\\
15665 config.status
15666 configured by $0, generated by GNU Autoconf 2.69,
15667 with options \\"\$ac_cs_config\\"
15668
15669 Copyright (C) 2012 Free Software Foundation, Inc.
15670 This config.status script is free software; the Free Software Foundation
15671 gives unlimited permission to copy, distribute and modify it."
15672
15673 ac_pwd='$ac_pwd'
15674 srcdir='$srcdir'
15675 INSTALL='$INSTALL'
15676 test -n "\$AWK" || AWK=awk
15677 _ACEOF
15678
15679 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15680 # The default lists apply if the user does not specify any file.
15681 ac_need_defaults=:
15682 while test $# != 0
15683 do
15684 case $1 in
15685 --*=?*)
15686 ac_option=`expr "X$1" : 'X\([^=]*\)='`
15687 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
15688 ac_shift=:
15689 ;;
15690 --*=)
15691 ac_option=`expr "X$1" : 'X\([^=]*\)='`
15692 ac_optarg=
15693 ac_shift=:
15694 ;;
15695 *)
15696 ac_option=$1
15697 ac_optarg=$2
15698 ac_shift=shift
15699 ;;
15700 esac
15701
15702 case $ac_option in
15703 # Handling of the options.
15704 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
15705 ac_cs_recheck=: ;;
15706 --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
15707 $as_echo "$ac_cs_version"; exit ;;
15708 --config | --confi | --conf | --con | --co | --c )
15709 $as_echo "$ac_cs_config"; exit ;;
15710 --debug | --debu | --deb | --de | --d | -d )
15711 debug=: ;;
15712 --file | --fil | --fi | --f )
15713 $ac_shift
15714 case $ac_optarg in
15715 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
15716 '') as_fn_error $? "missing file argument" ;;
15717 esac
15718 as_fn_append CONFIG_FILES " '$ac_optarg'"
15719 ac_need_defaults=false;;
15720 --he | --h | --help | --hel | -h )
15721 $as_echo "$ac_cs_usage"; exit ;;
15722 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
15723 | -silent | --silent | --silen | --sile | --sil | --si | --s)
15724 ac_cs_silent=: ;;
15725
15726 # This is an error.
15727 -*) as_fn_error $? "unrecognized option: \`$1'
15728 Try \`$0 --help' for more information." ;;
15729
15730 *) as_fn_append ac_config_targets " $1"
15731 ac_need_defaults=false ;;
15732
15733 esac
15734 shift
15735 done
15736
15737 ac_configure_extra_args=
15738
15739 if $ac_cs_silent; then
15740 exec 6>/dev/null
15741 ac_configure_extra_args="$ac_configure_extra_args --silent"
15742 fi
15743
15744 _ACEOF
15745 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15746 if \$ac_cs_recheck; then
15747 set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
15748 shift
15749 \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
15750 CONFIG_SHELL='$SHELL'
15751 export CONFIG_SHELL
15752 exec "\$@"
15753 fi
15754
15755 _ACEOF
15756 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
15757 exec 5>>config.log
15758 {
15759 echo
15760 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
15761 ## Running $as_me. ##
15762 _ASBOX
15763 $as_echo "$ac_log"
15764 } >&5
15765
15766 _ACEOF
15767 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
15768 #
15769 # INIT-COMMANDS
15770 #
15771
15772
15773 # The HP-UX ksh and POSIX shell print the target directory to stdout
15774 # if CDPATH is set.
15775 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
15776
15777 sed_quote_subst='$sed_quote_subst'
15778 double_quote_subst='$double_quote_subst'
15779 delay_variable_subst='$delay_variable_subst'
15780 macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
15781 macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
15782 AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`'
15783 DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`'
15784 OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
15785 enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
15786 enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
15787 pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
15788 enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
15789 host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
15790 host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
15791 host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
15792 build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
15793 build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
15794 build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
15795 SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
15796 Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
15797 GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
15798 EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
15799 FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
15800 LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
15801 NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
15802 LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
15803 max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
15804 ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
15805 exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
15806 lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
15807 lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
15808 lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
15809 reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
15810 reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15811 deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
15812 file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
15813 AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
15814 AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
15815 STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
15816 RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
15817 old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15818 old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15819 old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15820 CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
15821 CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
15822 compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
15823 GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
15824 lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
15825 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
15826 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"`'
15827 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"`'
15828 objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
15829 SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
15830 ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
15831 MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
15832 lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
15833 lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
15834 lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
15835 lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
15836 lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
15837 need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
15838 DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
15839 NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
15840 LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
15841 OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
15842 OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
15843 libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
15844 shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15845 extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15846 archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
15847 enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
15848 export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
15849 whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
15850 compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
15851 old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15852 old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15853 archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15854 archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15855 module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15856 module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15857 with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
15858 allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
15859 no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
15860 hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
15861 hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
15862 hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
15863 hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
15864 hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
15865 hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
15866 hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
15867 hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
15868 inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
15869 link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
15870 fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
15871 always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
15872 export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15873 exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
15874 include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
15875 prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15876 file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
15877 variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
15878 need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
15879 need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
15880 version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
15881 runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
15882 shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
15883 shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
15884 libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
15885 library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
15886 soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
15887 postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15888 postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15889 finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
15890 finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
15891 hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
15892 sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
15893 sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
15894 hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
15895 enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
15896 enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
15897 enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
15898 old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
15899 striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
15900
15901 LTCC='$LTCC'
15902 LTCFLAGS='$LTCFLAGS'
15903 compiler='$compiler_DEFAULT'
15904
15905 # Quote evaled strings.
15906 for var in SED \
15907 GREP \
15908 EGREP \
15909 FGREP \
15910 LD \
15911 NM \
15912 LN_S \
15913 lt_SP2NL \
15914 lt_NL2SP \
15915 reload_flag \
15916 deplibs_check_method \
15917 file_magic_cmd \
15918 AR \
15919 AR_FLAGS \
15920 STRIP \
15921 RANLIB \
15922 CC \
15923 CFLAGS \
15924 compiler \
15925 lt_cv_sys_global_symbol_pipe \
15926 lt_cv_sys_global_symbol_to_cdecl \
15927 lt_cv_sys_global_symbol_to_c_name_address \
15928 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
15929 SHELL \
15930 ECHO \
15931 lt_prog_compiler_no_builtin_flag \
15932 lt_prog_compiler_wl \
15933 lt_prog_compiler_pic \
15934 lt_prog_compiler_static \
15935 lt_cv_prog_compiler_c_o \
15936 need_locks \
15937 DSYMUTIL \
15938 NMEDIT \
15939 LIPO \
15940 OTOOL \
15941 OTOOL64 \
15942 shrext_cmds \
15943 export_dynamic_flag_spec \
15944 whole_archive_flag_spec \
15945 compiler_needs_object \
15946 with_gnu_ld \
15947 allow_undefined_flag \
15948 no_undefined_flag \
15949 hardcode_libdir_flag_spec \
15950 hardcode_libdir_flag_spec_ld \
15951 hardcode_libdir_separator \
15952 fix_srcfile_path \
15953 exclude_expsyms \
15954 include_expsyms \
15955 file_list_spec \
15956 variables_saved_for_relink \
15957 libname_spec \
15958 library_names_spec \
15959 soname_spec \
15960 finish_eval \
15961 old_striplib \
15962 striplib; do
15963 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
15964 *[\\\\\\\`\\"\\\$]*)
15965 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
15966 ;;
15967 *)
15968 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
15969 ;;
15970 esac
15971 done
15972
15973 # Double-quote double-evaled strings.
15974 for var in reload_cmds \
15975 old_postinstall_cmds \
15976 old_postuninstall_cmds \
15977 old_archive_cmds \
15978 extract_expsyms_cmds \
15979 old_archive_from_new_cmds \
15980 old_archive_from_expsyms_cmds \
15981 archive_cmds \
15982 archive_expsym_cmds \
15983 module_cmds \
15984 module_expsym_cmds \
15985 export_symbols_cmds \
15986 prelink_cmds \
15987 postinstall_cmds \
15988 postuninstall_cmds \
15989 finish_cmds \
15990 sys_lib_search_path_spec \
15991 sys_lib_dlsearch_path_spec; do
15992 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
15993 *[\\\\\\\`\\"\\\$]*)
15994 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
15995 ;;
15996 *)
15997 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
15998 ;;
15999 esac
16000 done
16001
16002 # Fix-up fallback echo if it was mangled by the above quoting rules.
16003 case \$lt_ECHO in
16004 *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
16005 ;;
16006 esac
16007
16008 ac_aux_dir='$ac_aux_dir'
16009 xsi_shell='$xsi_shell'
16010 lt_shell_append='$lt_shell_append'
16011
16012 # See if we are running on zsh, and set the options which allow our
16013 # commands through without removal of \ escapes INIT.
16014 if test -n "\${ZSH_VERSION+set}" ; then
16015 setopt NO_GLOB_SUBST
16016 fi
16017
16018
16019 PACKAGE='$PACKAGE'
16020 VERSION='$VERSION'
16021 TIMESTAMP='$TIMESTAMP'
16022 RM='$RM'
16023 ofile='$ofile'
16024
16025 ac_aux_dir='$ac_aux_dir'
16026
16027
16028
16029 DEPENDS="$DEPENDS"
16030 VERSION_DEPENDS="$VERSION_DEPENDS"
16031 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
16032 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
16033
16034
16035 _ACEOF
16036
16037 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
16038
16039 # Handling of arguments.
16040 for ac_config_target in $ac_config_targets
16041 do
16042 case $ac_config_target in
16043 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
16044 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
16045 "SDL2_mixer.spec") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.spec" ;;
16046 "SDL2_mixer.pc") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.pc" ;;
16047 "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
16048
16049 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
16050 esac
16051 done
16052
16053
16054 # If the user did not use the arguments to specify the items to instantiate,
16055 # then the envvar interface is used. Set only those that are not.
16056 # We use the long form for the default assignment because of an extremely
16057 # bizarre bug on SunOS 4.1.3.
16058 if $ac_need_defaults; then
16059 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
16060 test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
16061 fi
16062
16063 # Have a temporary directory for convenience. Make it in the build tree
16064 # simply because there is no reason against having it here, and in addition,
16065 # creating and moving files from /tmp can sometimes cause problems.
16066 # Hook for its removal unless debugging.
16067 # Note that there is a small window in which the directory will not be cleaned:
16068 # after its creation but before its name has been assigned to `$tmp'.
16069 $debug ||
16070 {
16071 tmp= ac_tmp=
16072 trap 'exit_status=$?
16073 : "${ac_tmp:=$tmp}"
16074 { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
16075 ' 0
16076 trap 'as_fn_exit 1' 1 2 13 15
16077 }
16078 # Create a (secure) tmp directory for tmp files.
16079
16080 {
16081 tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
16082 test -d "$tmp"
16083 } ||
16084 {
16085 tmp=./conf$$-$RANDOM
16086 (umask 077 && mkdir "$tmp")
16087 } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
16088 ac_tmp=$tmp
16089
16090 # Set up the scripts for CONFIG_FILES section.
16091 # No need to generate them if there are no CONFIG_FILES.
16092 # This happens for instance with `./config.status config.h'.
16093 if test -n "$CONFIG_FILES"; then
16094
16095
16096 ac_cr=`echo X | tr X '\015'`
16097 # On cygwin, bash can eat \r inside `` if the user requested igncr.
16098 # But we know of no other shell where ac_cr would be empty at this
16099 # point, so we can use a bashism as a fallback.
16100 if test "x$ac_cr" = x; then
16101 eval ac_cr=\$\'\\r\'
16102 fi
16103 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
16104 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
16105 ac_cs_awk_cr='\\r'
16106 else
16107 ac_cs_awk_cr=$ac_cr
16108 fi
16109
16110 echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
16111 _ACEOF
16112
16113
16114 {
16115 echo "cat >conf$$subs.awk <<_ACEOF" &&
16116 echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
16117 echo "_ACEOF"
16118 } >conf$$subs.sh ||
16119 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
16120 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
16121 ac_delim='%!_!# '
16122 for ac_last_try in false false false false false :; do
16123 . ./conf$$subs.sh ||
16124 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
16125
16126 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
16127 if test $ac_delim_n = $ac_delim_num; then
16128 break
16129 elif $ac_last_try; then
16130 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
16131 else
16132 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
16133 fi
16134 done
16135 rm -f conf$$subs.sh
16136
16137 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
16138 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
16139 _ACEOF
16140 sed -n '
16141 h
16142 s/^/S["/; s/!.*/"]=/
16143 p
16144 g
16145 s/^[^!]*!//
16146 :repl
16147 t repl
16148 s/'"$ac_delim"'$//
16149 t delim
16150 :nl
16151 h
16152 s/\(.\{148\}\)..*/\1/
16153 t more1
16154 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
16155 p
16156 n
16157 b repl
16158 :more1
16159 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
16160 p
16161 g
16162 s/.\{148\}//
16163 t nl
16164 :delim
16165 h
16166 s/\(.\{148\}\)..*/\1/
16167 t more2
16168 s/["\\]/\\&/g; s/^/"/; s/$/"/
16169 p
16170 b
16171 :more2
16172 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
16173 p
16174 g
16175 s/.\{148\}//
16176 t delim
16177 ' <conf$$subs.awk | sed '
16178 /^[^""]/{
16179 N
16180 s/\n//
16181 }
16182 ' >>$CONFIG_STATUS || ac_write_fail=1
16183 rm -f conf$$subs.awk
16184 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
16185 _ACAWK
16186 cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
16187 for (key in S) S_is_set[key] = 1
16188 FS = ""
16189
16190 }
16191 {
16192 line = $ 0
16193 nfields = split(line, field, "@")
16194 substed = 0
16195 len = length(field[1])
16196 for (i = 2; i < nfields; i++) {
16197 key = field[i]
16198 keylen = length(key)
16199 if (S_is_set[key]) {
16200 value = S[key]
16201 line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
16202 len += length(value) + length(field[++i])
16203 substed = 1
16204 } else
16205 len += 1 + keylen
16206 }
16207
16208 print line
16209 }
16210
16211 _ACAWK
16212 _ACEOF
16213 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
16214 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
16215 sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
16216 else
16217 cat
16218 fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
16219 || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
16220 _ACEOF
16221
16222 # VPATH may cause trouble with some makes, so we remove sole $(srcdir),
16223 # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
16224 # trailing colons and then remove the whole line if VPATH becomes empty
16225 # (actually we leave an empty line to preserve line numbers).
16226 if test "x$srcdir" = x.; then
16227 ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
16228 h
16229 s///
16230 s/^/:/
16231 s/[ ]*$/:/
16232 s/:\$(srcdir):/:/g
16233 s/:\${srcdir}:/:/g
16234 s/:@srcdir@:/:/g
16235 s/^:*//
16236 s/:*$//
16237 x
16238 s/\(=[ ]*\).*/\1/
16239 G
16240 s/\n//
16241 s/^[^=]*=[ ]*$//
16242 }'
16243 fi
16244
16245 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
16246 fi # test -n "$CONFIG_FILES"
16247
16248
16249 eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS"
16250 shift
16251 for ac_tag
16252 do
16253 case $ac_tag in
16254 :[FHLC]) ac_mode=$ac_tag; continue;;
16255 esac
16256 case $ac_mode$ac_tag in
16257 :[FHL]*:*);;
16258 :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
16259 :[FH]-) ac_tag=-:-;;
16260 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
16261 esac
16262 ac_save_IFS=$IFS
16263 IFS=:
16264 set x $ac_tag
16265 IFS=$ac_save_IFS
16266 shift
16267 ac_file=$1
16268 shift
16269
16270 case $ac_mode in
16271 :L) ac_source=$1;;
16272 :[FH])
16273 ac_file_inputs=
16274 for ac_f
16275 do
16276 case $ac_f in
16277 -) ac_f="$ac_tmp/stdin";;
16278 *) # Look for the file first in the build tree, then in the source tree
16279 # (if the path is not absolute). The absolute path cannot be DOS-style,
16280 # because $ac_f cannot contain `:'.
16281 test -f "$ac_f" ||
16282 case $ac_f in
16283 [\\/$]*) false;;
16284 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
16285 esac ||
16286 as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
16287 esac
16288 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
16289 as_fn_append ac_file_inputs " '$ac_f'"
16290 done
16291
16292 # Let's still pretend it is `configure' which instantiates (i.e., don't
16293 # use $as_me), people would be surprised to read:
16294 # /* config.h. Generated by config.status. */
16295 configure_input='Generated from '`
16296 $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
16297 `' by configure.'
16298 if test x"$ac_file" != x-; then
16299 configure_input="$ac_file. $configure_input"
16300 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
16301 $as_echo "$as_me: creating $ac_file" >&6;}
16302 fi
16303 # Neutralize special characters interpreted by sed in replacement strings.
16304 case $configure_input in #(
16305 *\&* | *\|* | *\\* )
16306 ac_sed_conf_input=`$as_echo "$configure_input" |
16307 sed 's/[\\\\&|]/\\\\&/g'`;; #(
16308 *) ac_sed_conf_input=$configure_input;;
16309 esac
16310
16311 case $ac_tag in
16312 *:-:* | *:-) cat >"$ac_tmp/stdin" \
16313 || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
16314 esac
16315 ;;
16316 esac
16317
16318 ac_dir=`$as_dirname -- "$ac_file" ||
16319 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
16320 X"$ac_file" : 'X\(//\)[^/]' \| \
16321 X"$ac_file" : 'X\(//\)$' \| \
16322 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
16323 $as_echo X"$ac_file" |
16324 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
16325 s//\1/
16326 q
16327 }
16328 /^X\(\/\/\)[^/].*/{
16329 s//\1/
16330 q
16331 }
16332 /^X\(\/\/\)$/{
16333 s//\1/
16334 q
16335 }
16336 /^X\(\/\).*/{
16337 s//\1/
16338 q
16339 }
16340 s/.*/./; q'`
16341 as_dir="$ac_dir"; as_fn_mkdir_p
16342 ac_builddir=.
16343
16344 case "$ac_dir" in
16345 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
16346 *)
16347 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
16348 # A ".." for each directory in $ac_dir_suffix.
16349 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
16350 case $ac_top_builddir_sub in
16351 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
16352 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
16353 esac ;;
16354 esac
16355 ac_abs_top_builddir=$ac_pwd
16356 ac_abs_builddir=$ac_pwd$ac_dir_suffix
16357 # for backward compatibility:
16358 ac_top_builddir=$ac_top_build_prefix
16359
16360 case $srcdir in
16361 .) # We are building in place.
16362 ac_srcdir=.
16363 ac_top_srcdir=$ac_top_builddir_sub
16364 ac_abs_top_srcdir=$ac_pwd ;;
16365 [\\/]* | ?:[\\/]* ) # Absolute name.
16366 ac_srcdir=$srcdir$ac_dir_suffix;
16367 ac_top_srcdir=$srcdir
16368 ac_abs_top_srcdir=$srcdir ;;
16369 *) # Relative name.
16370 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
16371 ac_top_srcdir=$ac_top_build_prefix$srcdir
16372 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
16373 esac
16374 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
16375
16376
16377 case $ac_mode in
16378 :F)
16379 #
16380 # CONFIG_FILE
16381 #
16382
16383 case $INSTALL in
16384 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
16385 *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
16386 esac
16387 _ACEOF
16388
16389 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
16390 # If the template does not know about datarootdir, expand it.
16391 # FIXME: This hack should be removed a few years after 2.60.
16392 ac_datarootdir_hack=; ac_datarootdir_seen=
16393 ac_sed_dataroot='
16394 /datarootdir/ {
16395 p
16396 q
16397 }
16398 /@datadir@/p
16399 /@docdir@/p
16400 /@infodir@/p
16401 /@localedir@/p
16402 /@mandir@/p'
16403 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
16404 *datarootdir*) ac_datarootdir_seen=yes;;
16405 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
16406 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
16407 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
16408 _ACEOF
16409 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
16410 ac_datarootdir_hack='
16411 s&@datadir@&$datadir&g
16412 s&@docdir@&$docdir&g
16413 s&@infodir@&$infodir&g
16414 s&@localedir@&$localedir&g
16415 s&@mandir@&$mandir&g
16416 s&\\\${datarootdir}&$datarootdir&g' ;;
16417 esac
16418 _ACEOF
16419
16420 # Neutralize VPATH when `$srcdir' = `.'.
16421 # Shell code in configure.ac might set extrasub.
16422 # FIXME: do we really want to maintain this feature?
16423 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
16424 ac_sed_extra="$ac_vpsub
16425 $extrasub
16426 _ACEOF
16427 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
16428 :t
16429 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
16430 s|@configure_input@|$ac_sed_conf_input|;t t
16431 s&@top_builddir@&$ac_top_builddir_sub&;t t
16432 s&@top_build_prefix@&$ac_top_build_prefix&;t t
16433 s&@srcdir@&$ac_srcdir&;t t
16434 s&@abs_srcdir@&$ac_abs_srcdir&;t t
16435 s&@top_srcdir@&$ac_top_srcdir&;t t
16436 s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
16437 s&@builddir@&$ac_builddir&;t t
16438 s&@abs_builddir@&$ac_abs_builddir&;t t
16439 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
16440 s&@INSTALL@&$ac_INSTALL&;t t
16441 $ac_datarootdir_hack
16442 "
16443 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
16444 >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
16445
16446 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
16447 { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
16448 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
16449 "$ac_tmp/out"`; test -z "$ac_out"; } &&
16450 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
16451 which seems to be undefined. Please make sure it is defined" >&5
16452 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
16453 which seems to be undefined. Please make sure it is defined" >&2;}
16454
16455 rm -f "$ac_tmp/stdin"
16456 case $ac_file in
16457 -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
16458 *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
16459 esac \
16460 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
16461 ;;
16462
16463
16464 :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
16465 $as_echo "$as_me: executing $ac_file commands" >&6;}
16466 ;;
16467 esac
16468
16469
16470 case $ac_file$ac_mode in
16471 "libtool":C)
16472
16473 # See if we are running on zsh, and set the options which allow our
16474 # commands through without removal of \ escapes.
16475 if test -n "${ZSH_VERSION+set}" ; then
16476 setopt NO_GLOB_SUBST
16477 fi
16478
16479 cfgfile="${ofile}T"
16480 trap "$RM \"$cfgfile\"; exit 1" 1 2 15
16481 $RM "$cfgfile"
16482
16483 cat <<_LT_EOF >> "$cfgfile"
16484 #! $SHELL
16485
16486 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
16487 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
16488 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
16489 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
16490 #
16491 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
16492 # 2006, 2007, 2008 Free Software Foundation, Inc.
16493 # Written by Gordon Matzigkeit, 1996
16494 #
16495 # This file is part of GNU Libtool.
16496 #
16497 # GNU Libtool is free software; you can redistribute it and/or
16498 # modify it under the terms of the GNU General Public License as
16499 # published by the Free Software Foundation; either version 2 of
16500 # the License, or (at your option) any later version.
16501 #
16502 # As a special exception to the GNU General Public License,
16503 # if you distribute this file as part of a program or library that
16504 # is built using GNU Libtool, you may include this file under the
16505 # same distribution terms that you use for the rest of that program.
16506 #
16507 # GNU Libtool is distributed in the hope that it will be useful,
16508 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16509 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16510 # GNU General Public License for more details.
16511 #
16512 # You should have received a copy of the GNU General Public License
16513 # along with GNU Libtool; see the file COPYING. If not, a copy
16514 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
16515 # obtained by writing to the Free Software Foundation, Inc.,
16516 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16517
16518
16519 # The names of the tagged configurations supported by this script.
16520 available_tags=""
16521
16522 # ### BEGIN LIBTOOL CONFIG
16523
16524 # Which release of libtool.m4 was used?
16525 macro_version=$macro_version
16526 macro_revision=$macro_revision
16527
16528 # Assembler program.
16529 AS=$AS
16530
16531 # DLL creation program.
16532 DLLTOOL=$DLLTOOL
16533
16534 # Object dumper program.
16535 OBJDUMP=$OBJDUMP
16536
16537 # Whether or not to build shared libraries.
16538 build_libtool_libs=$enable_shared
16539
16540 # Whether or not to build static libraries.
16541 build_old_libs=$enable_static
16542
16543 # What type of objects to build.
16544 pic_mode=$pic_mode
16545
16546 # Whether or not to optimize for fast installation.
16547 fast_install=$enable_fast_install
16548
16549 # The host system.
16550 host_alias=$host_alias
16551 host=$host
16552 host_os=$host_os
16553
16554 # The build system.
16555 build_alias=$build_alias
16556 build=$build
16557 build_os=$build_os
16558
16559 # A sed program that does not truncate output.
16560 SED=$lt_SED
16561
16562 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
16563 Xsed="\$SED -e 1s/^X//"
16564
16565 # A grep program that handles long lines.
16566 GREP=$lt_GREP
16567
16568 # An ERE matcher.
16569 EGREP=$lt_EGREP
16570
16571 # A literal string matcher.
16572 FGREP=$lt_FGREP
16573
16574 # A BSD- or MS-compatible name lister.
16575 NM=$lt_NM
16576
16577 # Whether we need soft or hard links.
16578 LN_S=$lt_LN_S
16579
16580 # What is the maximum length of a command?
16581 max_cmd_len=$max_cmd_len
16582
16583 # Object file suffix (normally "o").
16584 objext=$ac_objext
16585
16586 # Executable file suffix (normally "").
16587 exeext=$exeext
16588
16589 # whether the shell understands "unset".
16590 lt_unset=$lt_unset
16591
16592 # turn spaces into newlines.
16593 SP2NL=$lt_lt_SP2NL
16594
16595 # turn newlines into spaces.
16596 NL2SP=$lt_lt_NL2SP
16597
16598 # How to create reloadable object files.
16599 reload_flag=$lt_reload_flag
16600 reload_cmds=$lt_reload_cmds
16601
16602 # Method to check whether dependent libraries are shared objects.
16603 deplibs_check_method=$lt_deplibs_check_method
16604
16605 # Command to use when deplibs_check_method == "file_magic".
16606 file_magic_cmd=$lt_file_magic_cmd
16607
16608 # The archiver.
16609 AR=$lt_AR
16610 AR_FLAGS=$lt_AR_FLAGS
16611
16612 # A symbol stripping program.
16613 STRIP=$lt_STRIP
16614
16615 # Commands used to install an old-style archive.
16616 RANLIB=$lt_RANLIB
16617 old_postinstall_cmds=$lt_old_postinstall_cmds
16618 old_postuninstall_cmds=$lt_old_postuninstall_cmds
16619
16620 # A C compiler.
16621 LTCC=$lt_CC
16622
16623 # LTCC compiler flags.
16624 LTCFLAGS=$lt_CFLAGS
16625
16626 # Take the output of nm and produce a listing of raw symbols and C names.
16627 global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
16628
16629 # Transform the output of nm in a proper C declaration.
16630 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
16631
16632 # Transform the output of nm in a C name address pair.
16633 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
16634
16635 # Transform the output of nm in a C name address pair when lib prefix is needed.
16636 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
16637
16638 # The name of the directory that contains temporary libtool files.
16639 objdir=$objdir
16640
16641 # Shell to use when invoking shell scripts.
16642 SHELL=$lt_SHELL
16643
16644 # An echo program that does not interpret backslashes.
16645 ECHO=$lt_ECHO
16646
16647 # Used to examine libraries when file_magic_cmd begins with "file".
16648 MAGIC_CMD=$MAGIC_CMD
16649
16650 # Must we lock files when doing compilation?
16651 need_locks=$lt_need_locks
16652
16653 # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
16654 DSYMUTIL=$lt_DSYMUTIL
16655
16656 # Tool to change global to local symbols on Mac OS X.
16657 NMEDIT=$lt_NMEDIT
16658
16659 # Tool to manipulate fat objects and archives on Mac OS X.
16660 LIPO=$lt_LIPO
16661
16662 # ldd/readelf like tool for Mach-O binaries on Mac OS X.
16663 OTOOL=$lt_OTOOL
16664
16665 # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
16666 OTOOL64=$lt_OTOOL64
16667
16668 # Old archive suffix (normally "a").
16669 libext=$libext
16670
16671 # Shared library suffix (normally ".so").
16672 shrext_cmds=$lt_shrext_cmds
16673
16674 # The commands to extract the exported symbol list from a shared archive.
16675 extract_expsyms_cmds=$lt_extract_expsyms_cmds
16676
16677 # Variables whose values should be saved in libtool wrapper scripts and
16678 # restored at link time.
16679 variables_saved_for_relink=$lt_variables_saved_for_relink
16680
16681 # Do we need the "lib" prefix for modules?
16682 need_lib_prefix=$need_lib_prefix
16683
16684 # Do we need a version for libraries?
16685 need_version=$need_version
16686
16687 # Library versioning type.
16688 version_type=$version_type
16689
16690 # Shared library runtime path variable.
16691 runpath_var=$runpath_var
16692
16693 # Shared library path variable.
16694 shlibpath_var=$shlibpath_var
16695
16696 # Is shlibpath searched before the hard-coded library search path?
16697 shlibpath_overrides_runpath=$shlibpath_overrides_runpath
16698
16699 # Format of library name prefix.
16700 libname_spec=$lt_libname_spec
16701
16702 # List of archive names. First name is the real one, the rest are links.
16703 # The last name is the one that the linker finds with -lNAME
16704 library_names_spec=$lt_library_names_spec
16705
16706 # The coded name of the library, if different from the real name.
16707 soname_spec=$lt_soname_spec
16708
16709 # Command to use after installation of a shared archive.
16710 postinstall_cmds=$lt_postinstall_cmds
16711
16712 # Command to use after uninstallation of a shared archive.
16713 postuninstall_cmds=$lt_postuninstall_cmds
16714
16715 # Commands used to finish a libtool library installation in a directory.
16716 finish_cmds=$lt_finish_cmds
16717
16718 # As "finish_cmds", except a single script fragment to be evaled but
16719 # not shown.
16720 finish_eval=$lt_finish_eval
16721
16722 # Whether we should hardcode library paths into libraries.
16723 hardcode_into_libs=$hardcode_into_libs
16724
16725 # Compile-time system search path for libraries.
16726 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
16727
16728 # Run-time system search path for libraries.
16729 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
16730
16731 # Whether dlopen is supported.
16732 dlopen_support=$enable_dlopen
16733
16734 # Whether dlopen of programs is supported.
16735 dlopen_self=$enable_dlopen_self
16736
16737 # Whether dlopen of statically linked programs is supported.
16738 dlopen_self_static=$enable_dlopen_self_static
16739
16740 # Commands to strip libraries.
16741 old_striplib=$lt_old_striplib
16742 striplib=$lt_striplib
16743
16744
16745 # The linker used to build libraries.
16746 LD=$lt_LD
16747
16748 # Commands used to build an old-style archive.
16749 old_archive_cmds=$lt_old_archive_cmds
16750
16751 # A language specific compiler.
16752 CC=$lt_compiler
16753
16754 # Is the compiler the GNU compiler?
16755 with_gcc=$GCC
16756
16757 # Compiler flag to turn off builtin functions.
16758 no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
16759
16760 # How to pass a linker flag through the compiler.
16761 wl=$lt_lt_prog_compiler_wl
16762
16763 # Additional compiler flags for building library objects.
16764 pic_flag=$lt_lt_prog_compiler_pic
16765
16766 # Compiler flag to prevent dynamic linking.
16767 link_static_flag=$lt_lt_prog_compiler_static
16768
16769 # Does compiler simultaneously support -c and -o options?
16770 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
16771
16772 # Whether or not to add -lc for building shared libraries.
16773 build_libtool_need_lc=$archive_cmds_need_lc
16774
16775 # Whether or not to disallow shared libs when runtime libs are static.
16776 allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
16777
16778 # Compiler flag to allow reflexive dlopens.
16779 export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
16780
16781 # Compiler flag to generate shared objects directly from archives.
16782 whole_archive_flag_spec=$lt_whole_archive_flag_spec
16783
16784 # Whether the compiler copes with passing no objects directly.
16785 compiler_needs_object=$lt_compiler_needs_object
16786
16787 # Create an old-style archive from a shared archive.
16788 old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
16789
16790 # Create a temporary old-style archive to link instead of a shared archive.
16791 old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
16792
16793 # Commands used to build a shared archive.
16794 archive_cmds=$lt_archive_cmds
16795 archive_expsym_cmds=$lt_archive_expsym_cmds
16796
16797 # Commands used to build a loadable module if different from building
16798 # a shared archive.
16799 module_cmds=$lt_module_cmds
16800 module_expsym_cmds=$lt_module_expsym_cmds
16801
16802 # Whether we are building with GNU ld or not.
16803 with_gnu_ld=$lt_with_gnu_ld
16804
16805 # Flag that allows shared libraries with undefined symbols to be built.
16806 allow_undefined_flag=$lt_allow_undefined_flag
16807
16808 # Flag that enforces no undefined symbols.
16809 no_undefined_flag=$lt_no_undefined_flag
16810
16811 # Flag to hardcode \$libdir into a binary during linking.
16812 # This must work even if \$libdir does not exist
16813 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
16814
16815 # If ld is used when linking, flag to hardcode \$libdir into a binary
16816 # during linking. This must work even if \$libdir does not exist.
16817 hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
16818
16819 # Whether we need a single "-rpath" flag with a separated argument.
16820 hardcode_libdir_separator=$lt_hardcode_libdir_separator
16821
16822 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
16823 # DIR into the resulting binary.
16824 hardcode_direct=$hardcode_direct
16825
16826 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
16827 # DIR into the resulting binary and the resulting library dependency is
16828 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
16829 # library is relocated.
16830 hardcode_direct_absolute=$hardcode_direct_absolute
16831
16832 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
16833 # into the resulting binary.
16834 hardcode_minus_L=$hardcode_minus_L
16835
16836 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
16837 # into the resulting binary.
16838 hardcode_shlibpath_var=$hardcode_shlibpath_var
16839
16840 # Set to "yes" if building a shared library automatically hardcodes DIR
16841 # into the library and all subsequent libraries and executables linked
16842 # against it.
16843 hardcode_automatic=$hardcode_automatic
16844
16845 # Set to yes if linker adds runtime paths of dependent libraries
16846 # to runtime path list.
16847 inherit_rpath=$inherit_rpath
16848
16849 # Whether libtool must link a program against all its dependency libraries.
16850 link_all_deplibs=$link_all_deplibs
16851
16852 # Fix the shell variable \$srcfile for the compiler.
16853 fix_srcfile_path=$lt_fix_srcfile_path
16854
16855 # Set to "yes" if exported symbols are required.
16856 always_export_symbols=$always_export_symbols
16857
16858 # The commands to list exported symbols.
16859 export_symbols_cmds=$lt_export_symbols_cmds
16860
16861 # Symbols that should not be listed in the preloaded symbols.
16862 exclude_expsyms=$lt_exclude_expsyms
16863
16864 # Symbols that must always be exported.
16865 include_expsyms=$lt_include_expsyms
16866
16867 # Commands necessary for linking programs (against libraries) with templates.
16868 prelink_cmds=$lt_prelink_cmds
16869
16870 # Specify filename containing input files.
16871 file_list_spec=$lt_file_list_spec
16872
16873 # How to hardcode a shared library path into an executable.
16874 hardcode_action=$hardcode_action
16875
16876 # ### END LIBTOOL CONFIG
16877
16878 _LT_EOF
16879
16880 case $host_os in
16881 aix3*)
16882 cat <<\_LT_EOF >> "$cfgfile"
16883 # AIX sometimes has problems with the GCC collect2 program. For some
16884 # reason, if we set the COLLECT_NAMES environment variable, the problems
16885 # vanish in a puff of smoke.
16886 if test "X${COLLECT_NAMES+set}" != Xset; then
16887 COLLECT_NAMES=
16888 export COLLECT_NAMES
16889 fi
16890 _LT_EOF
16891 ;;
16892 esac
16893
16894
16895 ltmain="$ac_aux_dir/ltmain.sh"
16896
16897
16898 # We use sed instead of cat because bash on DJGPP gets confused if
16899 # if finds mixed CR/LF and LF-only lines. Since sed operates in
16900 # text mode, it properly converts lines to CR/LF. This bash problem
16901 # is reportedly fixed, but why not run on old versions too?
16902 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
16903 || (rm -f "$cfgfile"; exit 1)
16904
16905 case $xsi_shell in
16906 yes)
16907 cat << \_LT_EOF >> "$cfgfile"
16908
16909 # func_dirname file append nondir_replacement
16910 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
16911 # otherwise set result to NONDIR_REPLACEMENT.
16912 func_dirname ()
16913 {
16914 case ${1} in
16915 */*) func_dirname_result="${1%/*}${2}" ;;
16916 * ) func_dirname_result="${3}" ;;
16917 esac
16918 }
16919
16920 # func_basename file
16921 func_basename ()
16922 {
16923 func_basename_result="${1##*/}"
16924 }
16925
16926 # func_dirname_and_basename file append nondir_replacement
16927 # perform func_basename and func_dirname in a single function
16928 # call:
16929 # dirname: Compute the dirname of FILE. If nonempty,
16930 # add APPEND to the result, otherwise set result
16931 # to NONDIR_REPLACEMENT.
16932 # value returned in "$func_dirname_result"
16933 # basename: Compute filename of FILE.
16934 # value retuned in "$func_basename_result"
16935 # Implementation must be kept synchronized with func_dirname
16936 # and func_basename. For efficiency, we do not delegate to
16937 # those functions but instead duplicate the functionality here.
16938 func_dirname_and_basename ()
16939 {
16940 case ${1} in
16941 */*) func_dirname_result="${1%/*}${2}" ;;
16942 * ) func_dirname_result="${3}" ;;
16943 esac
16944 func_basename_result="${1##*/}"
16945 }
16946
16947 # func_stripname prefix suffix name
16948 # strip PREFIX and SUFFIX off of NAME.
16949 # PREFIX and SUFFIX must not contain globbing or regex special
16950 # characters, hashes, percent signs, but SUFFIX may contain a leading
16951 # dot (in which case that matches only a dot).
16952 func_stripname ()
16953 {
16954 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
16955 # positional parameters, so assign one to ordinary parameter first.
16956 func_stripname_result=${3}
16957 func_stripname_result=${func_stripname_result#"${1}"}
16958 func_stripname_result=${func_stripname_result%"${2}"}
16959 }
16960
16961 # func_opt_split
16962 func_opt_split ()
16963 {
16964 func_opt_split_opt=${1%%=*}
16965 func_opt_split_arg=${1#*=}
16966 }
16967
16968 # func_lo2o object
16969 func_lo2o ()
16970 {
16971 case ${1} in
16972 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
16973 *) func_lo2o_result=${1} ;;
16974 esac
16975 }
16976
16977 # func_xform libobj-or-source
16978 func_xform ()
16979 {
16980 func_xform_result=${1%.*}.lo
16981 }
16982
16983 # func_arith arithmetic-term...
16984 func_arith ()
16985 {
16986 func_arith_result=$(( $* ))
16987 }
16988
16989 # func_len string
16990 # STRING may not start with a hyphen.
16991 func_len ()
16992 {
16993 func_len_result=${#1}
16994 }
16995
16996 _LT_EOF
16997 ;;
16998 *) # Bourne compatible functions.
16999 cat << \_LT_EOF >> "$cfgfile"
17000
17001 # func_dirname file append nondir_replacement
17002 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
17003 # otherwise set result to NONDIR_REPLACEMENT.
17004 func_dirname ()
17005 {
17006 # Extract subdirectory from the argument.
17007 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
17008 if test "X$func_dirname_result" = "X${1}"; then
17009 func_dirname_result="${3}"
17010 else
17011 func_dirname_result="$func_dirname_result${2}"
17012 fi
17013 }
17014
17015 # func_basename file
17016 func_basename ()
17017 {
17018 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
17019 }
17020
17021
17022 # func_stripname prefix suffix name
17023 # strip PREFIX and SUFFIX off of NAME.
17024 # PREFIX and SUFFIX must not contain globbing or regex special
17025 # characters, hashes, percent signs, but SUFFIX may contain a leading
17026 # dot (in which case that matches only a dot).
17027 # func_strip_suffix prefix name
17028 func_stripname ()
17029 {
17030 case ${2} in
17031 .*) func_stripname_result=`$ECHO "X${3}" \
17032 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
17033 *) func_stripname_result=`$ECHO "X${3}" \
17034 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
17035 esac
17036 }
17037
17038 # sed scripts:
17039 my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
17040 my_sed_long_arg='1s/^-[^=]*=//'
17041
17042 # func_opt_split
17043 func_opt_split ()
17044 {
17045 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
17046 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
17047 }
17048
17049 # func_lo2o object
17050 func_lo2o ()
17051 {
17052 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
17053 }
17054
17055 # func_xform libobj-or-source
17056 func_xform ()
17057 {
17058 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
17059 }
17060
17061 # func_arith arithmetic-term...
17062 func_arith ()
17063 {
17064 func_arith_result=`expr "$@"`
17065 }
17066
17067 # func_len string
17068 # STRING may not start with a hyphen.
17069 func_len ()
17070 {
17071 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
17072 }
17073
17074 _LT_EOF
17075 esac
17076
17077 case $lt_shell_append in
17078 yes)
17079 cat << \_LT_EOF >> "$cfgfile"
17080
17081 # func_append var value
17082 # Append VALUE to the end of shell variable VAR.
17083 func_append ()
17084 {
17085 eval "$1+=\$2"
17086 }
17087 _LT_EOF
17088 ;;
17089 *)
17090 cat << \_LT_EOF >> "$cfgfile"
17091
17092 # func_append var value
17093 # Append VALUE to the end of shell variable VAR.
17094 func_append ()
17095 {
17096 eval "$1=\$$1\$2"
17097 }
17098
17099 _LT_EOF
17100 ;;
17101 esac
17102
17103
17104 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
17105 || (rm -f "$cfgfile"; exit 1)
17106
17107 mv -f "$cfgfile" "$ofile" ||
17108 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
17109 chmod +x "$ofile"
17110
17111 ;;
17112 "default":C) cat >>Makefile <<__EOF__
17113
17114 # Build rules for objects
17115 -include \$(OBJECTS:.lo=.d)
17116 $DEPENDS
17117 $VERSION_DEPENDS
17118
17119 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
17120 $PLAYWAVE_DEPENDS
17121
17122 -include \$(PLAYMUS_OBJECTS:.lo=.d)
17123 $PLAYMUS_DEPENDS
17124 __EOF__
17125 ;;
17126
17127 esac
17128 done # for ac_tag
17129
17130
17131 as_fn_exit 0
17132 _ACEOF
17133 ac_clean_files=$ac_clean_files_save
17134
17135 test $ac_write_fail = 0 ||
17136 as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
17137
17138
17139 # configure is writing to config.log, and then calls config.status.
17140 # config.status does its own redirection, appending to config.log.
17141 # Unfortunately, on DOS this fails, as config.log is still kept open
17142 # by configure, so config.status won't be able to write to it; its
17143 # output is simply discarded. So we exec the FD to /dev/null,
17144 # effectively closing config.log, so it can be properly (re)opened and
17145 # appended to by config.status. When coming back to configure, we
17146 # need to make the FD available again.
17147 if test "$no_create" != yes; then
17148 ac_cs_success=:
17149 ac_config_status_args=
17150 test "$silent" = yes &&
17151 ac_config_status_args="$ac_config_status_args --quiet"
17152 exec 5>/dev/null
17153 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
17154 exec 5>>config.log
17155 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
17156 # would make configure fail if this is the last instruction.
17157 $ac_cs_success || as_fn_exit 1
17158 fi
17159 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
17160 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
17161 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
17162 fi
17163
0 dnl Process this file with autoconf to produce a configure script.
1 AC_INIT
2 AC_CONFIG_SRCDIR([src/mixer.c])
3 AC_CONFIG_AUX_DIR(build-scripts)
4
5 dnl Set various version strings - taken gratefully from the GTk sources
6
7 # Making releases:
8 # MICRO_VERSION += 1;
9 # INTERFACE_AGE += 1;
10 # BINARY_AGE += 1;
11 # if any functions have been added, set INTERFACE_AGE to 0.
12 # if backwards compatibility has been broken,
13 # set BINARY_AGE and INTERFACE_AGE to 0.
14 #
15 MAJOR_VERSION=2
16 MINOR_VERSION=0
17 MICRO_VERSION=4
18 INTERFACE_AGE=2
19 BINARY_AGE=4
20 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
21
22 AC_SUBST(MAJOR_VERSION)
23 AC_SUBST(MINOR_VERSION)
24 AC_SUBST(MICRO_VERSION)
25 AC_SUBST(INTERFACE_AGE)
26 AC_SUBST(BINARY_AGE)
27 AC_SUBST(VERSION)
28
29 dnl libtool versioning
30 LT_INIT([win32-dll])
31
32 LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
33 LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
34 LT_REVISION=$INTERFACE_AGE
35 LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
36 LT_EXTRA="" dnl for OS2 dll name
37 m4_pattern_allow([^LT_])
38
39 AC_SUBST(LT_RELEASE)
40 AC_SUBST(LT_CURRENT)
41 AC_SUBST(LT_REVISION)
42 AC_SUBST(LT_AGE)
43 AC_SUBST(LT_EXTRA)
44
45 dnl Detect the canonical build and host environments
46 dnl AC_CANONICAL_HOST
47
48 dnl Check for tools
49 AC_PROG_CC
50 AC_PROG_INSTALL
51 AC_PROG_MAKE_SET
52 LT_PROG_RC
53
54 dnl Set up the compiler and linker flags
55 case "$host" in
56 *-*-cygwin*)
57 # We build SDL on cygwin without the UNIX emulation layer
58 BASE_CFLAGS="-I/usr/include/mingw"
59 BASE_LDFLAGS=""
60 have_no_cygwin=no
61 AC_MSG_CHECKING(for GCC -mno-cygwin option)
62 save_CFLAGS="$CFLAGS"
63 CFLAGS="$save_CFLAGS -mno-cygwin"
64 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [have_no_cygwin=yes],[])
65 AC_MSG_RESULT($have_no_cygwin)
66 CFLAGS="$save_CFLAGS"
67 if test x$have_no_cygwin = xyes; then
68 BASE_CFLAGS="$BASE_CFLAGS -mno-cygwin"
69 BASE_LDFLAGS="-mno-cygwin"
70 fi
71 ;;
72 *-*-os2*)
73 # disable static builds on os/2
74 enable_static=no
75 # -DBUILD_SDL is needed for DECLSPEC
76 BASE_CFLAGS="-DBUILD_SDL"
77 BASE_LDFLAGS=""
78 # OS/2 does not support a DLL name longer than 8 characters.
79 LT_EXTRA="-os2dllname SDL2mix"
80 ;;
81 *)
82 BASE_CFLAGS="-D_GNU_SOURCE=1"
83 BASE_LDFLAGS=""
84 ;;
85 esac
86 BUILD_CFLAGS="$CFLAGS $CPPFLAGS -I$srcdir/include -I$srcdir/src -I$srcdir/src/codecs"
87 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
88 BUILD_LDFLAGS="$LDFLAGS"
89 EXTRA_LDFLAGS="$BASE_LDFLAGS"
90 ## These are common directories to find software packages
91 #for path in /usr/freeware /usr/pkg /usr/local; do
92 # if test -d $path/include; then
93 # EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
94 # fi
95 # if test -d $path/lib; then
96 # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
97 # fi
98 #done
99 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
100 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
101 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
102
103 dnl Check for compiler characteristics
104 AC_C_CONST
105
106 dnl See whether we can use gcc style dependency tracking
107 AC_ARG_ENABLE(dependency-tracking,
108 [AS_HELP_STRING([--enable-dependency-tracking],
109 [Use gcc -MMD -MT dependency tracking [default=yes]])],
110 , enable_dependency_tracking=yes)
111 if test x$enable_dependency_tracking = xyes; then
112 have_gcc_mmd_mt=no
113 AC_MSG_CHECKING(for GCC -MMD -MT option)
114 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
115 #if !defined(__GNUC__) || __GNUC__ < 3
116 #error Dependency tracking requires GCC 3.0 or newer
117 #endif
118 ]],[])], [have_gcc_mmd_mt=yes],[])
119 AC_MSG_RESULT($have_gcc_mmd_mt)
120
121 if test x$have_gcc_mmd_mt = xyes; then
122 DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
123 fi
124 fi
125
126 case "$host" in
127 *-*-cygwin* | *-*-mingw*)
128 VERSION_SOURCES="$srcdir/version.rc"
129 EXE=".exe"
130 if test "$build" != "$host"; then # cross-compiling
131 # Default cross-compile location
132 ac_default_prefix=/usr/local/cross-tools/$host
133 else
134 # Look for the location of the tools and install there
135 if test "$BUILD_PREFIX" != ""; then
136 ac_default_prefix=$BUILD_PREFIX
137 fi
138 fi
139 ;;
140 *-*-os2*)
141 EXE=".exe"
142 ;;
143 *)
144 EXE=""
145 ;;
146 esac
147
148 # Standard C sources
149 SOURCES=`ls $srcdir/src/*.c $srcdir/src/codecs/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
150
151 dnl set this to use on systems that use lib64 instead of lib
152 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
153
154 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
155 dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
156 CheckVisibilityHidden()
157 {
158 AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
159 have_gcc_fvisibility=no
160
161 visibility_CFLAGS="-fvisibility=hidden"
162 save_CFLAGS="$CFLAGS"
163 CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
164 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
165 #if !defined(__GNUC__) || __GNUC__ < 4
166 #error SDL only uses visibility attributes in GCC 4 or newer
167 #endif
168 ]],[])], [have_gcc_fvisibility=yes],[])
169 AC_MSG_RESULT($have_gcc_fvisibility)
170 CFLAGS="$save_CFLAGS"
171
172 if test x$have_gcc_fvisibility = xyes; then
173 EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
174 fi
175 }
176
177
178 dnl Function to find a library in the compiler search path
179 find_lib()
180 {
181 gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
182 gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
183 env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
184 if test "$cross_compiling" = yes; then
185 host_lib_path=""
186 else
187 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
188 fi
189 for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
190 lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
191 if test x$lib != x; then
192 echo $lib
193 return
194 fi
195 done
196 }
197
198 dnl Check for SDL
199 SDL_VERSION=2.0.7
200 AM_PATH_SDL2($SDL_VERSION,
201 :,
202 AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
203 )
204 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
205 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
206
207 dnl Check for math library
208 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
209
210 AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
211 AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
212
213 dnl Check command-line options
214
215 CheckVisibilityHidden
216
217 AC_ARG_ENABLE([music-cmd],
218 [AS_HELP_STRING([--enable-music-cmd], [support an external music player [default=yes]])],
219 [], [enable_music_cmd=detect])
220 if test "x$enable_music_cmd" != xno; then
221 AC_CHECK_FUNCS([fork vfork])
222 if test "x$ac_cv_func_fork" = "xyes"; then
223 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
224 elif test "x$ac_cv_func_vfork" = "xyes"; then
225 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
226 elif test "x$enable_music_cmd" = "xyes"; then
227 AC_MSG_ERROR([external music player not available on your platform])
228 else
229 enable_music_cmd=no
230 fi
231 if test "x$enable_music_cmd" != xno; then
232 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD"
233 fi
234 fi
235
236 AC_ARG_ENABLE([music-wave],
237 [AS_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [default=yes]])],
238 [], [enable_music_wave=yes])
239 if test x$enable_music_wave = xyes; then
240 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV"
241 fi
242
243 AC_ARG_ENABLE([music-mod],
244 [AS_HELP_STRING([--enable-music-mod], [enable MOD music [default=yes]])],
245 [], [enable_music_mod=yes])
246
247 AC_ARG_ENABLE([music-mod-modplug],
248 [AS_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [default=yes]])],
249 [], [enable_music_mod_modplug=yes])
250 AC_ARG_ENABLE([music-mod-modplug-shared],
251 [AS_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [default=yes]])],
252 [], [enable_music_mod_modplug_shared=yes])
253 if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then
254 PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl
255 have_libmodplug_hdr=yes
256 have_libmodplug_lib=yes
257 ], [dnl
258 AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
259 AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"])
260 ])
261
262 if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
263 have_libmodplug=yes
264 case "$host" in
265 *-*-darwin*)
266 modplug_lib=[`find_lib libmodplug.dylib`]
267 ;;
268 *-*-cygwin* | *-*-mingw*)
269 modplug_lib=[`find_lib "libmodplug*.dll"`]
270 ;;
271 *)
272 modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`]
273 if test x$modplug_lib = x; then
274 modplug_lib=[`find_lib "libmodplug.so.*"`]
275 fi
276 ;;
277 esac
278 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS"
279 if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then
280 echo "-- dynamic libmodplug -> $modplug_lib"
281 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
282 else
283 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
284 fi
285 else
286 AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
287 fi
288 fi
289
290 AC_ARG_ENABLE([music-mod-xmp],
291 [AS_HELP_STRING([--enable-music-mod-xmp], [enable MOD music via libxmp [default=no]])],
292 [], [enable_music_mod_xmp=no])
293 AC_ARG_ENABLE([music-mod-xmp-lite],
294 [AS_HELP_STRING([--enable-music-mod-xmp-lite], [use libxmp-lite instead of libxmp [default=no]])],
295 [], [enable_music_mod_xmp_lite=no])
296 AC_ARG_ENABLE([music-mod-xmp-shared],
297 [AS_HELP_STRING([--enable-music-mod-xmp-shared], [dynamically load xmp library [default=yes]])],
298 [], [enable_music_mod_xmp_shared=yes])
299 if test x$enable_music_mod = xyes -a x$enable_music_mod_xmp = xyes; then
300 xmplib=xmp
301 if test x$enable_music_mod_xmp_lite = xyes; then
302 xmplib=xmp-lite
303 fi
304 PKG_CHECK_MODULES([XMP], [lib$xmplib >= 4.2], [dnl
305 have_libxmp_hdr=yes
306 have_libxmp_lib=yes
307 ], [dnl
308 AC_CHECK_HEADER([xmp.h], [have_libxmp_hdr=yes])
309 AC_CHECK_LIB([xmp], [xmp_load_module_from_memory], [have_libxmp_lib=yes;XMP_LIBS="-l$xmplib"])
310 ])
311
312 if test x$have_libxmp_hdr = xyes -a x$have_libxmp_lib = xyes; then
313 have_libxmp=yes
314 case "$host" in
315 *-*-darwin*)
316 xmp_lib=[`find_lib lib$xmplib.dylib`]
317 ;;
318 *-*-cygwin* | *-*-mingw*)
319 xmp_lib=[`find_lib "lib$xmplib*.dll"`]
320 ;;
321 *)
322 xmp_lib=[`find_lib "lib$xmplib[0-9]*.so.*"`]
323 if test x$xmp_lib = x; then
324 xmp_lib=[`find_lib "lib$xmplib.so.*"`]
325 fi
326 ;;
327 esac
328 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_XMP $XMP_CFLAGS"
329 if test x$enable_music_mod_xmp_shared = xyes && test x$xmp_lib != x; then
330 echo "-- dynamic libxmp -> $xmp_lib"
331 EXTRA_CFLAGS="$EXTRA_CFLAGS -DXMP_DYNAMIC=\\\"$xmp_lib\\\""
332 else
333 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $XMP_LIBS"
334 fi
335 else
336 AC_MSG_WARN([*** Unable to find xmp library (http://xmp.sourceforge.net/)])
337 fi
338 fi
339
340 AC_ARG_ENABLE([music-mod-mikmod],
341 [AS_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [default=no]])],
342 [], [enable_music_mod_mikmod=no])
343 AC_ARG_ENABLE([music-mod-mikmod-shared],
344 [AS_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [default=yes]])],
345 [], [enable_music_mod_mikmod_shared=yes])
346 if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then
347 have_libmikmod=no
348 libmikmod_maj=3
349 libmikmod_min=1
350 libmikmod_rev=10
351 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
352 CFLAGS_SAVED="$CFLAGS"
353 LIBS_SAVED="$LIBS"
354 AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
355 if test "$LIBMIKMOD_CONFIG" != "no" ; then
356 CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
357 LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
358 have_libmikmod=yes
359 AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
360 AC_RUN_IFELSE([AC_LANG_SOURCE([[
361 #include "mikmod.h"
362 #include "stdio.h"
363
364 int main(int argc, char **argv)
365 {
366 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
367 if (ver>=((maj<<16)|(min<<8)|(rev))) {
368 printf("yes\n");
369 return 0;
370 }
371 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
372 return 1;
373 }
374 ]])],[],[have_libmikmod=no],[echo $ac_n "cross compiling; assumed OK... $ac_c"])
375 fi
376
377 if test x$have_libmikmod = xyes; then
378 case "$host" in
379 *-*-darwin*)
380 mikmod_lib=[`find_lib libmikmod.dylib`]
381 ;;
382 *-*-cygwin* | *-*-mingw*)
383 mikmod_lib=[`find_lib "libmikmod*.dll"`]
384 ;;
385 *)
386 mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
387 if test x$mikmod_lib = x; then
388 mikmod_lib=[`find_lib "libmikmod.so.*"`]
389 fi
390 ;;
391 esac
392 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
393 if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
394 echo "-- dynamic libmikmod -> $mikmod_lib"
395 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
396 else
397 EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
398 fi
399 else
400 AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.sourceforge.net/)])
401 fi
402 LIBS="$LIBS_SAVED"
403 CFLAGS="$CFLAGS_SAVED"
404 fi
405
406 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes -a x$have_libxmp != xyes; then
407 AC_MSG_WARN([MOD support disabled])
408 fi
409
410 AC_ARG_ENABLE([music-midi],
411 [AS_HELP_STRING([--enable-music-midi], [enable MIDI music [default=yes]])],
412 [], [enable_music_midi=yes])
413 if test x$enable_music_midi = xyes; then
414 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID"
415 AC_ARG_ENABLE([music-midi-timidity],
416 [AS_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [default=yes]])],
417 [], [enable_music_midi_timidity=yes])
418 if test x$enable_music_midi_timidity = xyes; then
419 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/src/codecs/timidity"
420 SOURCES="$SOURCES $srcdir/src/codecs/timidity/*.c"
421 timidity_cfg=no
422 AC_ARG_WITH([timidity-cfg],
423 [AS_HELP_STRING([--with-timidity-cfg=FILE],[Specify full path to timidity.cfg])], timidity_cfg="$withval", [])
424 if test x$timidity_cfg != xyes -a x$timidity_cfg != xno; then
425 EXTRA_CFLAGS="$EXTRA_CFLAGS -DTIMIDITY_CFG=\\\"$timidity_cfg\\\""
426 fi
427 fi
428 AC_ARG_ENABLE([music-midi-native],
429 [AS_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [default=yes]])],
430 [], [enable_music_midi_native=yes])
431 if test x$enable_music_midi_native = xyes; then
432 use_music_midi_native=no
433 case "$host" in
434 *-*-cygwin* | *-*-mingw*)
435 use_music_midi_native=yes
436 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
437 ;;
438 *-*-darwin*)
439 use_music_midi_native=yes
440 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
441 ;;
442 *-*-haiku*)
443 use_music_midi_native=yes_cpp
444 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
445 ;;
446 esac
447 if test x$use_music_midi_native = xyes; then
448 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
449 SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
450 elif test x$use_music_midi_native = xyes_cpp; then
451 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
452 SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
453 SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp"
454 fi
455 fi
456 AC_ARG_ENABLE([music-midi-fluidsynth],
457 [AS_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [default=yes]])],
458 [], [enable_music_midi_fluidsynth=yes])
459 AC_ARG_ENABLE([music-midi-fluidsynth-shared],
460 [AS_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [default=yes]])],
461 [], [enable_music_midi_fluidsynth_shared=yes])
462 if test x$enable_music_midi_fluidsynth = xyes; then
463 AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
464 AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
465 if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
466 have_fluidsynth=yes
467 case "$host" in
468 *-*-darwin*)
469 fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
470 ;;
471 *-*-cygwin* | *-*-mingw*)
472 fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
473 if test x$fluidsynth_lib = x; then
474 fluidsynth_lib=[`find_lib "libfluidsynth*.dll"`]
475 fi
476 ;;
477 *)
478 fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
479 if test x$fluidsynth_lib = x; then
480 fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
481 fi
482 ;;
483 esac
484 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
485 if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
486 echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
487 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
488 else
489 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
490 fi
491 else
492 AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
493 AC_MSG_WARN([FluidSynth support disabled])
494 fi
495 fi
496 fi
497
498 if test x$enable_music_midi_timidity != xyes -a \
499 x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
500 x$have_fluidsynth != xyes; then
501 AC_MSG_WARN([MIDI support disabled])
502 fi
503
504 AC_ARG_ENABLE([music-ogg],
505 [AS_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [default=yes]])],
506 [], [enable_music_ogg=yes])
507 AC_ARG_ENABLE(music-ogg-tremor,
508 [AS_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [default=no]])],
509 [], enable_music_ogg_tremor=no)
510 AC_ARG_ENABLE([music-ogg-shared],
511 [AS_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [default=yes]])],
512 [], [enable_music_ogg_shared=yes])
513 if test x$enable_music_ogg = xyes; then
514 LIBS_SAVED="$LIBS"
515 if test x$enable_music_ogg_tremor = xyes; then
516 AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
517 AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg])
518 if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
519 case "$host" in
520 *-*-darwin*)
521 ogg_lib=[`find_lib libvorbisidec.dylib`]
522 ;;
523 *-*-cygwin* | *-*-mingw*)
524 ogg_lib=[`find_lib "vorbisidec*.dll"`]
525 if test x$ogg_lib = x; then
526 ogg_lib=[`find_lib "libvorbisidec*.dll"`]
527 fi
528 ;;
529 *)
530 ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
531 if test x$ogg_lib = x; then
532 ogg_lib=[`find_lib "libvorbisidec.so.*"`]
533 fi
534 ;;
535 esac
536 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
537 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
538 echo "-- dynamic libvorbisidec -> $ogg_lib"
539 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
540 else
541 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
542 fi
543 else
544 AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
545 AC_MSG_WARN([Ogg Vorbis support disabled])
546 fi
547 else
548 AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
549 AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm])
550 if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
551 case "$host" in
552 *-*-darwin*)
553 ogg_lib=[`find_lib libvorbisfile.dylib`]
554 ;;
555 *-*-cygwin* | *-*-mingw*)
556 ogg_lib=[`find_lib "libvorbisfile*.dll"`]
557 ;;
558 *)
559 ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
560 if test x$ogg_lib = x; then
561 ogg_lib=[`find_lib "libvorbisfile.so.*"`]
562 fi
563 ;;
564 esac
565 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
566 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
567 echo "-- dynamic libvorbisfile -> $ogg_lib"
568 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
569 else
570 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
571 fi
572 else
573 AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
574 AC_MSG_WARN([Ogg Vorbis support disabled])
575 fi
576 fi
577 LIBS="$LIBS_SAVED"
578 fi
579
580 libflac_ver=8
581 AC_ARG_ENABLE([music-flac],
582 [AS_HELP_STRING([--enable-music-flac], [enable FLAC music [default=yes]])],
583 [], [enable_music_flac=yes])
584 AC_ARG_ENABLE([music-flac-shared],
585 [AS_HELP_STRING([--enable-music-flac-shared],
586 [dynamically load FLAC library [default=yes]])],
587 [], [enable_music_flac_shared=yes])
588 if test x$enable_music_flac = xyes; then
589 AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
590 if test x$have_flac_export = xyes; then
591 LIBS_SAVED="$LIBS"
592 LIBS="-lFLAC"
593 AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
594 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
595 #include "FLAC/export.h"
596 #include "stdio.h"
597 ]], [[
598 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
599 #else
600 #error "old-flac"
601 #endif
602 ]])], [have_flac_ver=yes],[have_flac_ver=no])
603 LIBS="$LIBS_SAVED"
604 AC_MSG_RESULT($have_flac_ver)
605 fi
606
607 if test x$have_flac_ver = xyes; then
608 AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
609 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
610 if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
611 case "$host" in
612 *-*-darwin*)
613 flac_lib=[`find_lib libFLAC.dylib`]
614 ;;
615 *-*-cygwin* | *-*-mingw*)
616 flac_lib=[`find_lib "libFLAC-*.dll"`]
617 ;;
618 *)
619 flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
620 if test x$flac_lib = x; then
621 flac_lib=[`find_lib "libFLAC.so.*"`]
622 fi
623 ;;
624 esac
625 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
626 if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
627 echo "-- dynamic libFLAC -> $flac_lib"
628 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
629 else
630 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
631 fi
632 fi
633 else
634 AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
635 AC_MSG_WARN([FLAC support disabled])
636 fi
637 fi
638
639 AC_ARG_ENABLE(music-mp3,
640 [AS_HELP_STRING([--enable-music-mp3], [enable MP3 music [default=yes]])],
641 [], enable_music_mp3=yes)
642
643 AC_ARG_ENABLE(music-mp3-mad-gpl,
644 [AS_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [default=no]])],
645 [], [enable_music_mp3_mad_gpl=no])
646 AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
647 [AS_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [default=yes]])],
648 [], [enable_music_mp3_mad_gpl_dithering=yes])
649 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
650 AC_MSG_CHECKING(for libmad headers)
651 have_libmad=no
652 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
653 #include "mad.h"
654 ]],[])], [have_libmad=yes],[])
655 AC_MSG_RESULT($have_libmad)
656 if test x$have_libmad = xyes; then
657 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
658 if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
659 AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
660 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
661 fi
662 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
663 else
664 AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
665 fi
666 fi
667
668 AC_ARG_ENABLE(music-mp3-mpg123,
669 [AS_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [default=yes]])],
670 [], [enable_music_mp3_mpg123=yes])
671 AC_ARG_ENABLE([music-mp3-mpg123-shared],
672 [AS_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [default=yes]])],
673 [], [enable_music_mp3_mpg123_shared=yes])
674 if test x$enable_music_mp3_mpg123 = xyes; then
675 AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
676 AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
677 if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
678 have_libmpg123=yes
679 case "$host" in
680 *-*-darwin*)
681 mpg123_lib=[`find_lib libmpg123.dylib`]
682 ;;
683 *-*-cygwin* | *-*-mingw*)
684 mpg123_lib=[`find_lib "libmpg123*.dll"`]
685 ;;
686 *)
687 mpg123_lib=[`find_lib "libmpg123.so.*"`]
688 ;;
689 esac
690 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
691 if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
692 echo "-- dynamic libmpg123 -> $mpg123_lib"
693 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
694 else
695 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
696 fi
697 else
698 AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
699 AC_MSG_WARN([mpg123 support disabled])
700 fi
701 fi
702
703 if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
704 :
705 else
706 AC_MSG_WARN([MP3 support disabled])
707 fi
708
709 AC_ARG_ENABLE([music-opus],
710 [AS_HELP_STRING([--enable-music-opus], [enable Opus music [default=yes]])],
711 [], [enable_music_opus=yes])
712
713 AC_ARG_ENABLE([music-opus-shared],
714 [AS_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [default=yes]])],
715 [], [enable_music_opus_shared=yes])
716 if test x$enable_music_opus = xyes; then
717 LIBS_SAVED="$LIBS"
718 PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
719 have_opusfile_hdr=yes
720 have_opusfile_lib=yes
721 ], [dnl
722 AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
723 AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm])
724 ])
725 LIBS="$LIBS_SAVED"
726
727 if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
728 have_opusfile=yes
729 case "$host" in
730 *-*-darwin*)
731 opusfile_lib=[`find_lib libopusfile.dylib`]
732 ;;
733 *-*-cygwin* | *-*-mingw*)
734 opusfile_lib=[`find_lib "libopusfile*.dll"`]
735 ;;
736 *)
737 opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
738 if test x$opusfile_lib = x; then
739 opusfile_lib=[`find_lib "libopusfile.so.*"`]
740 fi
741 ;;
742 esac
743 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
744 if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
745 echo "-- dynamic opusfile -> $opusfile_lib"
746 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
747 else
748 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
749 fi
750 else
751 AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
752 fi
753 fi
754
755 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
756
757 OBJECTS=`echo $SOURCES`
758 DEPENDS=`echo $SOURCES`
759 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
760 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
761 $(objects)/\2.lo: \1/\2.c \$(objects)/.created\\
762 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
763
764 OBJECTS_CXX=`echo $SOURCES_CXX`
765 DEPENDS_CXX=`echo $SOURCES_CXX`
766 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
767 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
768 $(objects)/\2.lo: \1/\2.cpp \$(objects)/.created\\
769 \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
770 OBJECTS="$OBJECTS $OBJECTS_CXX"
771 DEPENDS="$DEPENDS $DEPENDS_CXX"
772 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
773
774 VERSION_OBJECTS=`echo $VERSION_SOURCES`
775 VERSION_DEPENDS=`echo $VERSION_SOURCES`
776 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'`
777 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
778 $(objects)/\2.lo: \1/\2.rc \$(objects)/.created\\
779 \$(LIBTOOL) --tag=RC --mode=compile \$(RC) \$< -o \$@,g'`
780 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
781
782 PLAYWAVE_SOURCES="$srcdir/playwave.c"
783 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
784 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
785 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
786 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
787 $(objects)/\2.lo: \1/\2.c \$(objects)/.created\\
788 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
789 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
790
791 PLAYMUS_SOURCES="$srcdir/playmus.c"
792 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
793 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
794 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
795 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
796 $(objects)/\2.lo: \1/\2.c \$(objects)/.created\\
797 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
798 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
799
800 dnl Expand the sources and objects needed to build the library
801 AC_SUBST(ac_aux_dir)
802 AC_SUBST(OBJECTS)
803 AC_SUBST(VERSION_OBJECTS)
804 AC_SUBST(PLAYWAVE_OBJECTS)
805 AC_SUBST(PLAYMUS_OBJECTS)
806 AC_SUBST(BUILD_CFLAGS)
807 AC_SUBST(EXTRA_CFLAGS)
808 AC_SUBST(BUILD_LDFLAGS)
809 AC_SUBST(EXTRA_LDFLAGS)
810 AC_SUBST(EXE)
811 AC_SUBST(SDL_VERSION)
812 AC_SUBST(SDL_CFLAGS)
813 AC_SUBST(SDL_LIBS)
814
815 AC_CONFIG_FILES([
816 Makefile SDL2_mixer.spec SDL2_mixer.pc
817 ])
818 AC_CONFIG_COMMANDS([default],
819 [cat >>Makefile <<__EOF__
820
821 # Build rules for objects
822 -include \$(OBJECTS:.lo=.d)
823 $DEPENDS
824 $VERSION_DEPENDS
825
826 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
827 $PLAYWAVE_DEPENDS
828
829 -include \$(PLAYMUS_OBJECTS:.lo=.d)
830 $PLAYMUS_DEPENDS
831 __EOF__
832 ], [
833 DEPENDS="$DEPENDS"
834 VERSION_DEPENDS="$VERSION_DEPENDS"
835 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
836 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
837 ])
838 AC_OUTPUT
+0
-778
configure.in less more
0 dnl Process this file with autoconf to produce a configure script.
1 AC_INIT(README.txt)
2 AC_CONFIG_AUX_DIR(build-scripts)
3
4 dnl Set various version strings - taken gratefully from the GTk sources
5
6 # Making releases:
7 # MICRO_VERSION += 1;
8 # INTERFACE_AGE += 1;
9 # BINARY_AGE += 1;
10 # if any functions have been added, set INTERFACE_AGE to 0.
11 # if backwards compatibility has been broken,
12 # set BINARY_AGE and INTERFACE_AGE to 0.
13 #
14 MAJOR_VERSION=2
15 MINOR_VERSION=0
16 MICRO_VERSION=4
17 INTERFACE_AGE=2
18 BINARY_AGE=4
19 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
20
21 AC_SUBST(MAJOR_VERSION)
22 AC_SUBST(MINOR_VERSION)
23 AC_SUBST(MICRO_VERSION)
24 AC_SUBST(INTERFACE_AGE)
25 AC_SUBST(BINARY_AGE)
26 AC_SUBST(VERSION)
27
28 # libtool versioning
29 LT_INIT([win32-dll])
30
31 LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
32 LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
33 LT_REVISION=$INTERFACE_AGE
34 LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
35 m4_pattern_allow([^LT_])
36
37 AC_SUBST(LT_RELEASE)
38 AC_SUBST(LT_CURRENT)
39 AC_SUBST(LT_REVISION)
40 AC_SUBST(LT_AGE)
41
42 dnl Detect the canonical build and host environments
43 AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
44 dnl AC_CANONICAL_HOST
45
46 dnl Check for tools
47 AC_PROG_LIBTOOL
48 AC_PROG_CC
49 AC_PROG_INSTALL
50 AC_PROG_MAKE_SET
51 if test -z "$host_alias"; then
52 hostaliaswindres=
53 else
54 hostaliaswindres="$host_alias-windres"
55 fi
56 AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
57
58 dnl Set up the compiler and linker flags
59 case "$host" in
60 *-*-cygwin*)
61 # We build SDL on cygwin without the UNIX emulation layer
62 BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
63 BASE_LDFLAGS="-mno-cygwin"
64 ;;
65 *)
66 BASE_CFLAGS="-D_GNU_SOURCE=1"
67 BASE_LDFLAGS=""
68 ;;
69 esac
70 BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
71 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
72 BUILD_LDFLAGS="$LDFLAGS"
73 EXTRA_LDFLAGS="$BASE_LDFLAGS"
74 ## These are common directories to find software packages
75 #for path in /usr/freeware /usr/pkg /usr/local; do
76 # if test -d $path/include; then
77 # EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
78 # fi
79 # if test -d $path/lib; then
80 # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
81 # fi
82 #done
83 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
84 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
85 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
86
87 dnl Check for compiler characteristics
88 AC_C_CONST
89
90 dnl See whether we can use gcc style dependency tracking
91 AC_ARG_ENABLE(dependency-tracking,
92 AC_HELP_STRING([--enable-dependency-tracking],
93 [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
94 , enable_dependency_tracking=yes)
95 if test x$enable_dependency_tracking = xyes; then
96 have_gcc_mmd_mt=no
97 AC_MSG_CHECKING(for GCC -MMD -MT option)
98 AC_TRY_COMPILE([
99 #if !defined(__GNUC__) || __GNUC__ < 3
100 #error Dependency tracking requires GCC 3.0 or newer
101 #endif
102 ],[
103 ],[
104 have_gcc_mmd_mt=yes
105 ])
106 AC_MSG_RESULT($have_gcc_mmd_mt)
107
108 if test x$have_gcc_mmd_mt = xyes; then
109 DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
110 fi
111 fi
112
113 case "$host" in
114 *mingw32ce*)
115 #VERSION_SOURCES="$srcdir/version.rc"
116 EXE=".exe"
117 ;;
118 *-*-cygwin* | *-*-mingw32*)
119 VERSION_SOURCES="$srcdir/version.rc"
120 EXE=".exe"
121 if test "$build" != "$host"; then # cross-compiling
122 # Default cross-compile location
123 ac_default_prefix=/usr/local/cross-tools/$host
124 else
125 # Look for the location of the tools and install there
126 if test "$BUILD_PREFIX" != ""; then
127 ac_default_prefix=$BUILD_PREFIX
128 fi
129 fi
130 ;;
131 *)
132 EXE=""
133 ;;
134 esac
135
136 # Standard C sources
137 SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
138
139 dnl set this to use on systems that use lib64 instead of lib
140 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
141
142 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
143 dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
144 CheckVisibilityHidden()
145 {
146 AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
147 have_gcc_fvisibility=no
148
149 visibility_CFLAGS="-fvisibility=hidden"
150 save_CFLAGS="$CFLAGS"
151 CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
152 AC_TRY_COMPILE([
153 #if !defined(__GNUC__) || __GNUC__ < 4
154 #error SDL only uses visibility attributes in GCC 4 or newer
155 #endif
156 ],[
157 ],[
158 have_gcc_fvisibility=yes
159 ])
160 AC_MSG_RESULT($have_gcc_fvisibility)
161 CFLAGS="$save_CFLAGS"
162
163 if test x$have_gcc_fvisibility = xyes; then
164 EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
165 fi
166 }
167
168
169 dnl Function to find a library in the compiler search path
170 find_lib()
171 {
172 gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
173 gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
174 env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
175 if test "$cross_compiling" = yes; then
176 host_lib_path=""
177 else
178 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
179 fi
180 for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
181 lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
182 if test x$lib != x; then
183 echo $lib
184 return
185 fi
186 done
187 }
188
189 dnl Check for SDL
190 SDL_VERSION=2.0.7
191 AM_PATH_SDL2($SDL_VERSION,
192 :,
193 AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
194 )
195 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
196 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
197
198 dnl Check for math library
199 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
200
201 AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
202 AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
203
204 dnl Check command-line options
205
206 CheckVisibilityHidden
207
208 AC_ARG_ENABLE([music-cmd],
209 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
210 [], [enable_music_cmd=detect])
211 if test "x$enable_music_cmd" != xno; then
212 AC_CHECK_FUNCS([fork vfork])
213 if test "x$ac_cv_func_fork" = "xyes"; then
214 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
215 elif test "x$ac_cv_func_vfork" = "xyes"; then
216 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
217 elif test "x$enable_music_cmd" = "xyes"; then
218 AC_MSG_ERROR([external music player not available on your platform])
219 else
220 enable_music_cmd=no
221 fi
222 if test "x$enable_music_cmd" != xno; then
223 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD"
224 fi
225 fi
226
227 AC_ARG_ENABLE([music-wave],
228 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
229 [], [enable_music_wave=yes])
230 if test x$enable_music_wave = xyes; then
231 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV"
232 fi
233
234 AC_ARG_ENABLE([music-mod],
235 AC_HELP_STRING([--enable-music-mod], [enable MOD music [[default=yes]]]),
236 [], [enable_music_mod=yes])
237
238 AC_ARG_ENABLE([music-mod-modplug],
239 AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=yes]]]),
240 [], [enable_music_mod_modplug=yes])
241 AC_ARG_ENABLE([music-mod-modplug-shared],
242 AC_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [[default=yes]]]),
243 [], [enable_music_mod_modplug_shared=yes])
244 if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then
245 PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl
246 have_libmodplug_hdr=yes
247 have_libmodplug_lib=yes
248 ], [dnl
249 AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
250 AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"])
251 ])
252
253 if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
254 have_libmodplug=yes
255 case "$host" in
256 *-*-darwin*)
257 modplug_lib=[`find_lib libmodplug.dylib`]
258 ;;
259 *-*-cygwin* | *-*-mingw32*)
260 modplug_lib=[`find_lib "libmodplug*.dll"`]
261 ;;
262 *)
263 modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`]
264 if test x$modplug_lib = x; then
265 modplug_lib=[`find_lib "libmodplug.so.*"`]
266 fi
267 ;;
268 esac
269 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS"
270 if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then
271 echo "-- dynamic libmodplug -> $modplug_lib"
272 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
273 else
274 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
275 fi
276 else
277 AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
278 fi
279 fi
280
281 AC_ARG_ENABLE([music-mod-mikmod],
282 AC_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [[default=no]]]),
283 [], [enable_music_mod_mikmod=no])
284 AC_ARG_ENABLE([music-mod-mikmod-shared],
285 AC_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [[default=yes]]]),
286 [], [enable_music_mod_mikmod_shared=yes])
287 if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then
288 have_libmikmod=no
289 libmikmod_maj=3
290 libmikmod_min=1
291 libmikmod_rev=10
292 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
293 CFLAGS_SAVED="$CFLAGS"
294 LIBS_SAVED="$LIBS"
295 AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
296 if test "$LIBMIKMOD_CONFIG" != "no" ; then
297 CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
298 LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
299 have_libmikmod=yes
300 AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
301 AC_TRY_RUN([
302 #include "mikmod.h"
303 #include "stdio.h"
304
305 int main(int argc, char **argv)
306 {
307 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
308 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
309 if(ver>=((maj<<16)|(min<<8)|(rev))) {
310 printf("yes\n");
311 return 0;
312 }
313 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
314 return 1;
315 }
316 ], [], [have_libmikmod=no], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
317 fi
318
319 if test x$have_libmikmod = xyes; then
320 case "$host" in
321 *-*-darwin*)
322 mikmod_lib=[`find_lib libmikmod.dylib`]
323 ;;
324 *-*-cygwin* | *-*-mingw32*)
325 mikmod_lib=[`find_lib "libmikmod*.dll"`]
326 ;;
327 *)
328 mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
329 if test x$mikmod_lib = x; then
330 mikmod_lib=[`find_lib "libmikmod.so.*"`]
331 fi
332 ;;
333 esac
334 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
335 if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
336 echo "-- dynamic libmikmod -> $mikmod_lib"
337 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
338 else
339 EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
340 fi
341 else
342 AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
343 fi
344 LIBS="$LIBS_SAVED"
345 CFLAGS="$CFLAGS_SAVED"
346 fi
347
348 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
349 AC_MSG_WARN([MOD support disabled])
350 fi
351
352 AC_ARG_ENABLE([music-midi],
353 AC_HELP_STRING([--enable-music-midi], [enable MIDI music [[default=yes]]]),
354 [], [enable_music_midi=yes])
355 if test x$enable_music_midi = xyes; then
356 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID"
357 AC_ARG_ENABLE([music-midi-timidity],
358 AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]),
359 [], [enable_music_midi_timidity=yes])
360 if test x$enable_music_midi_timidity = xyes; then
361 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
362 SOURCES="$SOURCES $srcdir/timidity/*.c"
363 fi
364 AC_ARG_ENABLE([music-midi-native],
365 AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]),
366 [], [enable_music_midi_native=yes])
367 if test x$enable_music_midi_native = xyes; then
368 use_music_midi_native=no
369 case "$host" in
370 *mingw32ce*)
371 use_music_midi_native=no
372 ;;
373 *-*-cygwin* | *-*-mingw32*)
374 use_music_midi_native=yes
375 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
376 ;;
377 *-*-darwin*)
378 use_music_midi_native=yes
379 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
380 ;;
381 *-*-haiku*)
382 use_music_midi_native=yes_cpp
383 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
384 ;;
385 esac
386 if test x$use_music_midi_native = xyes; then
387 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
388 SOURCES="$SOURCES $srcdir/native_midi/*.c"
389 elif test x$use_music_midi_native = xyes_cpp; then
390 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
391 SOURCES="$SOURCES $srcdir/native_midi/*.c"
392 SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
393 fi
394 fi
395 AC_ARG_ENABLE([music-midi-fluidsynth],
396 AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]),
397 [], [enable_music_midi_fluidsynth=yes])
398 AC_ARG_ENABLE([music-midi-fluidsynth-shared],
399 AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]),
400 [], [enable_music_midi_fluidsynth_shared=yes])
401 if test x$enable_music_midi_fluidsynth = xyes; then
402 AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
403 AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
404 if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
405 have_fluidsynth=yes
406 case "$host" in
407 *-*-darwin*)
408 fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
409 ;;
410 *-*-cygwin* | *-*-mingw32*)
411 fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
412 ;;
413 *)
414 fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
415 if test x$fluidsynth_lib = x; then
416 fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
417 fi
418 ;;
419 esac
420 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
421 if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
422 echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
423 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
424 else
425 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
426 fi
427 else
428 AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
429 AC_MSG_WARN([FluidSynth support disabled])
430 fi
431 fi
432 fi
433
434 if test x$enable_music_midi_timidity != xyes -a \
435 x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
436 x$have_fluidsynth != xyes; then
437 AC_MSG_WARN([MIDI support disabled])
438 fi
439
440 AC_ARG_ENABLE([music-ogg],
441 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
442 [], [enable_music_ogg=yes])
443 AC_ARG_ENABLE(music-ogg-tremor,
444 AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
445 [], enable_music_ogg_tremor=no)
446 AC_ARG_ENABLE([music-ogg-shared],
447 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [[default=yes]]]),
448 [], [enable_music_ogg_shared=yes])
449 if test x$enable_music_ogg = xyes; then
450 LIBS_SAVED="$LIBS"
451 if test x$enable_music_ogg_tremor = xyes; then
452 AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
453 AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg])
454 if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
455 case "$host" in
456 *-*-darwin*)
457 ogg_lib=[`find_lib libvorbisidec.dylib`]
458 ;;
459 *-*-cygwin* | *-*-mingw32*)
460 ogg_lib=[`find_lib "vorbisidec*.dll"`]
461 ;;
462 *)
463 ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
464 if test x$ogg_lib = x; then
465 ogg_lib=[`find_lib "libvorbisidec.so.*"`]
466 fi
467 ;;
468 esac
469 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
470 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
471 echo "-- dynamic libvorbisidec -> $ogg_lib"
472 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
473 else
474 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
475 fi
476 else
477 AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
478 AC_MSG_WARN([Ogg Vorbis support disabled])
479 fi
480 else
481 AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
482 AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm])
483 if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
484 case "$host" in
485 *-*-darwin*)
486 ogg_lib=[`find_lib libvorbisfile.dylib`]
487 ;;
488 *-*-cygwin* | *-*-mingw32*)
489 ogg_lib=[`find_lib "libvorbisfile*.dll"`]
490 ;;
491 *)
492 ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
493 if test x$ogg_lib = x; then
494 ogg_lib=[`find_lib "libvorbisfile.so.*"`]
495 fi
496 ;;
497 esac
498 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
499 if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
500 echo "-- dynamic libvorbisfile -> $ogg_lib"
501 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
502 else
503 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
504 fi
505 else
506 AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
507 AC_MSG_WARN([Ogg Vorbis support disabled])
508 fi
509 fi
510 LIBS="$LIBS_SAVED"
511 fi
512
513 libflac_ver=8
514 AC_ARG_ENABLE([music-flac],
515 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
516 [], [enable_music_flac=yes])
517 AC_ARG_ENABLE([music-flac-shared],
518 AC_HELP_STRING([--enable-music-flac-shared],
519 [dynamically load FLAC library [[default=yes]]]),
520 [], [enable_music_flac_shared=yes])
521 if test x$enable_music_flac = xyes; then
522 AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
523 if test x$have_flac_export = xyes; then
524 LIBS_SAVED="$LIBS"
525 LIBS="-lFLAC"
526 AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
527 AC_TRY_COMPILE([
528 #include "FLAC/export.h"
529 #include "stdio.h"
530 ],[
531 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
532 #else
533 #error "old-flac"
534 #endif
535 ], have_flac_ver=yes, have_flac_ver=no)
536 LIBS="$LIBS_SAVED"
537 AC_MSG_RESULT($have_flac_ver)
538 fi
539
540 if test x$have_flac_ver = xyes; then
541 AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
542 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
543 if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
544 case "$host" in
545 *-*-darwin*)
546 flac_lib=[`find_lib libFLAC.dylib`]
547 ;;
548 *-*-cygwin* | *-*-mingw32*)
549 flac_lib=[`find_lib "libFLAC-*.dll"`]
550 ;;
551 *)
552 flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
553 if test x$flac_lib = x; then
554 flac_lib=[`find_lib "libFLAC.so.*"`]
555 fi
556 ;;
557 esac
558 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
559 if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
560 echo "-- dynamic libFLAC -> $flac_lib"
561 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
562 else
563 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
564 fi
565 fi
566 else
567 AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
568 AC_MSG_WARN([FLAC support disabled])
569 fi
570 fi
571
572 AC_ARG_ENABLE(music-mp3,
573 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]),
574 [], enable_music_mp3=yes)
575
576 AC_ARG_ENABLE(music-mp3-mad-gpl,
577 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
578 [], [enable_music_mp3_mad_gpl=no])
579 AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
580 AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]),
581 [], [enable_music_mp3_mad_gpl_dithering=yes])
582 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
583 AC_MSG_CHECKING(for libmad headers)
584 have_libmad=no
585 AC_TRY_COMPILE([
586 #include "mad.h"
587 ],[
588 ],[
589 have_libmad=yes
590 ])
591 AC_MSG_RESULT($have_libmad)
592 if test x$have_libmad = xyes; then
593 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
594 if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
595 AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
596 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
597 fi
598 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
599 else
600 AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
601 fi
602 fi
603
604 AC_ARG_ENABLE(music-mp3-mpg123,
605 AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
606 [], [enable_music_mp3_mpg123=yes])
607 AC_ARG_ENABLE([music-mp3-mpg123-shared],
608 AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
609 [], [enable_music_mp3_mpg123_shared=yes])
610 if test x$enable_music_mp3_mpg123 = xyes; then
611 AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
612 AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
613 if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
614 have_libmpg123=yes
615 case "$host" in
616 *-*-darwin*)
617 mpg123_lib=[`find_lib libmpg123.dylib`]
618 ;;
619 *-*-cygwin* | *-*-mingw32*)
620 mpg123_lib=[`find_lib "libmpg123*.dll"`]
621 ;;
622 *)
623 mpg123_lib=[`find_lib "libmpg123.so.*"`]
624 ;;
625 esac
626 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
627 if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
628 echo "-- dynamic libmpg123 -> $mpg123_lib"
629 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
630 else
631 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
632 fi
633 else
634 AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
635 AC_MSG_WARN([mpg123 support disabled])
636 fi
637 fi
638
639 if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
640 :
641 else
642 AC_MSG_WARN([MP3 support disabled])
643 fi
644
645 AC_ARG_ENABLE([music-opus],
646 AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]),
647 [], [enable_music_opus=yes])
648
649 AC_ARG_ENABLE([music-opus-shared],
650 AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]),
651 [], [enable_music_opus_shared=yes])
652 if test x$enable_music_opus = xyes; then
653 LIBS_SAVED="$LIBS"
654 PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
655 have_opusfile_hdr=yes
656 have_opusfile_lib=yes
657 ], [dnl
658 AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
659 AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm])
660 ])
661 LIBS="$LIBS_SAVED"
662
663 if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
664 have_opusfile=yes
665 case "$host" in
666 *-*-darwin*)
667 opusfile_lib=[`find_lib libopusfile.dylib`]
668 ;;
669 *-*-cygwin* | *-*-mingw32*)
670 opusfile_lib=[`find_lib "libopusfile*.dll"`]
671 ;;
672 *)
673 opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
674 if test x$opusfile_lib = x; then
675 opusfile_lib=[`find_lib "libopusfile.so.*"`]
676 fi
677 ;;
678 esac
679 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
680 if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
681 echo "-- dynamic opusfile -> $opusfile_lib"
682 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
683 else
684 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
685 fi
686 else
687 AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
688 fi
689 fi
690
691 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
692
693 OBJECTS=`echo $SOURCES`
694 DEPENDS=`echo $SOURCES`
695 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
696 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
697 $(objects)/\2.lo: \1/\2.c\\
698 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
699
700 OBJECTS_CXX=`echo $SOURCES_CXX`
701 DEPENDS_CXX=`echo $SOURCES_CXX`
702 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
703 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
704 $(objects)/\2.lo: \1/\2.cpp\\
705 \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
706 OBJECTS="$OBJECTS $OBJECTS_CXX"
707 DEPENDS="$DEPENDS $DEPENDS_CXX"
708 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
709
710 VERSION_OBJECTS=`echo $VERSION_SOURCES`
711 VERSION_DEPENDS=`echo $VERSION_SOURCES`
712 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
713 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
714 $(objects)/\2.o: \1/\2.rc\\
715 \$(WINDRES) \$< \$@,g'`
716 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
717
718 PLAYWAVE_SOURCES="$srcdir/playwave.c"
719 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
720 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
721 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
722 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
723 $(objects)/\2.lo: \1/\2.c\\
724 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
725 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
726
727 PLAYMUS_SOURCES="$srcdir/playmus.c"
728 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
729 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
730 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
731 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
732 $(objects)/\2.lo: \1/\2.c\\
733 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
734 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
735
736 dnl Expand the sources and objects needed to build the library
737 AC_SUBST(ac_aux_dir)
738 AC_SUBST(OBJECTS)
739 AC_SUBST(VERSION_OBJECTS)
740 AC_SUBST(PLAYWAVE_OBJECTS)
741 AC_SUBST(PLAYMUS_OBJECTS)
742 AC_SUBST(BUILD_CFLAGS)
743 AC_SUBST(EXTRA_CFLAGS)
744 AC_SUBST(BUILD_LDFLAGS)
745 AC_SUBST(EXTRA_LDFLAGS)
746 AC_SUBST(EXE)
747 AC_SUBST(WINDRES)
748 AC_SUBST(SDL_VERSION)
749 AC_SUBST(SDL_CFLAGS)
750 AC_SUBST(SDL_LIBS)
751
752 AC_OUTPUT([
753 ])
754 AC_CONFIG_FILES([
755 Makefile SDL2_mixer.spec SDL2_mixer.pc
756 ])
757 AC_CONFIG_COMMANDS([default],
758 [cat >>Makefile <<__EOF__
759
760 # Build rules for objects
761 -include \$(OBJECTS:.lo=.d)
762 $DEPENDS
763 $VERSION_DEPENDS
764
765 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
766 $PLAYWAVE_DEPENDS
767
768 -include \$(PLAYMUS_OBJECTS:.lo=.d)
769 $PLAYMUS_DEPENDS
770 __EOF__
771 ], [
772 DEPENDS="$DEPENDS"
773 VERSION_DEPENDS="$VERSION_DEPENDS"
774 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
775 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
776 ])
777 AC_OUTPUT
+0
-2049
effect_position.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some internally supported special effects that use SDL_mixer's
23 effect callback API. They are meant for speed over quality. :)
24 */
25
26 /* $Id$ */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "SDL.h"
33 #include "SDL_endian.h"
34 #include "SDL_mixer.h"
35 #include "mixer.h"
36
37 #define __MIX_INTERNAL_EFFECT__
38 #include "effects_internal.h"
39
40 /* profile code:
41 #include <sys/time.h>
42 #include <unistd.h>
43 struct timeval tv1;
44 struct timeval tv2;
45
46 gettimeofday(&tv1, NULL);
47
48 ... do your thing here ...
49
50 gettimeofday(&tv2, NULL);
51 printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
52 */
53
54
55 /*
56 * Positional effects...panning, distance attenuation, etc.
57 */
58
59 typedef struct _Eff_positionargs
60 {
61 volatile float left_f;
62 volatile float right_f;
63 volatile Uint8 left_u8;
64 volatile Uint8 right_u8;
65 volatile float left_rear_f;
66 volatile float right_rear_f;
67 volatile float center_f;
68 volatile float lfe_f;
69 volatile Uint8 left_rear_u8;
70 volatile Uint8 right_rear_u8;
71 volatile Uint8 center_u8;
72 volatile Uint8 lfe_u8;
73 volatile float distance_f;
74 volatile Uint8 distance_u8;
75 volatile Sint16 room_angle;
76 volatile int in_use;
77 volatile int channels;
78 } position_args;
79
80 static position_args **pos_args_array = NULL;
81 static position_args *pos_args_global = NULL;
82 static int position_channels = 0;
83
84 void _Eff_PositionDeinit(void)
85 {
86 int i;
87 for (i = 0; i < position_channels; i++) {
88 SDL_free(pos_args_array[i]);
89 }
90
91 position_channels = 0;
92
93 SDL_free(pos_args_global);
94 pos_args_global = NULL;
95 SDL_free(pos_args_array);
96 pos_args_array = NULL;
97 }
98
99
100 /* This just frees up the callback-specific data. */
101 static void SDLCALL _Eff_PositionDone(int channel, void *udata)
102 {
103 if (channel < 0) {
104 if (pos_args_global != NULL) {
105 SDL_free(pos_args_global);
106 pos_args_global = NULL;
107 }
108 }
109
110 else if (pos_args_array[channel] != NULL) {
111 SDL_free(pos_args_array[channel]);
112 pos_args_array[channel] = NULL;
113 }
114 }
115
116
117 static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata)
118 {
119 volatile position_args *args = (volatile position_args *) udata;
120 Uint8 *ptr = (Uint8 *) stream;
121 int i;
122
123 /*
124 * if there's only a mono channnel (the only way we wouldn't have
125 * a len divisible by 2 here), then left_f and right_f are always
126 * 1.0, and are therefore throwaways.
127 */
128 if (len % sizeof (Uint16) != 0) {
129 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
130 ptr++;
131 len--;
132 }
133
134 if (args->room_angle == 180)
135 for (i = 0; i < len; i += sizeof (Uint8) * 2) {
136 /* must adjust the sample so that 0 is the center */
137 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
138 * args->right_f) * args->distance_f) + 128);
139 ptr++;
140 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
141 * args->left_f) * args->distance_f) + 128);
142 ptr++;
143 }
144 else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
145 /* must adjust the sample so that 0 is the center */
146 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
147 * args->left_f) * args->distance_f) + 128);
148 ptr++;
149 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
150 * args->right_f) * args->distance_f) + 128);
151 ptr++;
152 }
153 }
154 static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata)
155 {
156 volatile position_args *args = (volatile position_args *) udata;
157 Uint8 *ptr = (Uint8 *) stream;
158 int i;
159
160 /*
161 * if there's only a mono channnel (the only way we wouldn't have
162 * a len divisible by 2 here), then left_f and right_f are always
163 * 1.0, and are therefore throwaways.
164 */
165 if (len % sizeof (Uint16) != 0) {
166 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
167 ptr++;
168 len--;
169 }
170
171 if (args->room_angle == 0)
172 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
173 /* must adjust the sample so that 0 is the center */
174 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
175 * args->left_f) * args->distance_f) + 128);
176 ptr++;
177 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
178 * args->right_f) * args->distance_f) + 128);
179 ptr++;
180 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
181 * args->left_rear_f) * args->distance_f) + 128);
182 ptr++;
183 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
184 * args->right_rear_f) * args->distance_f) + 128);
185 ptr++;
186 }
187 else if (args->room_angle == 90)
188 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
189 /* must adjust the sample so that 0 is the center */
190 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
191 * args->right_f) * args->distance_f) + 128);
192 ptr++;
193 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
194 * args->right_rear_f) * args->distance_f) + 128);
195 ptr++;
196 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
197 * args->left_f) * args->distance_f) + 128);
198 ptr++;
199 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
200 * args->left_rear_f) * args->distance_f) + 128);
201 ptr++;
202 }
203 else if (args->room_angle == 180)
204 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
205 /* must adjust the sample so that 0 is the center */
206 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
207 * args->right_rear_f) * args->distance_f) + 128);
208 ptr++;
209 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
210 * args->left_rear_f) * args->distance_f) + 128);
211 ptr++;
212 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
213 * args->right_f) * args->distance_f) + 128);
214 ptr++;
215 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
216 * args->left_f) * args->distance_f) + 128);
217 ptr++;
218 }
219 else if (args->room_angle == 270)
220 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
221 /* must adjust the sample so that 0 is the center */
222 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
223 * args->left_rear_f) * args->distance_f) + 128);
224 ptr++;
225 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
226 * args->left_f) * args->distance_f) + 128);
227 ptr++;
228 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
229 * args->right_rear_f) * args->distance_f) + 128);
230 ptr++;
231 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
232 * args->right_f) * args->distance_f) + 128);
233 ptr++;
234 }
235 }
236
237
238 static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata)
239 {
240 volatile position_args *args = (volatile position_args *) udata;
241 Uint8 *ptr = (Uint8 *) stream;
242 int i;
243
244 /*
245 * if there's only a mono channnel (the only way we wouldn't have
246 * a len divisible by 2 here), then left_f and right_f are always
247 * 1.0, and are therefore throwaways.
248 */
249 if (len % sizeof (Uint16) != 0) {
250 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
251 ptr++;
252 len--;
253 }
254
255 if (args->room_angle == 0)
256 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
257 /* must adjust the sample so that 0 is the center */
258 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
259 * args->left_f) * args->distance_f) + 128);
260 ptr++;
261 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
262 * args->right_f) * args->distance_f) + 128);
263 ptr++;
264 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
265 * args->left_rear_f) * args->distance_f) + 128);
266 ptr++;
267 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
268 * args->right_rear_f) * args->distance_f) + 128);
269 ptr++;
270 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
271 * args->center_f) * args->distance_f) + 128);
272 ptr++;
273 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
274 * args->lfe_f) * args->distance_f) + 128);
275 ptr++;
276 }
277 else if (args->room_angle == 90)
278 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
279 /* must adjust the sample so that 0 is the center */
280 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
281 * args->right_f) * args->distance_f) + 128);
282 ptr++;
283 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
284 * args->right_rear_f) * args->distance_f) + 128);
285 ptr++;
286 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
287 * args->left_f) * args->distance_f) + 128);
288 ptr++;
289 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
290 * args->left_rear_f) * args->distance_f) + 128);
291 ptr++;
292 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
293 * args->right_rear_f) * args->distance_f/2) + 128)
294 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
295 * args->right_f) * args->distance_f/2) + 128);
296 ptr++;
297 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
298 * args->lfe_f) * args->distance_f) + 128);
299 ptr++;
300 }
301 else if (args->room_angle == 180)
302 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
303 /* must adjust the sample so that 0 is the center */
304 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
305 * args->right_rear_f) * args->distance_f) + 128);
306 ptr++;
307 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
308 * args->left_rear_f) * args->distance_f) + 128);
309 ptr++;
310 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
311 * args->right_f) * args->distance_f) + 128);
312 ptr++;
313 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
314 * args->left_f) * args->distance_f) + 128);
315 ptr++;
316 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
317 * args->right_rear_f) * args->distance_f/2) + 128)
318 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
319 * args->left_rear_f) * args->distance_f/2) + 128);
320 ptr++;
321 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
322 * args->lfe_f) * args->distance_f) + 128);
323 ptr++;
324 }
325 else if (args->room_angle == 270)
326 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
327 /* must adjust the sample so that 0 is the center */
328 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
329 * args->left_rear_f) * args->distance_f) + 128);
330 ptr++;
331 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
332 * args->left_f) * args->distance_f) + 128);
333 ptr++;
334 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
335 * args->right_rear_f) * args->distance_f) + 128);
336 ptr++;
337 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
338 * args->right_f) * args->distance_f) + 128);
339 ptr++;
340 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
341 * args->left_f) * args->distance_f/2) + 128)
342 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
343 * args->left_rear_f) * args->distance_f/2) + 128);
344 ptr++;
345 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
346 * args->lfe_f) * args->distance_f) + 128);
347 ptr++;
348 }
349 }
350
351
352 /*
353 * This one runs about 10.1 times faster than the non-table version, with
354 * no loss in quality. It does, however, require 64k of memory for the
355 * lookup table. Also, this will only update position information once per
356 * call; the non-table version always checks the arguments for each sample,
357 * in case the user has called Mix_SetPanning() or whatnot again while this
358 * callback is running.
359 */
360 static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata)
361 {
362 volatile position_args *args = (volatile position_args *) udata;
363 Uint8 *ptr = (Uint8 *) stream;
364 Uint32 *p;
365 int i;
366 Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8);
367 Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8);
368 Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
369
370 if (args->room_angle == 180) {
371 Uint8 *temp = l;
372 l = r;
373 r = temp;
374 }
375 /*
376 * if there's only a mono channnel, then l[] and r[] are always
377 * volume 255, and are therefore throwaways. Still, we have to
378 * be sure not to overrun the audio buffer...
379 */
380 while (len % sizeof (Uint32) != 0) {
381 *ptr = d[l[*ptr]];
382 ptr++;
383 if (args->channels > 1) {
384 *ptr = d[r[*ptr]];
385 ptr++;
386 }
387 len -= args->channels;
388 }
389
390 p = (Uint32 *) ptr;
391
392 for (i = 0; i < len; i += sizeof (Uint32)) {
393 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
394 *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
395 (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
396 (d[l[(*p & 0x0000FF00) >> 8]] << 8) |
397 (d[r[(*p & 0x000000FF) ]] ) ;
398 #else
399 *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
400 (d[l[(*p & 0x00FF0000) >> 16]] << 16) |
401 (d[r[(*p & 0x0000FF00) >> 8]] << 8) |
402 (d[l[(*p & 0x000000FF) ]] ) ;
403 #endif
404 ++p;
405 }
406 }
407
408
409 static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata)
410 {
411 volatile position_args *args = (volatile position_args *) udata;
412 Sint8 *ptr = (Sint8 *) stream;
413 int i;
414
415 /*
416 * if there's only a mono channnel (the only way we wouldn't have
417 * a len divisible by 2 here), then left_f and right_f are always
418 * 1.0, and are therefore throwaways.
419 */
420 if (len % sizeof (Sint16) != 0) {
421 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
422 ptr++;
423 len--;
424 }
425
426 if (args->room_angle == 180)
427 for (i = 0; i < len; i += sizeof (Sint8) * 2) {
428 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
429 ptr++;
430 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
431 ptr++;
432 }
433 else
434 for (i = 0; i < len; i += sizeof (Sint8) * 2) {
435 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
436 ptr++;
437 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
438 ptr++;
439 }
440 }
441 static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata)
442 {
443 volatile position_args *args = (volatile position_args *) udata;
444 Sint8 *ptr = (Sint8 *) stream;
445 int i;
446
447 /*
448 * if there's only a mono channnel (the only way we wouldn't have
449 * a len divisible by 2 here), then left_f and right_f are always
450 * 1.0, and are therefore throwaways.
451 */
452 if (len % sizeof (Sint16) != 0) {
453 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
454 ptr++;
455 len--;
456 }
457
458 for (i = 0; i < len; i += sizeof (Sint8) * 4) {
459 switch (args->room_angle) {
460 case 0:
461 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
462 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
463 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
464 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
465 break;
466 case 90:
467 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
468 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
469 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
470 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
471 break;
472 case 180:
473 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
474 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
475 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
476 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
477 break;
478 case 270:
479 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
480 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
481 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
482 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
483 break;
484 }
485 }
486 }
487 static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata)
488 {
489 volatile position_args *args = (volatile position_args *) udata;
490 Sint8 *ptr = (Sint8 *) stream;
491 int i;
492
493 /*
494 * if there's only a mono channnel (the only way we wouldn't have
495 * a len divisible by 2 here), then left_f and right_f are always
496 * 1.0, and are therefore throwaways.
497 */
498 if (len % sizeof (Sint16) != 0) {
499 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
500 ptr++;
501 len--;
502 }
503
504 for (i = 0; i < len; i += sizeof (Sint8) * 6) {
505 switch (args->room_angle) {
506 case 0:
507 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
508 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
509 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
510 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
511 *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
512 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
513 break;
514 case 90:
515 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
516 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
517 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
518 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
519 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
520 + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++;
521 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
522 break;
523 case 180:
524 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
525 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
526 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
527 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
528 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
529 + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
530 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
531 break;
532 case 270:
533 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
534 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
535 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
536 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
537 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2)
538 + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
539 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
540 break;
541 }
542 }
543 }
544
545
546 /*
547 * This one runs about 10.1 times faster than the non-table version, with
548 * no loss in quality. It does, however, require 64k of memory for the
549 * lookup table. Also, this will only update position information once per
550 * call; the non-table version always checks the arguments for each sample,
551 * in case the user has called Mix_SetPanning() or whatnot again while this
552 * callback is running.
553 */
554 static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata)
555 {
556 volatile position_args *args = (volatile position_args *) udata;
557 Sint8 *ptr = (Sint8 *) stream;
558 Uint32 *p;
559 int i;
560 Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
561 Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
562 Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
563
564 if (args->room_angle == 180) {
565 Sint8 *temp = l;
566 l = r;
567 r = temp;
568 }
569
570
571 while (len % sizeof (Uint32) != 0) {
572 *ptr = d[l[*ptr]];
573 ptr++;
574 if (args->channels > 1) {
575 *ptr = d[r[*ptr]];
576 ptr++;
577 }
578 len -= args->channels;
579 }
580
581 p = (Uint32 *) ptr;
582
583 for (i = 0; i < len; i += sizeof (Uint32)) {
584 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
585 *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
586 (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
587 (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
588 (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
589 #else
590 *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
591 (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
592 (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
593 (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
594 #endif
595 ++p;
596 }
597
598
599 }
600
601
602 /* !!! FIXME : Optimize the code for 16-bit samples? */
603
604 static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
605 {
606 volatile position_args *args = (volatile position_args *) udata;
607 Uint16 *ptr = (Uint16 *) stream;
608 int i;
609
610 for (i = 0; i < len; i += sizeof (Uint16) * 2) {
611 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
612 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
613
614 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
615 * args->distance_f) + 32768);
616 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
617 * args->distance_f) + 32768);
618
619 if (args->room_angle == 180) {
620 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
621 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
622 }
623 else {
624 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
625 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
626 }
627 }
628 }
629 static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
630 {
631 volatile position_args *args = (volatile position_args *) udata;
632 Uint16 *ptr = (Uint16 *) stream;
633 int i;
634
635 for (i = 0; i < len; i += sizeof (Uint16) * 4) {
636 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
637 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
638 Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
639 Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
640
641 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
642 * args->distance_f) + 32768);
643 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
644 * args->distance_f) + 32768);
645 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
646 * args->distance_f) + 32768);
647 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
648 * args->distance_f) + 32768);
649
650 switch (args->room_angle) {
651 case 0:
652 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
653 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
654 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
655 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
656 break;
657 case 90:
658 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
659 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
660 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
661 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
662 break;
663 case 180:
664 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
665 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
666 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
667 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
668 break;
669 case 270:
670 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
671 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
672 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
673 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
674 break;
675 }
676 }
677 }
678 static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
679 {
680 volatile position_args *args = (volatile position_args *) udata;
681 Uint16 *ptr = (Uint16 *) stream;
682 int i;
683
684 for (i = 0; i < len; i += sizeof (Uint16) * 6) {
685 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
686 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
687 Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
688 Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
689 Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
690 Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
691
692 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
693 * args->distance_f) + 32768);
694 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
695 * args->distance_f) + 32768);
696 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
697 * args->distance_f) + 32768);
698 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
699 * args->distance_f) + 32768);
700 Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
701 * args->distance_f) + 32768);
702 Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
703 * args->distance_f) + 32768);
704
705 switch (args->room_angle) {
706 case 0:
707 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
708 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
709 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
710 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
711 *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
712 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
713 break;
714 case 90:
715 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
716 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
717 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
718 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
719 *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
720 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
721 break;
722 case 180:
723 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
724 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
725 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
726 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
727 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
728 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
729 break;
730 case 270:
731 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
732 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
733 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
734 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
735 *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
736 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
737 break;
738 }
739 }
740 }
741
742 static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
743 {
744 /* 16 signed bits (lsb) * 2 channels. */
745 volatile position_args *args = (volatile position_args *) udata;
746 Sint16 *ptr = (Sint16 *) stream;
747 int i;
748
749 #if 0
750 if (len % (sizeof(Sint16) * 2)) {
751 fprintf(stderr,"Not an even number of frames! len=%d\n", len);
752 return;
753 }
754 #endif
755
756 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
757 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
758 args->left_f) * args->distance_f);
759 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
760 args->right_f) * args->distance_f);
761 if (args->room_angle == 180) {
762 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
763 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
764 }
765 else {
766 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
767 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
768 }
769 }
770 }
771 static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
772 {
773 /* 16 signed bits (lsb) * 4 channels. */
774 volatile position_args *args = (volatile position_args *) udata;
775 Sint16 *ptr = (Sint16 *) stream;
776 int i;
777
778 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
779 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
780 args->left_f) * args->distance_f);
781 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
782 args->right_f) * args->distance_f);
783 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
784 args->left_rear_f) * args->distance_f);
785 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
786 args->right_rear_f) * args->distance_f);
787 switch (args->room_angle) {
788 case 0:
789 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
790 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
791 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
792 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
793 break;
794 case 90:
795 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
796 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
797 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
798 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
799 break;
800 case 180:
801 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
802 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
803 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
804 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
805 break;
806 case 270:
807 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
808 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
809 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
810 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
811 break;
812 }
813 }
814 }
815
816 static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata)
817 {
818 /* 16 signed bits (lsb) * 6 channels. */
819 volatile position_args *args = (volatile position_args *) udata;
820 Sint16 *ptr = (Sint16 *) stream;
821 int i;
822
823 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
824 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
825 args->left_f) * args->distance_f);
826 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
827 args->right_f) * args->distance_f);
828 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
829 args->left_rear_f) * args->distance_f);
830 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *
831 args->right_rear_f) * args->distance_f);
832 Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *
833 args->center_f) * args->distance_f);
834 Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *
835 args->lfe_f) * args->distance_f);
836 switch (args->room_angle) {
837 case 0:
838 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
839 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
840 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
841 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
842 *(ptr++) = (Sint16) SDL_SwapLE16(swapce);
843 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
844 break;
845 case 90:
846 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
847 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
848 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
849 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
850 *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;
851 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
852 break;
853 case 180:
854 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
855 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
856 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
857 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
858 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
859 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
860 break;
861 case 270:
862 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
863 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
864 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
865 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
866 *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
867 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
868 break;
869 }
870 }
871 }
872
873 static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
874 {
875 /* 16 signed bits (lsb) * 2 channels. */
876 volatile position_args *args = (volatile position_args *) udata;
877 Uint16 *ptr = (Uint16 *) stream;
878 int i;
879
880 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
881 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
882 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
883
884 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
885 * args->distance_f) + 32768);
886 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
887 * args->distance_f) + 32768);
888
889 if (args->room_angle == 180) {
890 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
891 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
892 }
893 else {
894 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
895 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
896 }
897 }
898 }
899 static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
900 {
901 /* 16 signed bits (lsb) * 4 channels. */
902 volatile position_args *args = (volatile position_args *) udata;
903 Uint16 *ptr = (Uint16 *) stream;
904 int i;
905
906 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
907 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
908 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
909 Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
910 Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
911
912 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
913 * args->distance_f) + 32768);
914 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
915 * args->distance_f) + 32768);
916 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
917 * args->distance_f) + 32768);
918 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
919 * args->distance_f) + 32768);
920
921 switch (args->room_angle) {
922 case 0:
923 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
924 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
925 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
926 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
927 break;
928 case 90:
929 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
930 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
931 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
932 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
933 break;
934 case 180:
935 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
936 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
937 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
938 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
939 break;
940 case 270:
941 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
942 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
943 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
944 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
945 break;
946 }
947 }
948 }
949 static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
950 {
951 /* 16 signed bits (lsb) * 6 channels. */
952 volatile position_args *args = (volatile position_args *) udata;
953 Uint16 *ptr = (Uint16 *) stream;
954 int i;
955
956 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
957 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
958 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
959 Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
960 Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
961 Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
962 Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
963
964 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
965 * args->distance_f) + 32768);
966 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
967 * args->distance_f) + 32768);
968 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
969 * args->distance_f) + 32768);
970 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
971 * args->distance_f) + 32768);
972 Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
973 * args->distance_f) + 32768);
974 Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
975 * args->distance_f) + 32768);
976
977 switch (args->room_angle) {
978 case 0:
979 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
980 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
981 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
982 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
983 *(ptr++) = (Uint16) SDL_SwapBE16(swapce);
984 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
985 break;
986 case 90:
987 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
988 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
989 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
990 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
991 *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
992 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
993 break;
994 case 180:
995 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
996 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
997 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
998 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
999 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
1000 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1001 break;
1002 case 270:
1003 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
1004 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
1005 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
1006 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
1007 *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
1008 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1009 break;
1010 }
1011 }
1012 }
1013
1014 static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
1015 {
1016 /* 16 signed bits (lsb) * 2 channels. */
1017 volatile position_args *args = (volatile position_args *) udata;
1018 Sint16 *ptr = (Sint16 *) stream;
1019 int i;
1020
1021 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
1022 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1023 args->left_f) * args->distance_f);
1024 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1025 args->right_f) * args->distance_f);
1026 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1027 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1028 }
1029 }
1030 static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata)
1031 {
1032 /* 16 signed bits (lsb) * 4 channels. */
1033 volatile position_args *args = (volatile position_args *) udata;
1034 Sint16 *ptr = (Sint16 *) stream;
1035 int i;
1036
1037 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
1038 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1039 args->left_f) * args->distance_f);
1040 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1041 args->right_f) * args->distance_f);
1042 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
1043 args->left_rear_f) * args->distance_f);
1044 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
1045 args->right_rear_f) * args->distance_f);
1046 switch (args->room_angle) {
1047 case 0:
1048 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1049 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1050 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1051 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1052 break;
1053 case 90:
1054 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1055 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1056 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1057 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1058 break;
1059 case 180:
1060 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1061 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1062 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1063 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1064 break;
1065 case 270:
1066 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1067 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1068 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1069 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1070 break;
1071 }
1072 }
1073 }
1074 static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata)
1075 {
1076 /* 16 signed bits (lsb) * 6 channels. */
1077 volatile position_args *args = (volatile position_args *) udata;
1078 Sint16 *ptr = (Sint16 *) stream;
1079 int i;
1080
1081 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
1082 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1083 args->left_f) * args->distance_f);
1084 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1085 args->right_f) * args->distance_f);
1086 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
1087 args->left_rear_f) * args->distance_f);
1088 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
1089 args->right_rear_f) * args->distance_f);
1090 Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) *
1091 args->center_f) * args->distance_f);
1092 Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) *
1093 args->lfe_f) * args->distance_f);
1094
1095 switch (args->room_angle) {
1096 case 0:
1097 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1098 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1099 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1100 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1101 *(ptr++) = (Sint16) SDL_SwapBE16(swapce);
1102 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1103 break;
1104 case 90:
1105 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1106 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1107 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1108 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1109 *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2;
1110 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1111 break;
1112 case 180:
1113 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1114 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1115 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1116 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1117 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
1118 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1119 break;
1120 case 270:
1121 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1122 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1123 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1124 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1125 *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
1126 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1127 break;
1128 }
1129 }
1130 }
1131
1132 static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata)
1133 {
1134 /* 32 signed bits (lsb) * 2 channels. */
1135 volatile position_args *args = (volatile position_args *) udata;
1136 Sint32 *ptr = (Sint32 *) stream;
1137 int i;
1138
1139 #if 0
1140 if (len % (sizeof(Sint32) * 2)) {
1141 fprintf(stderr,"Not an even number of frames! len=%d\n", len);
1142 return;
1143 }
1144 #endif
1145
1146 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
1147 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1148 args->left_f) * args->distance_f);
1149 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1150 args->right_f) * args->distance_f);
1151 if (args->room_angle == 180) {
1152 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1153 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1154 }
1155 else {
1156 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1157 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1158 }
1159 }
1160 }
1161 static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata)
1162 {
1163 /* 32 signed bits (lsb) * 4 channels. */
1164 volatile position_args *args = (volatile position_args *) udata;
1165 Sint32 *ptr = (Sint32 *) stream;
1166 int i;
1167
1168 for (i = 0; i < len; i += sizeof (Sint32) * 4) {
1169 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1170 args->left_f) * args->distance_f);
1171 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1172 args->right_f) * args->distance_f);
1173 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1174 args->left_rear_f) * args->distance_f);
1175 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
1176 args->right_rear_f) * args->distance_f);
1177 switch (args->room_angle) {
1178 case 0:
1179 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1180 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1181 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1182 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1183 break;
1184 case 90:
1185 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1186 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1187 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1188 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1189 break;
1190 case 180:
1191 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1192 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1193 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1194 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1195 break;
1196 case 270:
1197 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1198 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1199 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1200 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1201 break;
1202 }
1203 }
1204 }
1205
1206 static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata)
1207 {
1208 /* 32 signed bits (lsb) * 6 channels. */
1209 volatile position_args *args = (volatile position_args *) udata;
1210 Sint32 *ptr = (Sint32 *) stream;
1211 int i;
1212
1213 for (i = 0; i < len; i += sizeof (Sint32) * 6) {
1214 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1215 args->left_f) * args->distance_f);
1216 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1217 args->right_f) * args->distance_f);
1218 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
1219 args->left_rear_f) * args->distance_f);
1220 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) *
1221 args->right_rear_f) * args->distance_f);
1222 Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) *
1223 args->center_f) * args->distance_f);
1224 Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) *
1225 args->lfe_f) * args->distance_f);
1226 switch (args->room_angle) {
1227 case 0:
1228 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1229 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1230 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1231 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1232 *(ptr++) = (Sint32) SDL_SwapLE32(swapce);
1233 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1234 break;
1235 case 90:
1236 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1237 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1238 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1239 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1240 *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2;
1241 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1242 break;
1243 case 180:
1244 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1245 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1246 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1247 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1248 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
1249 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1250 break;
1251 case 270:
1252 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1253 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1254 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1255 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1256 *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
1257 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1258 break;
1259 }
1260 }
1261 }
1262
1263 static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata)
1264 {
1265 /* 32 signed bits (lsb) * 2 channels. */
1266 volatile position_args *args = (volatile position_args *) udata;
1267 Sint32 *ptr = (Sint32 *) stream;
1268 int i;
1269
1270 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
1271 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1272 args->left_f) * args->distance_f);
1273 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1274 args->right_f) * args->distance_f);
1275 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1276 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1277 }
1278 }
1279 static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata)
1280 {
1281 /* 32 signed bits (lsb) * 4 channels. */
1282 volatile position_args *args = (volatile position_args *) udata;
1283 Sint32 *ptr = (Sint32 *) stream;
1284 int i;
1285
1286 for (i = 0; i < len; i += sizeof (Sint32) * 4) {
1287 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1288 args->left_f) * args->distance_f);
1289 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1290 args->right_f) * args->distance_f);
1291 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
1292 args->left_rear_f) * args->distance_f);
1293 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
1294 args->right_rear_f) * args->distance_f);
1295 switch (args->room_angle) {
1296 case 0:
1297 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1298 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1299 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1300 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1301 break;
1302 case 90:
1303 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1304 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1305 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1306 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1307 break;
1308 case 180:
1309 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1310 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1311 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1312 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1313 break;
1314 case 270:
1315 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1316 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1317 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1318 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1319 break;
1320 }
1321 }
1322 }
1323 static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata)
1324 {
1325 /* 32 signed bits (lsb) * 6 channels. */
1326 volatile position_args *args = (volatile position_args *) udata;
1327 Sint32 *ptr = (Sint32 *) stream;
1328 int i;
1329
1330 for (i = 0; i < len; i += sizeof (Sint32) * 6) {
1331 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1332 args->left_f) * args->distance_f);
1333 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1334 args->right_f) * args->distance_f);
1335 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
1336 args->left_rear_f) * args->distance_f);
1337 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
1338 args->right_rear_f) * args->distance_f);
1339 Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) *
1340 args->center_f) * args->distance_f);
1341 Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) *
1342 args->lfe_f) * args->distance_f);
1343
1344 switch (args->room_angle) {
1345 case 0:
1346 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1347 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1348 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1349 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1350 *(ptr++) = (Sint32) SDL_SwapBE32(swapce);
1351 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1352 break;
1353 case 90:
1354 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1355 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1356 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1357 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1358 *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2;
1359 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1360 break;
1361 case 180:
1362 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1363 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1364 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1365 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1366 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
1367 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1368 break;
1369 case 270:
1370 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1371 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1372 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1373 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1374 *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
1375 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1376 break;
1377 }
1378 }
1379 }
1380
1381 static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata)
1382 {
1383 /* float * 2 channels. */
1384 volatile position_args *args = (volatile position_args *) udata;
1385 float *ptr = (float *) stream;
1386 int i;
1387
1388 for (i = 0; i < len; i += sizeof (float) * 2) {
1389 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1390 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1391 *(ptr++) = swapl;
1392 *(ptr++) = swapr;
1393 }
1394 }
1395 static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata)
1396 {
1397 /* float * 4 channels. */
1398 volatile position_args *args = (volatile position_args *) udata;
1399 float *ptr = (float *) stream;
1400 int i;
1401
1402 for (i = 0; i < len; i += sizeof (float) * 4) {
1403 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1404 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1405 float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
1406 float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
1407 switch (args->room_angle) {
1408 case 0:
1409 *(ptr++) = swapl;
1410 *(ptr++) = swapr;
1411 *(ptr++) = swaplr;
1412 *(ptr++) = swaprr;
1413 break;
1414 case 90:
1415 *(ptr++) = swapr;
1416 *(ptr++) = swaprr;
1417 *(ptr++) = swapl;
1418 *(ptr++) = swaplr;
1419 break;
1420 case 180:
1421 *(ptr++) = swaprr;
1422 *(ptr++) = swaplr;
1423 *(ptr++) = swapr;
1424 *(ptr++) = swapl;
1425 break;
1426 case 270:
1427 *(ptr++) = swaplr;
1428 *(ptr++) = swapl;
1429 *(ptr++) = swaprr;
1430 *(ptr++) = swapr;
1431 break;
1432 }
1433 }
1434 }
1435 static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata)
1436 {
1437 /* float * 6 channels. */
1438 volatile position_args *args = (volatile position_args *) udata;
1439 float *ptr = (float *) stream;
1440 int i;
1441
1442 for (i = 0; i < len; i += sizeof (float) * 6) {
1443 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1444 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1445 float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
1446 float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
1447 float swapce = ((*(ptr+4) * args->center_f) * args->distance_f);
1448 float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f);
1449
1450 switch (args->room_angle) {
1451 case 0:
1452 *(ptr++) = swapl;
1453 *(ptr++) = swapr;
1454 *(ptr++) = swaplr;
1455 *(ptr++) = swaprr;
1456 *(ptr++) = swapce;
1457 *(ptr++) = swapwf;
1458 break;
1459 case 90:
1460 *(ptr++) = swapr;
1461 *(ptr++) = swaprr;
1462 *(ptr++) = swapl;
1463 *(ptr++) = swaplr;
1464 *(ptr++) = swapr/2.0f + swaprr/2.0f;
1465 *(ptr++) = swapwf;
1466 break;
1467 case 180:
1468 *(ptr++) = swaprr;
1469 *(ptr++) = swaplr;
1470 *(ptr++) = swapr;
1471 *(ptr++) = swapl;
1472 *(ptr++) = swaprr/2.0f + swaplr/2.0f;
1473 *(ptr++) = swapwf;
1474 break;
1475 case 270:
1476 *(ptr++) = swaplr;
1477 *(ptr++) = swapl;
1478 *(ptr++) = swaprr;
1479 *(ptr++) = swapr;
1480 *(ptr++) = swapl/2.0f + swaplr/2.0f;
1481 *(ptr++) = swapwf;
1482 break;
1483 }
1484 }
1485 }
1486
1487 static void init_position_args(position_args *args)
1488 {
1489 SDL_memset(args, '\0', sizeof (position_args));
1490 args->in_use = 0;
1491 args->room_angle = 0;
1492 args->left_u8 = args->right_u8 = args->distance_u8 = 255;
1493 args->left_f = args->right_f = args->distance_f = 1.0f;
1494 args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255;
1495 args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f;
1496 Mix_QuerySpec(NULL, NULL, (int *) &args->channels);
1497 }
1498
1499
1500 static position_args *get_position_arg(int channel)
1501 {
1502 void *rc;
1503 int i;
1504
1505 if (channel < 0) {
1506 if (pos_args_global == NULL) {
1507 pos_args_global = SDL_malloc(sizeof (position_args));
1508 if (pos_args_global == NULL) {
1509 Mix_SetError("Out of memory");
1510 return(NULL);
1511 }
1512 init_position_args(pos_args_global);
1513 }
1514
1515 return(pos_args_global);
1516 }
1517
1518 if (channel >= position_channels) {
1519 rc = SDL_realloc(pos_args_array, (channel + 1) * sizeof (position_args *));
1520 if (rc == NULL) {
1521 Mix_SetError("Out of memory");
1522 return(NULL);
1523 }
1524 pos_args_array = (position_args **) rc;
1525 for (i = position_channels; i <= channel; i++) {
1526 pos_args_array[i] = NULL;
1527 }
1528 position_channels = channel + 1;
1529 }
1530
1531 if (pos_args_array[channel] == NULL) {
1532 pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
1533 if (pos_args_array[channel] == NULL) {
1534 Mix_SetError("Out of memory");
1535 return(NULL);
1536 }
1537 init_position_args(pos_args_array[channel]);
1538 }
1539
1540 return(pos_args_array[channel]);
1541 }
1542
1543
1544 static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
1545 {
1546 Mix_EffectFunc_t f = NULL;
1547
1548 switch (format) {
1549 case AUDIO_U8:
1550 switch (channels) {
1551 case 1:
1552 case 2:
1553 f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 :
1554 _Eff_position_u8;
1555 break;
1556 case 4:
1557 f = _Eff_position_u8_c4;
1558 break;
1559 case 6:
1560 f = _Eff_position_u8_c6;
1561 break;
1562 default:
1563 Mix_SetError("Unsupported audio channels");
1564 break;
1565 }
1566 break;
1567
1568 case AUDIO_S8:
1569 switch (channels) {
1570 case 1:
1571 case 2:
1572 f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 :
1573 _Eff_position_s8;
1574 break;
1575 case 4:
1576 f = _Eff_position_s8_c4;
1577 break;
1578 case 6:
1579 f = _Eff_position_s8_c6;
1580 break;
1581 default:
1582 Mix_SetError("Unsupported audio channels");
1583 break;
1584 }
1585 break;
1586
1587 case AUDIO_U16LSB:
1588 switch (channels) {
1589 case 1:
1590 case 2:
1591 f = _Eff_position_u16lsb;
1592 break;
1593 case 4:
1594 f = _Eff_position_u16lsb_c4;
1595 break;
1596 case 6:
1597 f = _Eff_position_u16lsb_c6;
1598 break;
1599 default:
1600 Mix_SetError("Unsupported audio channels");
1601 break;
1602 }
1603 break;
1604
1605 case AUDIO_S16LSB:
1606 switch (channels) {
1607 case 1:
1608 case 2:
1609 f = _Eff_position_s16lsb;
1610 break;
1611 case 4:
1612 f = _Eff_position_s16lsb_c4;
1613 break;
1614 case 6:
1615 f = _Eff_position_s16lsb_c6;
1616 break;
1617 default:
1618 Mix_SetError("Unsupported audio channels");
1619 break;
1620 }
1621 break;
1622
1623 case AUDIO_U16MSB:
1624 switch (channels) {
1625 case 1:
1626 case 2:
1627 f = _Eff_position_u16msb;
1628 break;
1629 case 4:
1630 f = _Eff_position_u16msb_c4;
1631 break;
1632 case 6:
1633 f = _Eff_position_u16msb_c6;
1634 break;
1635 default:
1636 Mix_SetError("Unsupported audio channels");
1637 break;
1638 }
1639 break;
1640
1641 case AUDIO_S16MSB:
1642 switch (channels) {
1643 case 1:
1644 case 2:
1645 f = _Eff_position_s16msb;
1646 break;
1647 case 4:
1648 f = _Eff_position_s16msb_c4;
1649 break;
1650 case 6:
1651 f = _Eff_position_s16msb_c6;
1652 break;
1653 default:
1654 Mix_SetError("Unsupported audio channels");
1655 break;
1656 }
1657 break;
1658
1659 case AUDIO_S32MSB:
1660 switch (channels) {
1661 case 1:
1662 case 2:
1663 f = _Eff_position_s32msb;
1664 break;
1665 case 4:
1666 f = _Eff_position_s32msb_c4;
1667 break;
1668 case 6:
1669 f = _Eff_position_s32msb_c6;
1670 break;
1671 default:
1672 Mix_SetError("Unsupported audio channels");
1673 break;
1674 }
1675 break;
1676
1677 case AUDIO_S32LSB:
1678 switch (channels) {
1679 case 1:
1680 case 2:
1681 f = _Eff_position_s32lsb;
1682 break;
1683 case 4:
1684 f = _Eff_position_s32lsb_c4;
1685 break;
1686 case 6:
1687 f = _Eff_position_s32lsb_c6;
1688 break;
1689 default:
1690 Mix_SetError("Unsupported audio channels");
1691 break;
1692 }
1693 break;
1694
1695 case AUDIO_F32SYS:
1696 switch (channels) {
1697 case 1:
1698 case 2:
1699 f = _Eff_position_f32sys;
1700 break;
1701 case 4:
1702 f = _Eff_position_f32sys_c4;
1703 break;
1704 case 6:
1705 f = _Eff_position_f32sys_c6;
1706 break;
1707 default:
1708 Mix_SetError("Unsupported audio channels");
1709 break;
1710 }
1711 break;
1712
1713 default:
1714 Mix_SetError("Unsupported audio format");
1715 break;
1716 }
1717
1718 return(f);
1719 }
1720
1721 static Uint8 speaker_amplitude[6];
1722
1723 static void set_amplitudes(int channels, int angle, int room_angle)
1724 {
1725 int left = 255, right = 255;
1726 int left_rear = 255, right_rear = 255, center = 255;
1727
1728 angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */
1729
1730 if (channels == 2)
1731 {
1732 /*
1733 * We only attenuate by position if the angle falls on the far side
1734 * of center; That is, an angle that's due north would not attenuate
1735 * either channel. Due west attenuates the right channel to 0.0, and
1736 * due east attenuates the left channel to 0.0. Slightly east of
1737 * center attenuates the left channel a little, and the right channel
1738 * not at all. I think of this as occlusion by one's own head. :)
1739 *
1740 * ...so, we split our angle circle into four quadrants...
1741 */
1742 if (angle < 90) {
1743 left = 255 - ((int) (255.0f * (((float) angle) / 89.0f)));
1744 } else if (angle < 180) {
1745 left = (int) (255.0f * (((float) (angle - 90)) / 89.0f));
1746 } else if (angle < 270) {
1747 right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f)));
1748 } else {
1749 right = (int) (255.0f * (((float) (angle - 270)) / 89.0f));
1750 }
1751 }
1752
1753 if (channels == 4 || channels == 6)
1754 {
1755 /*
1756 * An angle that's due north does not attenuate the center channel.
1757 * An angle in the first quadrant, 0-90, does not attenuate the RF.
1758 *
1759 * ...so, we split our angle circle into 8 ...
1760 *
1761 * CE
1762 * 0
1763 * LF | RF
1764 * |
1765 * 270<-------|----------->90
1766 * |
1767 * LR | RR
1768 * 180
1769 *
1770 */
1771 if (angle < 45) {
1772 left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
1773 left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f)));
1774 right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f)));
1775 } else if (angle < 90) {
1776 center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
1777 left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
1778 left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f)));
1779 right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f)));
1780 } else if (angle < 135) {
1781 center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
1782 left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f)));
1783 right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
1784 left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
1785 } else if (angle < 180) {
1786 center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f)));
1787 left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f)));
1788 right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
1789 left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
1790 } else if (angle < 225) {
1791 center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f)));
1792 left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
1793 right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f)));
1794 right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
1795 } else if (angle < 270) {
1796 center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
1797 left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
1798 right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f)));
1799 right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
1800 } else if (angle < 315) {
1801 center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
1802 right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
1803 left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
1804 right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f)));
1805 } else {
1806 right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
1807 left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
1808 right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f)));
1809 }
1810 }
1811
1812 if (left < 0) left = 0; if (left > 255) left = 255;
1813 if (right < 0) right = 0; if (right > 255) right = 255;
1814 if (left_rear < 0) left_rear = 0; if (left_rear > 255) left_rear = 255;
1815 if (right_rear < 0) right_rear = 0; if (right_rear > 255) right_rear = 255;
1816 if (center < 0) center = 0; if (center > 255) center = 255;
1817
1818 if (room_angle == 90) {
1819 speaker_amplitude[0] = (Uint8)left_rear;
1820 speaker_amplitude[1] = (Uint8)left;
1821 speaker_amplitude[2] = (Uint8)right_rear;
1822 speaker_amplitude[3] = (Uint8)right;
1823 }
1824 else if (room_angle == 180) {
1825 if (channels == 2) {
1826 speaker_amplitude[0] = (Uint8)right;
1827 speaker_amplitude[1] = (Uint8)left;
1828 }
1829 else {
1830 speaker_amplitude[0] = (Uint8)right_rear;
1831 speaker_amplitude[1] = (Uint8)left_rear;
1832 speaker_amplitude[2] = (Uint8)right;
1833 speaker_amplitude[3] = (Uint8)left;
1834 }
1835 }
1836 else if (room_angle == 270) {
1837 speaker_amplitude[0] = (Uint8)right;
1838 speaker_amplitude[1] = (Uint8)right_rear;
1839 speaker_amplitude[2] = (Uint8)left;
1840 speaker_amplitude[3] = (Uint8)left_rear;
1841 }
1842 else {
1843 speaker_amplitude[0] = (Uint8)left;
1844 speaker_amplitude[1] = (Uint8)right;
1845 speaker_amplitude[2] = (Uint8)left_rear;
1846 speaker_amplitude[3] = (Uint8)right_rear;
1847 }
1848 speaker_amplitude[4] = (Uint8)center;
1849 speaker_amplitude[5] = 255;
1850 }
1851
1852 int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
1853
1854 int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
1855 {
1856 Mix_EffectFunc_t f = NULL;
1857 int channels;
1858 Uint16 format;
1859 position_args *args = NULL;
1860 int retval = 1;
1861
1862 Mix_QuerySpec(NULL, &format, &channels);
1863
1864 if (channels != 2 && channels != 4 && channels != 6) /* it's a no-op; we call that successful. */
1865 return(1);
1866
1867 if (channels > 2) {
1868 /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */
1869 /* left = 255 => angle = -90; left = 0 => angle = +89 */
1870 int angle = 0;
1871 if ((left != 255) || (right != 255)) {
1872 angle = (int)left;
1873 angle = 127 - angle;
1874 angle = -angle;
1875 angle = angle * 90 / 128; /* Make it larger for more effect? */
1876 }
1877 return(Mix_SetPosition(channel, angle, 0));
1878 }
1879
1880 f = get_position_effect_func(format, channels);
1881 if (f == NULL)
1882 return(0);
1883
1884 Mix_LockAudio();
1885 args = get_position_arg(channel);
1886 if (!args) {
1887 Mix_UnlockAudio();
1888 return(0);
1889 }
1890
1891 /* it's a no-op; unregister the effect, if it's registered. */
1892 if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
1893 if (args->in_use) {
1894 retval = _Mix_UnregisterEffect_locked(channel, f);
1895 Mix_UnlockAudio();
1896 return(retval);
1897 } else {
1898 Mix_UnlockAudio();
1899 return(1);
1900 }
1901 }
1902
1903 args->left_u8 = left;
1904 args->left_f = ((float) left) / 255.0f;
1905 args->right_u8 = right;
1906 args->right_f = ((float) right) / 255.0f;
1907 args->room_angle = 0;
1908
1909 if (!args->in_use) {
1910 args->in_use = 1;
1911 retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args);
1912 }
1913
1914 Mix_UnlockAudio();
1915 return(retval);
1916 }
1917
1918
1919 int Mix_SetDistance(int channel, Uint8 distance)
1920 {
1921 Mix_EffectFunc_t f = NULL;
1922 Uint16 format;
1923 position_args *args = NULL;
1924 int channels;
1925 int retval = 1;
1926
1927 Mix_QuerySpec(NULL, &format, &channels);
1928 f = get_position_effect_func(format, channels);
1929 if (f == NULL)
1930 return(0);
1931
1932 Mix_LockAudio();
1933 args = get_position_arg(channel);
1934 if (!args) {
1935 Mix_UnlockAudio();
1936 return(0);
1937 }
1938
1939 distance = 255 - distance; /* flip it to our scale. */
1940
1941 /* it's a no-op; unregister the effect, if it's registered. */
1942 if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
1943 if (args->in_use) {
1944 retval = _Mix_UnregisterEffect_locked(channel, f);
1945 Mix_UnlockAudio();
1946 return(retval);
1947 } else {
1948 Mix_UnlockAudio();
1949 return(1);
1950 }
1951 }
1952
1953 args->distance_u8 = distance;
1954 args->distance_f = ((float) distance) / 255.0f;
1955 if (!args->in_use) {
1956 args->in_use = 1;
1957 retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
1958 }
1959
1960 Mix_UnlockAudio();
1961 return(retval);
1962 }
1963
1964
1965 int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
1966 {
1967 Mix_EffectFunc_t f = NULL;
1968 Uint16 format;
1969 int channels;
1970 position_args *args = NULL;
1971 Sint16 room_angle = 0;
1972 int retval = 1;
1973
1974 Mix_QuerySpec(NULL, &format, &channels);
1975 f = get_position_effect_func(format, channels);
1976 if (f == NULL)
1977 return(0);
1978
1979 angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */
1980
1981 Mix_LockAudio();
1982 args = get_position_arg(channel);
1983 if (!args) {
1984 Mix_UnlockAudio();
1985 return(0);
1986 }
1987
1988 /* it's a no-op; unregister the effect, if it's registered. */
1989 if ((!distance) && (!angle)) {
1990 if (args->in_use) {
1991 retval = _Mix_UnregisterEffect_locked(channel, f);
1992 Mix_UnlockAudio();
1993 return(retval);
1994 } else {
1995 Mix_UnlockAudio();
1996 return(1);
1997 }
1998 }
1999
2000 if (channels == 2)
2001 {
2002 if (angle > 180)
2003 room_angle = 180; /* exchange left and right channels */
2004 else room_angle = 0;
2005 }
2006
2007 if (channels == 4 || channels == 6)
2008 {
2009 if (angle > 315) room_angle = 0;
2010 else if (angle > 225) room_angle = 270;
2011 else if (angle > 135) room_angle = 180;
2012 else if (angle > 45) room_angle = 90;
2013 else room_angle = 0;
2014 }
2015
2016
2017 distance = 255 - distance; /* flip it to scale Mix_SetDistance() uses. */
2018
2019 set_amplitudes(channels, angle, room_angle);
2020
2021 args->left_u8 = speaker_amplitude[0];
2022 args->left_f = ((float) speaker_amplitude[0]) / 255.0f;
2023 args->right_u8 = speaker_amplitude[1];
2024 args->right_f = ((float) speaker_amplitude[1]) / 255.0f;
2025 args->left_rear_u8 = speaker_amplitude[2];
2026 args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f;
2027 args->right_rear_u8 = speaker_amplitude[3];
2028 args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f;
2029 args->center_u8 = speaker_amplitude[4];
2030 args->center_f = ((float) speaker_amplitude[4]) / 255.0f;
2031 args->lfe_u8 = speaker_amplitude[5];
2032 args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f;
2033 args->distance_u8 = distance;
2034 args->distance_f = ((float) distance) / 255.0f;
2035 args->room_angle = room_angle;
2036 if (!args->in_use) {
2037 args->in_use = 1;
2038 retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
2039 }
2040
2041 Mix_UnlockAudio();
2042 return(retval);
2043 }
2044
2045
2046 /* end of effects_position.c ... */
2047
2048 /* vi: set ts=4 sw=4 expandtab: */
+0
-146
effect_stereoreverse.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some internally supported special effects that use SDL_mixer's
23 effect callback API. They are meant for speed over quality. :)
24 */
25
26 /* $Id$ */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30
31 #include "SDL.h"
32 #include "SDL_mixer.h"
33
34 #define __MIX_INTERNAL_EFFECT__
35 #include "effects_internal.h"
36
37 /* profile code:
38 #include <sys/time.h>
39 #include <unistd.h>
40 struct timeval tv1;
41 struct timeval tv2;
42
43 gettimeofday(&tv1, NULL);
44
45 ... do your thing here ...
46
47 gettimeofday(&tv2, NULL);
48 printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
49 */
50
51
52
53 /*
54 * Stereo reversal effect...this one's pretty straightforward...
55 */
56
57 static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata)
58 {
59 /* 16 bits * 2 channels. */
60 Uint32 *ptr = (Uint32 *) stream;
61 Uint32 tmp;
62 int i;
63
64 for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) {
65 tmp = ptr[0];
66 ptr[0] = ptr[1];
67 ptr[1] = tmp;
68 }
69 }
70
71
72 static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata)
73 {
74 /* 16 bits * 2 channels. */
75 Uint32 *ptr = (Uint32 *) stream;
76 int i;
77
78 for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
79 *ptr = (((*ptr) & 0xFFFF0000) >> 16) | (((*ptr) & 0x0000FFFF) << 16);
80 }
81 }
82
83
84 static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata)
85 {
86 /* 8 bits * 2 channels. */
87 Uint32 *ptr = (Uint32 *) stream;
88 int i;
89
90 /* get the last two bytes if len is not divisible by four... */
91 if (len % sizeof (Uint32) != 0) {
92 Uint16 *p = (Uint16 *) (((Uint8 *) stream) + (len - 2));
93 *p = (Uint16)((((*p) & 0xFF00) >> 8) | (((*ptr) & 0x00FF) << 8));
94 len -= 2;
95 }
96
97 for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
98 *ptr = (((*ptr) & 0x0000FF00) >> 8) | (((*ptr) & 0x000000FF) << 8) |
99 (((*ptr) & 0xFF000000) >> 8) | (((*ptr) & 0x00FF0000) << 8);
100 }
101 }
102
103
104 int Mix_SetReverseStereo(int channel, int flip)
105 {
106 Mix_EffectFunc_t f = NULL;
107 int channels;
108 Uint16 format;
109
110 Mix_QuerySpec(NULL, &format, &channels);
111
112 if (channels == 2) {
113 int bits = (format & 0xFF);
114 switch (bits) {
115 case 8:
116 f = _Eff_reversestereo8;
117 break;
118 case 16:
119 f = _Eff_reversestereo16;
120 break;
121 case 32:
122 f = _Eff_reversestereo32;
123 break;
124 default:
125 Mix_SetError("Unsupported audio format");
126 return(0);
127 }
128
129 if (!flip) {
130 return(Mix_UnregisterEffect(channel, f));
131 } else {
132 return(Mix_RegisterEffect(channel, f, NULL, NULL));
133 }
134 } else {
135 Mix_SetError("Trying to reverse stereo on a non-stereo stream");
136 return(0);
137 }
138
139 return(1);
140 }
141
142
143 /* end of effect_stereoreverse.c ... */
144
145 /* vi: set ts=4 sw=4 expandtab: */
+0
-125
effects_internal.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some helper functions for the internal mixer special effects.
23 */
24
25 /* $Id$ */
26
27
28 /* ------ These are used internally only. Don't touch. ------ */
29
30
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include "SDL_mixer.h"
35
36 #define __MIX_INTERNAL_EFFECT__
37 #include "effects_internal.h"
38
39 /* Should we favor speed over memory usage and/or quality of output? */
40 int _Mix_effects_max_speed = 0;
41
42
43 void _Mix_InitEffects(void)
44 {
45 _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
46 }
47
48 void _Mix_DeinitEffects(void)
49 {
50 _Eff_PositionDeinit();
51 }
52
53
54 void *_Eff_volume_table = NULL;
55
56
57 /* Build the volume table for Uint8-format samples.
58 *
59 * Each column of the table is a possible sample, while each row of the
60 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
61 * volume. So _Eff_volume_table[128][mysample] would be the value of
62 * mysample, at half volume.
63 */
64 void *_Eff_build_volume_table_u8(void)
65 {
66 int volume;
67 int sample;
68 Uint8 *rc;
69
70 if (!_Mix_effects_max_speed) {
71 return(NULL);
72 }
73
74 if (!_Eff_volume_table) {
75 rc = SDL_malloc(256 * 256);
76 if (rc) {
77 _Eff_volume_table = (void *) rc;
78 for (volume = 0; volume < 256; volume++) {
79 for (sample = -128; sample < 128; sample ++) {
80 *rc = (Uint8)(((float) sample) * ((float) volume / 255.0))
81 + 128;
82 rc++;
83 }
84 }
85 }
86 }
87
88 return(_Eff_volume_table);
89 }
90
91
92 /* Build the volume table for Sint8-format samples.
93 *
94 * Each column of the table is a possible sample, while each row of the
95 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
96 * volume. So _Eff_volume_table[128][mysample+128] would be the value of
97 * mysample, at half volume.
98 */
99 void *_Eff_build_volume_table_s8(void)
100 {
101 int volume;
102 int sample;
103 Sint8 *rc;
104
105 if (!_Eff_volume_table) {
106 rc = SDL_malloc(256 * 256);
107 if (rc) {
108 _Eff_volume_table = (void *) rc;
109 for (volume = 0; volume < 256; volume++) {
110 for (sample = -128; sample < 128; sample ++) {
111 *rc = (Sint8)(((float) sample) * ((float) volume / 255.0));
112 rc++;
113 }
114 }
115 }
116 }
117
118 return(_Eff_volume_table);
119 }
120
121
122 /* end of effects.c ... */
123
124 /* vi: set ts=4 sw=4 expandtab: */
+0
-49
effects_internal.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* $Id$ */
22
23 #ifndef _INCLUDE_EFFECTS_INTERNAL_H_
24 #define _INCLUDE_EFFECTS_INTERNAL_H_
25
26 #ifndef __MIX_INTERNAL_EFFECT__
27 #error You should not include this file or use these functions.
28 #endif
29
30 #include "SDL_mixer.h"
31
32 extern int _Mix_effects_max_speed;
33 extern void *_Eff_volume_table;
34 void *_Eff_build_volume_table_u8(void);
35 void *_Eff_build_volume_table_s8(void);
36
37 void _Mix_InitEffects(void);
38 void _Mix_DeinitEffects(void);
39 void _Eff_PositionDeinit(void);
40
41 int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
42 Mix_EffectDone_t d, void *arg);
43 int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f);
44 int _Mix_UnregisterAllEffects_locked(int channel);
45
46 #endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */
47
48 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef SDL_MIXER_H_
22 #define SDL_MIXER_H_
23
24 #include "SDL_stdinc.h"
25 #include "SDL_rwops.h"
26 #include "SDL_audio.h"
27 #include "SDL_endian.h"
28 #include "SDL_version.h"
29 #include "begin_code.h"
30
31 /* Set up for C function definitions, even when using C++ */
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
37 */
38 #define SDL_MIXER_MAJOR_VERSION 2
39 #define SDL_MIXER_MINOR_VERSION 0
40 #define SDL_MIXER_PATCHLEVEL 4
41
42 /* This macro can be used to fill a version structure with the compile-time
43 * version of the SDL_mixer library.
44 */
45 #define SDL_MIXER_VERSION(X) \
46 { \
47 (X)->major = SDL_MIXER_MAJOR_VERSION; \
48 (X)->minor = SDL_MIXER_MINOR_VERSION; \
49 (X)->patch = SDL_MIXER_PATCHLEVEL; \
50 }
51
52 /* Backwards compatibility */
53 #define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION
54 #define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION
55 #define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL
56 #define MIX_VERSION(X) SDL_MIXER_VERSION(X)
57
58 /**
59 * This is the version number macro for the current SDL_mixer version.
60 */
61 #define SDL_MIXER_COMPILEDVERSION \
62 SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
63
64 /**
65 * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
66 */
67 #define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
68 (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
69
70 /* This function gets the version of the dynamically linked SDL_mixer library.
71 it should NOT be used to fill a version structure, instead you should
72 use the SDL_MIXER_VERSION() macro.
73 */
74 extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
75
76 typedef enum
77 {
78 MIX_INIT_FLAC = 0x00000001,
79 MIX_INIT_MOD = 0x00000002,
80 MIX_INIT_MP3 = 0x00000008,
81 MIX_INIT_OGG = 0x00000010,
82 MIX_INIT_MID = 0x00000020,
83 MIX_INIT_OPUS = 0x00000040
84 } MIX_InitFlags;
85
86 /* Loads dynamic libraries and prepares them for use. Flags should be
87 one or more flags from MIX_InitFlags OR'd together.
88 It returns the flags successfully initialized, or 0 on failure.
89 */
90 extern DECLSPEC int SDLCALL Mix_Init(int flags);
91
92 /* Unloads libraries loaded with Mix_Init */
93 extern DECLSPEC void SDLCALL Mix_Quit(void);
94
95
96 /* The default mixer has 8 simultaneous mixing channels */
97 #ifndef MIX_CHANNELS
98 #define MIX_CHANNELS 8
99 #endif
100
101 /* Good default values for a PC soundcard */
102 #define MIX_DEFAULT_FREQUENCY 44100
103 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
104 #define MIX_DEFAULT_FORMAT AUDIO_S16LSB
105 #else
106 #define MIX_DEFAULT_FORMAT AUDIO_S16MSB
107 #endif
108 #define MIX_DEFAULT_CHANNELS 2
109 #define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */
110
111 /* The internal format for an audio chunk */
112 typedef struct Mix_Chunk {
113 int allocated;
114 Uint8 *abuf;
115 Uint32 alen;
116 Uint8 volume; /* Per-sample volume, 0-128 */
117 } Mix_Chunk;
118
119 /* The different fading types supported */
120 typedef enum {
121 MIX_NO_FADING,
122 MIX_FADING_OUT,
123 MIX_FADING_IN
124 } Mix_Fading;
125
126 /* These are types of music files (not libraries used to load them) */
127 typedef enum {
128 MUS_NONE,
129 MUS_CMD,
130 MUS_WAV,
131 MUS_MOD,
132 MUS_MID,
133 MUS_OGG,
134 MUS_MP3,
135 MUS_MP3_MAD_UNUSED,
136 MUS_FLAC,
137 MUS_MODPLUG_UNUSED,
138 MUS_OPUS
139 } Mix_MusicType;
140
141 /* The internal format for a music chunk interpreted via mikmod */
142 typedef struct _Mix_Music Mix_Music;
143
144 /* Open the mixer with a certain audio format */
145 extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
146
147 /* Open the mixer with specific device and certain audio format */
148 extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
149
150 /* Dynamically change the number of channels managed by the mixer.
151 If decreasing the number of channels, the upper channels are
152 stopped.
153 This function returns the new number of allocated channels.
154 */
155 extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
156
157 /* Find out what the actual audio device parameters are.
158 This function returns 1 if the audio has been opened, 0 otherwise.
159 */
160 extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
161
162 /* Load a wave file or a music (.mod .s3m .it .xm) file */
163 extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
164 #define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
165 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
166
167 /* Load a music file from an SDL_RWop object
168 * Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
169 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
170
171 /* Load a music file from an SDL_RWop object assuming a specific format */
172 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
173
174 /* Load a wave file of the mixer format from a memory buffer */
175 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
176
177 /* Load raw audio data of the mixer format from a memory buffer */
178 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
179
180 /* Free an audio chunk previously loaded */
181 extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
182 extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
183
184 /* Get a list of chunk/music decoders that this build of SDL_mixer provides.
185 This list can change between builds AND runs of the program, if external
186 libraries that add functionality become available.
187 You must successfully call Mix_OpenAudio() before calling these functions.
188 This API is only available in SDL_mixer 1.2.9 and later.
189
190 // usage...
191 int i;
192 const int total = Mix_GetNumChunkDecoders();
193 for (i = 0; i < total; i++)
194 printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
195
196 Appearing in this list doesn't promise your specific audio file will
197 decode...but it's handy to know if you have, say, a functioning Timidity
198 install.
199
200 These return values are static, read-only data; do not modify or free it.
201 The pointers remain valid until you call Mix_CloseAudio().
202 */
203 extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
204 extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
205 extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
206 extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
207 extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
208 extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
209
210 /* Find out the music format of a mixer music, or the currently playing
211 music, if 'music' is NULL.
212 */
213 extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
214
215 /* Get music title from meta-tag if possible. If title tag is empty, filename will be returned */
216 extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music);
217 /* Get music title from meta-tag if possible */
218 extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music);
219 /* Get music artist from meta-tag if possible */
220 extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music);
221 /* Get music album from meta-tag if possible */
222 extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music);
223 /* Get music copyright from meta-tag if possible */
224 extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music);
225
226 /* Set a function that is called after all mixing is performed.
227 This can be used to provide real-time visual display of the audio stream
228 or add a custom mixer filter for the stream data.
229 */
230 extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
231
232 /* Add your own music player or additional mixer function.
233 If 'mix_func' is NULL, the default music player is re-enabled.
234 */
235 extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
236
237 /* Add your own callback for when the music has finished playing or when it is
238 * stopped from a call to Mix_HaltMusic.
239 */
240 extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void));
241
242 /* Get a pointer to the user data for the current music hook */
243 extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
244
245 /*
246 * Add your own callback when a channel has finished playing. NULL
247 * to disable callback. The callback may be called from the mixer's audio
248 * callback or it could be called as a result of Mix_HaltChannel(), etc.
249 * do not call SDL_LockAudio() from this callback; you will either be
250 * inside the audio callback, or SDL_mixer will explicitly lock the audio
251 * before calling your callback.
252 */
253 extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel));
254
255
256 /* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
257
258 #define MIX_CHANNEL_POST (-2)
259
260 /* This is the format of a special effect callback:
261 *
262 * myeffect(int chan, void *stream, int len, void *udata);
263 *
264 * (chan) is the channel number that your effect is affecting. (stream) is
265 * the buffer of data to work upon. (len) is the size of (stream), and
266 * (udata) is a user-defined bit of data, which you pass as the last arg of
267 * Mix_RegisterEffect(), and is passed back unmolested to your callback.
268 * Your effect changes the contents of (stream) based on whatever parameters
269 * are significant, or just leaves it be, if you prefer. You can do whatever
270 * you like to the buffer, though, and it will continue in its changed state
271 * down the mixing pipeline, through any other effect functions, then finally
272 * to be mixed with the rest of the channels and music for the final output
273 * stream.
274 *
275 * DO NOT EVER call SDL_LockAudio() from your callback function!
276 */
277 typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
278
279 /*
280 * This is a callback that signifies that a channel has finished all its
281 * loops and has completed playback. This gets called if the buffer
282 * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
283 * a channel via Mix_AllocateChannels(), or unregister a callback while
284 * it's still playing.
285 *
286 * DO NOT EVER call SDL_LockAudio() from your callback function!
287 */
288 typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
289
290
291 /* Register a special effect function. At mixing time, the channel data is
292 * copied into a buffer and passed through each registered effect function.
293 * After it passes through all the functions, it is mixed into the final
294 * output stream. The copy to buffer is performed once, then each effect
295 * function performs on the output of the previous effect. Understand that
296 * this extra copy to a buffer is not performed if there are no effects
297 * registered for a given chunk, which saves CPU cycles, and any given
298 * effect will be extra cycles, too, so it is crucial that your code run
299 * fast. Also note that the data that your function is given is in the
300 * format of the sound device, and not the format you gave to Mix_OpenAudio(),
301 * although they may in reality be the same. This is an unfortunate but
302 * necessary speed concern. Use Mix_QuerySpec() to determine if you can
303 * handle the data before you register your effect, and take appropriate
304 * actions.
305 * You may also specify a callback (Mix_EffectDone_t) that is called when
306 * the channel finishes playing. This gives you a more fine-grained control
307 * than Mix_ChannelFinished(), in case you need to free effect-specific
308 * resources, etc. If you don't need this, you can specify NULL.
309 * You may set the callbacks before or after calling Mix_PlayChannel().
310 * Things like Mix_SetPanning() are just internal special effect functions,
311 * so if you are using that, you've already incurred the overhead of a copy
312 * to a separate buffer, and that these effects will be in the queue with
313 * any functions you've registered. The list of registered effects for a
314 * channel is reset when a chunk finishes playing, so you need to explicitly
315 * set them with each call to Mix_PlayChannel*().
316 * You may also register a special effect function that is to be run after
317 * final mixing occurs. The rules for these callbacks are identical to those
318 * in Mix_RegisterEffect, but they are run after all the channels and the
319 * music have been mixed into a single stream, whereas channel-specific
320 * effects run on a given channel before any other mixing occurs. These
321 * global effect callbacks are call "posteffects". Posteffects only have
322 * their Mix_EffectDone_t function called when they are unregistered (since
323 * the main output stream is never "done" in the same sense as a channel).
324 * You must unregister them manually when you've had enough. Your callback
325 * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
326 * processing is considered a posteffect.
327 *
328 * After all these effects have finished processing, the callback registered
329 * through Mix_SetPostMix() runs, and then the stream goes to the audio
330 * device.
331 *
332 * DO NOT EVER call SDL_LockAudio() from your callback function!
333 *
334 * returns zero if error (no such channel), nonzero if added.
335 * Error messages can be retrieved from Mix_GetError().
336 */
337 extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
338
339
340 /* You may not need to call this explicitly, unless you need to stop an
341 * effect from processing in the middle of a chunk's playback.
342 * Posteffects are never implicitly unregistered as they are for channels,
343 * but they may be explicitly unregistered through this function by
344 * specifying MIX_CHANNEL_POST for a channel.
345 * returns zero if error (no such channel or effect), nonzero if removed.
346 * Error messages can be retrieved from Mix_GetError().
347 */
348 extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
349
350
351 /* You may not need to call this explicitly, unless you need to stop all
352 * effects from processing in the middle of a chunk's playback. Note that
353 * this will also shut off some internal effect processing, since
354 * Mix_SetPanning() and others may use this API under the hood. This is
355 * called internally when a channel completes playback.
356 * Posteffects are never implicitly unregistered as they are for channels,
357 * but they may be explicitly unregistered through this function by
358 * specifying MIX_CHANNEL_POST for a channel.
359 * returns zero if error (no such channel), nonzero if all effects removed.
360 * Error messages can be retrieved from Mix_GetError().
361 */
362 extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
363
364
365 #define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"
366
367 /*
368 * These are the internally-defined mixing effects. They use the same API that
369 * effects defined in the application use, but are provided here as a
370 * convenience. Some effects can reduce their quality or use more memory in
371 * the name of speed; to enable this, make sure the environment variable
372 * MIX_EFFECTSMAXSPEED (see above) is defined before you call
373 * Mix_OpenAudio().
374 */
375
376
377 /* Set the panning of a channel. The left and right channels are specified
378 * as integers between 0 and 255, quietest to loudest, respectively.
379 *
380 * Technically, this is just individual volume control for a sample with
381 * two (stereo) channels, so it can be used for more than just panning.
382 * If you want real panning, call it like this:
383 *
384 * Mix_SetPanning(channel, left, 255 - left);
385 *
386 * ...which isn't so hard.
387 *
388 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
389 * the panning will be done to the final mixed stream before passing it on
390 * to the audio device.
391 *
392 * This uses the Mix_RegisterEffect() API internally, and returns without
393 * registering the effect function if the audio device is not configured
394 * for stereo output. Setting both (left) and (right) to 255 causes this
395 * effect to be unregistered, since that is the data's normal state.
396 *
397 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
398 * nonzero if panning effect enabled. Note that an audio device in mono
399 * mode is a no-op, but this call will return successful in that case.
400 * Error messages can be retrieved from Mix_GetError().
401 */
402 extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
403
404
405 /* Set the position of a channel. (angle) is an integer from 0 to 360, that
406 * specifies the location of the sound in relation to the listener. (angle)
407 * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
408 * Angle 0 is due north, and rotates clockwise as the value increases.
409 * For efficiency, the precision of this effect may be limited (angles 1
410 * through 7 might all produce the same effect, 8 through 15 are equal, etc).
411 * (distance) is an integer between 0 and 255 that specifies the space
412 * between the sound and the listener. The larger the number, the further
413 * away the sound is. Using 255 does not guarantee that the channel will be
414 * culled from the mixing process or be completely silent. For efficiency,
415 * the precision of this effect may be limited (distance 0 through 5 might
416 * all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
417 * and (distance) to 0 unregisters this effect, since the data would be
418 * unchanged.
419 *
420 * If you need more precise positional audio, consider using OpenAL for
421 * spatialized effects instead of SDL_mixer. This is only meant to be a
422 * basic effect for simple "3D" games.
423 *
424 * If the audio device is configured for mono output, then you won't get
425 * any effectiveness from the angle; however, distance attenuation on the
426 * channel will still occur. While this effect will function with stereo
427 * voices, it makes more sense to use voices with only one channel of sound,
428 * so when they are mixed through this effect, the positioning will sound
429 * correct. You can convert them to mono through SDL before giving them to
430 * the mixer in the first place if you like.
431 *
432 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
433 * the positioning will be done to the final mixed stream before passing it
434 * on to the audio device.
435 *
436 * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
437 *
438 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
439 * nonzero if position effect is enabled.
440 * Error messages can be retrieved from Mix_GetError().
441 */
442 extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
443
444
445 /* Set the "distance" of a channel. (distance) is an integer from 0 to 255
446 * that specifies the location of the sound in relation to the listener.
447 * Distance 0 is overlapping the listener, and 255 is as far away as possible
448 * A distance of 255 does not guarantee silence; in such a case, you might
449 * want to try changing the chunk's volume, or just cull the sample from the
450 * mixing process with Mix_HaltChannel().
451 * For efficiency, the precision of this effect may be limited (distances 1
452 * through 7 might all produce the same effect, 8 through 15 are equal, etc).
453 * (distance) is an integer between 0 and 255 that specifies the space
454 * between the sound and the listener. The larger the number, the further
455 * away the sound is.
456 * Setting (distance) to 0 unregisters this effect, since the data would be
457 * unchanged.
458 * If you need more precise positional audio, consider using OpenAL for
459 * spatialized effects instead of SDL_mixer. This is only meant to be a
460 * basic effect for simple "3D" games.
461 *
462 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
463 * the distance attenuation will be done to the final mixed stream before
464 * passing it on to the audio device.
465 *
466 * This uses the Mix_RegisterEffect() API internally.
467 *
468 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
469 * nonzero if position effect is enabled.
470 * Error messages can be retrieved from Mix_GetError().
471 */
472 extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
473
474
475 /*
476 * !!! FIXME : Haven't implemented, since the effect goes past the
477 * end of the sound buffer. Will have to think about this.
478 * --ryan.
479 */
480 #if 0
481 /* Causes an echo effect to be mixed into a sound. (echo) is the amount
482 * of echo to mix. 0 is no echo, 255 is infinite (and probably not
483 * what you want).
484 *
485 * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
486 * the reverbing will be done to the final mixed stream before passing it on
487 * to the audio device.
488 *
489 * This uses the Mix_RegisterEffect() API internally. If you specify an echo
490 * of zero, the effect is unregistered, as the data is already in that state.
491 *
492 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
493 * nonzero if reversing effect is enabled.
494 * Error messages can be retrieved from Mix_GetError().
495 */
496 extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
497 #endif
498
499 /* Causes a channel to reverse its stereo. This is handy if the user has his
500 * speakers hooked up backwards, or you would like to have a minor bit of
501 * psychedelia in your sound code. :) Calling this function with (flip)
502 * set to non-zero reverses the chunks's usual channels. If (flip) is zero,
503 * the effect is unregistered.
504 *
505 * This uses the Mix_RegisterEffect() API internally, and thus is probably
506 * more CPU intensive than having the user just plug in his speakers
507 * correctly. Mix_SetReverseStereo() returns without registering the effect
508 * function if the audio device is not configured for stereo output.
509 *
510 * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
511 * on the final mixed stream before sending it on to the audio device (a
512 * posteffect).
513 *
514 * returns zero if error (no such channel or Mix_RegisterEffect() fails),
515 * nonzero if reversing effect is enabled. Note that an audio device in mono
516 * mode is a no-op, but this call will return successful in that case.
517 * Error messages can be retrieved from Mix_GetError().
518 */
519 extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
520
521 /* end of effects API. --ryan. */
522
523
524 /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
525 them dynamically to the next sample if requested with a -1 value below.
526 Returns the number of reserved channels.
527 */
528 extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
529
530 /* Channel grouping functions */
531
532 /* Attach a tag to a channel. A tag can be assigned to several mixer
533 channels, to form groups of channels.
534 If 'tag' is -1, the tag is removed (actually -1 is the tag used to
535 represent the group of all the channels).
536 Returns true if everything was OK.
537 */
538 extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
539 /* Assign several consecutive channels to a group */
540 extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
541 /* Finds the first available channel in a group of channels,
542 returning -1 if none are available.
543 */
544 extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
545 /* Returns the number of channels in a group. This is also a subtle
546 way to get the total number of channels when 'tag' is -1
547 */
548 extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
549 /* Finds the "oldest" sample playing in a group of channels */
550 extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
551 /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
552 extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
553
554 /* Play an audio chunk on a specific channel.
555 If the specified channel is -1, play on the first free channel.
556 If 'loops' is greater than zero, loop the sound that many times.
557 If 'loops' is -1, loop inifinitely (~65000 times).
558 Returns which channel was used to play the sound.
559 */
560 #define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
561 /* The same as above, but the sound is played at most 'ticks' milliseconds */
562 extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
563 extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
564
565 /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
566 extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
567 extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
568 #define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
569 extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
570
571 /* Set the volume in the range of 0-128 of a specific channel or chunk.
572 If the specified channel is -1, set volume for all channels.
573 Returns the original volume.
574 If the specified volume is -1, just return the current volume.
575 */
576 extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
577 extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
578 extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
579 /* Get the current volume value in the range of 0-128 of a music stream */
580 extern DECLSPEC int SDLCALL Mix_GetMusicVolume(Mix_Music *music);
581
582 /* Halt playing of a particular channel */
583 extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
584 extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
585 extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
586
587 /* Change the expiration delay for a particular channel.
588 The sample will stop playing after the 'ticks' milliseconds have elapsed,
589 or remove the expiration if 'ticks' is -1
590 */
591 extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
592
593 /* Halt a channel, fading it out progressively till it's silent
594 The ms parameter indicates the number of milliseconds the fading
595 will take.
596 */
597 extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
598 extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
599 extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
600
601 /* Query the fading status of a channel */
602 extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
603 extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
604
605 /* Pause/Resume a particular channel */
606 extern DECLSPEC void SDLCALL Mix_Pause(int channel);
607 extern DECLSPEC void SDLCALL Mix_Resume(int channel);
608 extern DECLSPEC int SDLCALL Mix_Paused(int channel);
609
610 /* Pause/Resume the music stream */
611 extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
612 extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
613 extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
614 extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
615
616 /* Jump to a given order in mod music.
617 Returns 0 if successful, or -1 if failed or isn't implemented.
618 Only for MOD music formats.
619 */
620 extern DECLSPEC int SDLCALL Mix_ModMusicJumpToOrder(int order);
621
622 /* Set the current position in the music stream.
623 This returns 0 if successful, or -1 if it failed or isn't implemented.
624 This function is only implemented for MOD music formats (set pattern
625 order number) and for WAV, OGG, FLAC, MP3_MAD, MP3_MPG, and MODPLUG music
626 (set position in seconds), at the moment.
627 */
628 extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
629
630 /*
631 Get the time current position of music stream
632 returns -1.0 if this feature is not supported for some codec
633 */
634 extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music);
635
636 /* Return music duration in seconds.
637 If NULL is passed, returns duration of current playing music.
638 Returns -1 on error.
639 */
640 extern DECLSPEC double SDLCALL Mix_MusicDuration(Mix_Music *music);
641
642 /*
643 Get the loop start time position of music stream
644 returns -1.0 if this feature is not used for this music or not supported for some codec
645 */
646 extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music);
647 /*
648 Get the loop end time position of music stream
649 returns -1.0 if this feature is not used for this music or not supported for some codec
650 */
651 extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music);
652 /*
653 Get the loop time length of music stream
654 returns -1.0 if this feature is not used for this music or not supported for some codec
655 */
656 extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music);
657
658 /* Check the status of a specific channel.
659 If the specified channel is -1, check all channels.
660 */
661 extern DECLSPEC int SDLCALL Mix_Playing(int channel);
662 extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
663
664 /* Stop music and set external music playback command */
665 extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
666
667 /* Synchro value is set by MikMod from modules while playing */
668 extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
669 extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
670
671 /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
672 extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
673 extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
674 extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data);
675
676 /* Set/Get full path of Timidity config file (e.g. /etc/timidity.cfg) */
677 extern DECLSPEC int SDLCALL Mix_SetTimidityCfg(const char *path);
678 extern DECLSPEC const char* SDLCALL Mix_GetTimidityCfg(void);
679
680 /* Get the Mix_Chunk currently associated with a mixer channel
681 Returns NULL if it's an invalid channel, or there's no chunk associated.
682 */
683 extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
684
685 /* Close the mixer, halting all playing audio */
686 extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
687
688 /* We'll use SDL for reporting errors */
689 #define Mix_SetError SDL_SetError
690 #define Mix_GetError SDL_GetError
691 #define Mix_ClearError SDL_ClearError
692
693 /* Ends C function definitions when using C++ */
694 #ifdef __cplusplus
695 }
696 #endif
697 #include "close_code.h"
698
699 #endif /* SDL_MIXER_H_ */
700
701 /* vi: set ts=4 sw=4 expandtab: */
+0
-246
load_aiff.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an AIFF file into a waveform.
21 It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadAIFF_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
26 8SVX file support added by Marc Le Douarain (mavati@club-internet.fr)
27 in december 2002.
28 */
29
30 #include "SDL_endian.h"
31 #include "SDL_mixer.h"
32 #include "load_aiff.h"
33
34 /*********************************************/
35 /* Define values for AIFF (IFF audio) format */
36 /*********************************************/
37 #define FORM 0x4d524f46 /* "FORM" */
38
39 #define AIFF 0x46464941 /* "AIFF" */
40 #define SSND 0x444e5353 /* "SSND" */
41 #define COMM 0x4d4d4f43 /* "COMM" */
42
43 #define _8SVX 0x58565338 /* "8SVX" */
44 #define VHDR 0x52444856 /* "VHDR" */
45 #define BODY 0x59444F42 /* "BODY" */
46
47 /* This function was taken from libsndfile. I don't pretend to fully
48 * understand it.
49 */
50
51 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
52 {
53 /* Is the frequency outside of what we can represent with Uint32? */
54 if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40)
55 || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C))
56 return 0;
57
58 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7)
59 | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
60 }
61
62 /* This function is based on SDL_LoadWAV_RW(). */
63
64 SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
65 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
66 {
67 int was_error;
68 int found_SSND;
69 int found_COMM;
70 int found_VHDR;
71 int found_BODY;
72 Sint64 start = 0;
73
74 Uint32 chunk_type;
75 Uint32 chunk_length;
76 Sint64 next_chunk;
77
78 /* AIFF magic header */
79 Uint32 FORMchunk;
80 Uint32 AIFFmagic;
81
82 /* SSND chunk */
83 Uint32 offset;
84 Uint32 blocksize;
85
86 /* COMM format chunk */
87 Uint16 channels = 0;
88 Uint32 numsamples = 0;
89 Uint16 samplesize = 0;
90 Uint8 sane_freq[10];
91 Uint32 frequency = 0;
92
93 /* Make sure we are passed a valid data source */
94 was_error = 0;
95 if (src == NULL) {
96 was_error = 1;
97 goto done;
98 }
99
100 FORMchunk = SDL_ReadLE32(src);
101 chunk_length = SDL_ReadBE32(src);
102 if (chunk_length == AIFF) { /* The FORMchunk has already been read */
103 AIFFmagic = chunk_length;
104 chunk_length = FORMchunk;
105 FORMchunk = FORM;
106 } else {
107 AIFFmagic = SDL_ReadLE32(src);
108 }
109 if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) {
110 SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)");
111 was_error = 1;
112 goto done;
113 }
114
115 /* TODO: Better santity-checking. */
116
117 found_SSND = 0;
118 found_COMM = 0;
119 found_VHDR = 0;
120 found_BODY = 0;
121
122 do {
123 chunk_type = SDL_ReadLE32(src);
124 chunk_length = SDL_ReadBE32(src);
125 next_chunk = SDL_RWtell(src) + chunk_length;
126 /* Paranoia to avoid infinite loops */
127 if (chunk_length == 0)
128 break;
129
130 switch (chunk_type) {
131 case SSND:
132 found_SSND = 1;
133 offset = SDL_ReadBE32(src);
134 blocksize = SDL_ReadBE32(src);
135 start = SDL_RWtell(src) + offset;
136 break;
137
138 case COMM:
139 found_COMM = 1;
140 channels = SDL_ReadBE16(src);
141 numsamples = SDL_ReadBE32(src);
142 samplesize = SDL_ReadBE16(src);
143 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
144 frequency = SANE_to_Uint32(sane_freq);
145 if (frequency == 0) {
146 SDL_SetError("Bad AIFF sample frequency");
147 was_error = 1;
148 goto done;
149 }
150 break;
151
152 case VHDR:
153 found_VHDR = 1;
154 SDL_ReadBE32(src);
155 SDL_ReadBE32(src);
156 SDL_ReadBE32(src);
157 frequency = SDL_ReadBE16(src);
158 channels = 1;
159 samplesize = 8;
160 break;
161
162 case BODY:
163 found_BODY = 1;
164 numsamples = chunk_length;
165 start = SDL_RWtell(src);
166 break;
167
168 default:
169 break;
170 }
171 /* a 0 pad byte can be stored for any odd-length chunk */
172 if (chunk_length&1)
173 next_chunk++;
174 } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM))
175 || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY)))
176 && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1);
177
178 if ((AIFFmagic == AIFF) && !found_SSND) {
179 SDL_SetError("Bad AIFF (no SSND chunk)");
180 was_error = 1;
181 goto done;
182 }
183
184 if ((AIFFmagic == AIFF) && !found_COMM) {
185 SDL_SetError("Bad AIFF (no COMM chunk)");
186 was_error = 1;
187 goto done;
188 }
189
190 if ((AIFFmagic == _8SVX) && !found_VHDR) {
191 SDL_SetError("Bad 8SVX (no VHDR chunk)");
192 was_error = 1;
193 goto done;
194 }
195
196 if ((AIFFmagic == _8SVX) && !found_BODY) {
197 SDL_SetError("Bad 8SVX (no BODY chunk)");
198 was_error = 1;
199 goto done;
200 }
201
202 /* Decode the audio data format */
203 SDL_memset(spec, 0, sizeof(*spec));
204 spec->freq = frequency;
205 switch (samplesize) {
206 case 8:
207 spec->format = AUDIO_S8;
208 break;
209 case 16:
210 spec->format = AUDIO_S16MSB;
211 break;
212 default:
213 SDL_SetError("Unsupported AIFF samplesize");
214 was_error = 1;
215 goto done;
216 }
217 spec->channels = (Uint8) channels;
218 spec->samples = 4096; /* Good default buffer size */
219
220 *audio_len = channels * numsamples * (samplesize / 8);
221 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
222 if (*audio_buf == NULL) {
223 SDL_SetError("Out of memory");
224 return(NULL);
225 }
226 SDL_RWseek(src, start, RW_SEEK_SET);
227 if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
228 SDL_SetError("Unable to read audio data");
229 return(NULL);
230 }
231
232 /* Don't return a buffer that isn't a multiple of samplesize */
233 *audio_len &= ~((samplesize / 8) - 1);
234
235 done:
236 if (freesrc && src) {
237 SDL_RWclose(src);
238 }
239 if (was_error) {
240 spec = NULL;
241 }
242 return(spec);
243 }
244
245 /* vi: set ts=4 sw=4 expandtab: */
+0
-33
load_aiff.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an AIFF file into a waveform.
21 It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadAIFF_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
26 */
27
28 /* Don't call this directly; use Mix_LoadWAV_RW() for now. */
29 SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
30 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
31
32 /* vi: set ts=4 sw=4 expandtab: */
+0
-451
load_voc.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode a Creative Labs VOC file into a
21 waveform. It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadVOC_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Ryan C. Gordon (icculus@icculus.org).
26
27 Heavily borrowed from sox v12.17.1's voc.c.
28 (http://www.freshmeat.net/projects/sox/)
29 */
30
31 #include "SDL_mixer.h"
32 #include "load_voc.h"
33
34 /* Private data for VOC file */
35 typedef struct vocstuff {
36 Uint32 rest; /* bytes remaining in current block */
37 Uint32 rate; /* rate code (byte) of this chunk */
38 int silent; /* sound or silence? */
39 Uint32 srate; /* rate code (byte) of silence */
40 Uint32 blockseek; /* start of current output block */
41 Uint32 samples; /* number of samples output */
42 Uint32 size; /* word length of data */
43 Uint8 channels; /* number of sound channels */
44 int has_extended; /* Has an extended block been read? */
45 } vs_t;
46
47 /* Size field */
48 /* SJB: note that the 1st 3 are sometimes used as sizeof(type) */
49 #define ST_SIZE_BYTE 1
50 #define ST_SIZE_8BIT 1
51 #define ST_SIZE_WORD 2
52 #define ST_SIZE_16BIT 2
53 #define ST_SIZE_DWORD 4
54 #define ST_SIZE_32BIT 4
55 #define ST_SIZE_FLOAT 5
56 #define ST_SIZE_DOUBLE 6
57 #define ST_SIZE_IEEE 7 /* IEEE 80-bit floats. */
58
59 /* Style field */
60 #define ST_ENCODING_UNSIGNED 1 /* unsigned linear: Sound Blaster */
61 #define ST_ENCODING_SIGN2 2 /* signed linear 2's comp: Mac */
62 #define ST_ENCODING_ULAW 3 /* U-law signed logs: US telephony, SPARC */
63 #define ST_ENCODING_ALAW 4 /* A-law signed logs: non-US telephony */
64 #define ST_ENCODING_ADPCM 5 /* Compressed PCM */
65 #define ST_ENCODING_IMA_ADPCM 6 /* Compressed PCM */
66 #define ST_ENCODING_GSM 7 /* GSM 6.10 33-byte frame lossy compression */
67
68 #define VOC_TERM 0
69 #define VOC_DATA 1
70 #define VOC_CONT 2
71 #define VOC_SILENCE 3
72 #define VOC_MARKER 4
73 #define VOC_TEXT 5
74 #define VOC_LOOP 6
75 #define VOC_LOOPEND 7
76 #define VOC_EXTENDED 8
77 #define VOC_DATA_16 9
78
79
80 static int voc_check_header(SDL_RWops *src)
81 {
82 /* VOC magic header */
83 Uint8 signature[20]; /* "Creative Voice File\032" */
84 Uint16 datablockofs;
85
86 SDL_RWseek(src, 0, RW_SEEK_SET);
87
88 if (SDL_RWread(src, signature, sizeof (signature), 1) != 1)
89 return(0);
90
91 if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) {
92 SDL_SetError("Unrecognized file type (not VOC)");
93 return(0);
94 }
95
96 /* get the offset where the first datablock is located */
97 if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1)
98 return(0);
99
100 datablockofs = SDL_SwapLE16(datablockofs);
101
102 if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
103 return(0);
104
105 return(1); /* success! */
106 } /* voc_check_header */
107
108
109 /* Read next block header, save info, leave position at start of data */
110 static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
111 {
112 Uint8 bits24[3];
113 Uint8 uc, block;
114 Uint32 sblen;
115 Uint16 new_rate_short;
116 Uint32 new_rate_long;
117 Uint8 trash[6];
118 Uint16 period;
119 unsigned int i;
120
121 v->silent = 0;
122 while (v->rest == 0)
123 {
124 if (SDL_RWread(src, &block, sizeof (block), 1) != 1)
125 return 1; /* assume that's the end of the file. */
126
127 if (block == VOC_TERM)
128 return 1;
129
130 if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
131 return 1; /* assume that's the end of the file. */
132
133 /* Size is an 24-bit value. Ugh. */
134 sblen = ((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16));
135
136 switch(block)
137 {
138 case VOC_DATA:
139 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
140 return 0;
141
142 /* When DATA block preceeded by an EXTENDED */
143 /* block, the DATA blocks rate value is invalid */
144 if (!v->has_extended)
145 {
146 if (uc == 0)
147 {
148 SDL_SetError("VOC Sample rate is zero?");
149 return 0;
150 }
151
152 if ((v->rate != -1) && (uc != v->rate))
153 {
154 SDL_SetError("VOC sample rate codes differ");
155 return 0;
156 }
157
158 v->rate = uc;
159 spec->freq = (Uint16)(1000000.0/(256 - v->rate));
160 v->channels = 1;
161 }
162
163 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
164 return 0;
165
166 if (uc != 0)
167 {
168 SDL_SetError("VOC decoder only interprets 8-bit data");
169 return 0;
170 }
171
172 v->has_extended = 0;
173 v->rest = sblen - 2;
174 v->size = ST_SIZE_BYTE;
175 return 1;
176
177 case VOC_DATA_16:
178 if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1)
179 return 0;
180 new_rate_long = SDL_SwapLE32(new_rate_long);
181 if (new_rate_long == 0)
182 {
183 SDL_SetError("VOC Sample rate is zero?");
184 return 0;
185 }
186 if ((v->rate != -1) && (new_rate_long != v->rate))
187 {
188 SDL_SetError("VOC sample rate codes differ");
189 return 0;
190 }
191 v->rate = new_rate_long;
192 spec->freq = new_rate_long;
193
194 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
195 return 0;
196
197 switch (uc)
198 {
199 case 8: v->size = ST_SIZE_BYTE; break;
200 case 16: v->size = ST_SIZE_WORD; break;
201 default:
202 SDL_SetError("VOC with unknown data size");
203 return 0;
204 }
205
206 if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1)
207 return 0;
208
209 if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6)
210 return 0;
211
212 v->rest = sblen - 12;
213 return 1;
214
215 case VOC_CONT:
216 v->rest = sblen;
217 return 1;
218
219 case VOC_SILENCE:
220 if (SDL_RWread(src, &period, sizeof (period), 1) != 1)
221 return 0;
222 period = SDL_SwapLE16(period);
223
224 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
225 return 0;
226 if (uc == 0)
227 {
228 SDL_SetError("VOC silence sample rate is zero");
229 return 0;
230 }
231
232 /*
233 * Some silence-packed files have gratuitously
234 * different sample rate codes in silence.
235 * Adjust period.
236 */
237 if ((v->rate != -1) && (uc != v->rate))
238 period = (Uint16)((period * (256 - uc))/(256 - v->rate));
239 else
240 v->rate = uc;
241 v->rest = period;
242 v->silent = 1;
243 return 1;
244
245 case VOC_LOOP:
246 case VOC_LOOPEND:
247 for(i = 0; i < sblen; i++) /* skip repeat loops. */
248 {
249 if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1)
250 return 0;
251 }
252 break;
253
254 case VOC_EXTENDED:
255 /* An Extended block is followed by a data block */
256 /* Set this byte so we know to use the rate */
257 /* value from the extended block and not the */
258 /* data block. */
259 v->has_extended = 1;
260 if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1)
261 return 0;
262 new_rate_short = SDL_SwapLE16(new_rate_short);
263 if (new_rate_short == 0)
264 {
265 SDL_SetError("VOC sample rate is zero");
266 return 0;
267 }
268 if ((v->rate != -1) && (new_rate_short != v->rate))
269 {
270 SDL_SetError("VOC sample rate codes differ");
271 return 0;
272 }
273 v->rate = new_rate_short;
274
275 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
276 return 0;
277
278 if (uc != 0)
279 {
280 SDL_SetError("VOC decoder only interprets 8-bit data");
281 return 0;
282 }
283
284 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
285 return 0;
286
287 if (uc)
288 spec->channels = 2; /* Stereo */
289 /* Needed number of channels before finishing
290 compute for rate */
291 spec->freq = (256000000L/(65536L - v->rate))/spec->channels;
292 /* An extended block must be followed by a data */
293 /* block to be valid so loop back to top so it */
294 /* can be grabed. */
295 continue;
296
297 case VOC_MARKER:
298 if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2)
299 return 0;
300
301 /* Falling! Falling! */
302
303 default: /* text block or other krapola. */
304 for(i = 0; i < sblen; i++)
305 {
306 if (SDL_RWread(src, &trash, sizeof (Uint8), 1) != 1)
307 return 0;
308 }
309
310 if (block == VOC_TEXT)
311 continue; /* get next block */
312 }
313 }
314
315 return 1;
316 }
317
318
319 static int voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec)
320 {
321 Uint32 done = 0;
322 Uint8 silence = 0x80;
323
324 if (v->rest == 0)
325 {
326 if (!voc_get_block(src, v, spec))
327 return 0;
328 }
329
330 if (v->rest == 0)
331 return 0;
332
333 if (v->silent)
334 {
335 if (v->size == ST_SIZE_WORD)
336 silence = 0x00;
337
338 /* Fill in silence */
339 SDL_memset(buf, silence, v->rest);
340 done = v->rest;
341 v->rest = 0;
342 }
343
344 else
345 {
346 done = (Uint32)SDL_RWread(src, buf, 1, v->rest);
347 v->rest -= done;
348 if (v->size == ST_SIZE_WORD)
349 {
350 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
351 Uint16 *samples = (Uint16 *)buf;
352 for (; v->rest > 0; v->rest -= 2)
353 {
354 *samples = SDL_SwapLE16(*samples);
355 samples++;
356 }
357 #endif
358 done >>= 1;
359 }
360 }
361
362 return done;
363 } /* voc_read */
364
365
366 /* don't call this directly; use Mix_LoadWAV_RW() for now. */
367 SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
368 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
369 {
370 vs_t v;
371 int was_error = 1;
372 int samplesize;
373 Uint8 *fillptr;
374 void *ptr;
375
376 if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */
377 goto done;
378
379 if (!voc_check_header(src))
380 goto done;
381
382 v.rate = -1;
383 v.rest = 0;
384 v.has_extended = 0;
385 *audio_buf = NULL;
386 *audio_len = 0;
387 SDL_memset(spec, '\0', sizeof (SDL_AudioSpec));
388
389 if (!voc_get_block(src, &v, spec))
390 goto done;
391
392 if (v.rate == -1)
393 {
394 SDL_SetError("VOC data had no sound!");
395 goto done;
396 }
397
398 spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8);
399 if (spec->channels == 0)
400 spec->channels = v.channels;
401
402 *audio_len = v.rest;
403 *audio_buf = SDL_malloc(v.rest);
404 if (*audio_buf == NULL)
405 goto done;
406
407 fillptr = *audio_buf;
408
409 while (voc_read(src, &v, fillptr, spec) > 0)
410 {
411 if (!voc_get_block(src, &v, spec))
412 goto done;
413
414 *audio_len += v.rest;
415 ptr = SDL_realloc(*audio_buf, *audio_len);
416 if (ptr == NULL)
417 {
418 SDL_free(*audio_buf);
419 *audio_buf = NULL;
420 *audio_len = 0;
421 goto done;
422 }
423
424 *audio_buf = ptr;
425 fillptr = ((Uint8 *) ptr) + (*audio_len - v.rest);
426 }
427
428 spec->samples = (Uint16)(*audio_len / v.size);
429
430 was_error = 0; /* success, baby! */
431
432 /* Don't return a buffer that isn't a multiple of samplesize */
433 samplesize = ((spec->format & 0xFF)/8)*spec->channels;
434 *audio_len &= ~(samplesize-1);
435
436 done:
437 if (freesrc && src) {
438 SDL_RWclose(src);
439 }
440
441 if (was_error) {
442 spec = NULL;
443 }
444
445 return(spec);
446 } /* Mix_LoadVOC_RW */
447
448 /* end of load_voc.c ... */
449
450 /* vi: set ts=4 sw=4 expandtab: */
+0
-36
load_voc.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode a Creative Labs VOC file into a
21 waveform. It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadVOC_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Ryan C. Gordon (icculus@icculus.org).
26
27 Heavily borrowed from sox v12.17.1's voc.c.
28 (http://www.freshmeat.net/projects/sox/)
29 */
30
31 /* Don't call this directly; use Mix_LoadWAV_RW() for now. */
32 SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
33 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
34
35 /* vi: set ts=4 sw=4 expandtab: */
+0
-1610
mixer.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* $Id$ */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "SDL.h"
28
29 #include "SDL_mixer.h"
30 #include "mixer.h"
31 #include "music.h"
32 #include "load_aiff.h"
33 #include "load_voc.h"
34
35 #define __MIX_INTERNAL_EFFECT__
36 #include "effects_internal.h"
37
38 /* Magic numbers for various audio file formats */
39 #define RIFF 0x46464952 /* "RIFF" */
40 #define WAVE 0x45564157 /* "WAVE" */
41 #define FORM 0x4d524f46 /* "FORM" */
42 #define CREA 0x61657243 /* "Crea" */
43
44 static int audio_opened = 0;
45 static SDL_AudioSpec mixer;
46 static SDL_AudioDeviceID audio_device;
47
48 typedef struct _Mix_effectinfo
49 {
50 Mix_EffectFunc_t callback;
51 Mix_EffectDone_t done_callback;
52 void *udata;
53 struct _Mix_effectinfo *next;
54 } effect_info;
55
56 static struct _Mix_Channel {
57 Mix_Chunk *chunk;
58 int playing;
59 int paused;
60 Uint8 *samples;
61 int volume;
62 int looping;
63 int tag;
64 Uint32 expire;
65 Uint32 start_time;
66 Mix_Fading fading;
67 int fade_volume;
68 int fade_volume_reset;
69 Uint32 fade_length;
70 Uint32 ticks_fade;
71 effect_info *effects;
72 } *mix_channel = NULL;
73
74 static effect_info *posteffects = NULL;
75
76 static int num_channels;
77 static int reserved_channels = 0;
78
79
80 /* Support for hooking into the mixer callback system */
81 static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL;
82 static void *mix_postmix_data = NULL;
83
84 /* rcg07062001 callback to alert when channels are done playing. */
85 static void (SDLCALL *channel_done_callback)(int channel) = NULL;
86
87 /* Support for user defined music functions */
88 static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer;
89 static void *music_data = NULL;
90
91 /* rcg06042009 report available decoders at runtime. */
92 static const char **chunk_decoders = NULL;
93 static int num_decoders = 0;
94
95
96 int Mix_GetNumChunkDecoders(void)
97 {
98 return(num_decoders);
99 }
100
101 const char *Mix_GetChunkDecoder(int index)
102 {
103 if ((index < 0) || (index >= num_decoders)) {
104 return NULL;
105 }
106 return(chunk_decoders[index]);
107 }
108
109 SDL_bool Mix_HasChunkDecoder(const char *name)
110 {
111 int index;
112 for (index = 0; index < num_decoders; ++index) {
113 if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) {
114 return SDL_TRUE;
115 }
116 }
117 return SDL_FALSE;
118 }
119
120 void add_chunk_decoder(const char *decoder)
121 {
122 int i;
123 void *ptr;
124
125 /* Check to see if we already have this decoder */
126 for (i = 0; i < num_decoders; ++i) {
127 if (SDL_strcmp(chunk_decoders[i], decoder) == 0) {
128 return;
129 }
130 }
131
132 ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *));
133 if (ptr == NULL) {
134 return; /* oh well, go on without it. */
135 }
136 chunk_decoders = (const char **) ptr;
137 chunk_decoders[num_decoders++] = decoder;
138 }
139
140 /* rcg06192001 get linked library's version. */
141 const SDL_version *Mix_Linked_Version(void)
142 {
143 static SDL_version linked_version;
144 SDL_MIXER_VERSION(&linked_version);
145 return(&linked_version);
146 }
147
148 int Mix_Init(int flags)
149 {
150 int result = 0;
151
152 if (flags & MIX_INIT_FLAC) {
153 if (load_music_type(MUS_FLAC)) {
154 open_music_type(MUS_FLAC);
155 result |= MIX_INIT_FLAC;
156 } else {
157 Mix_SetError("FLAC support not available");
158 }
159 }
160 if (flags & MIX_INIT_MOD) {
161 if (load_music_type(MUS_MOD)) {
162 open_music_type(MUS_MOD);
163 result |= MIX_INIT_MOD;
164 } else {
165 Mix_SetError("MOD support not available");
166 }
167 }
168 if (flags & MIX_INIT_MP3) {
169 if (load_music_type(MUS_MP3)) {
170 open_music_type(MUS_MP3);
171 result |= MIX_INIT_MP3;
172 } else {
173 Mix_SetError("MP3 support not available");
174 }
175 }
176 if (flags & MIX_INIT_OGG) {
177 if (load_music_type(MUS_OGG)) {
178 open_music_type(MUS_OGG);
179 result |= MIX_INIT_OGG;
180 } else {
181 Mix_SetError("OGG support not available");
182 }
183 }
184 if (flags & MIX_INIT_OPUS) {
185 if (load_music_type(MUS_OPUS)) {
186 open_music_type(MUS_OPUS);
187 result |= MIX_INIT_OPUS;
188 } else {
189 Mix_SetError("OPUS support not available");
190 }
191 }
192 if (flags & MIX_INIT_MID) {
193 if (load_music_type(MUS_MID)) {
194 open_music_type(MUS_MID);
195 result |= MIX_INIT_MID;
196 } else {
197 Mix_SetError("MIDI support not available");
198 }
199 }
200 return result;
201 }
202
203 void Mix_Quit()
204 {
205 unload_music();
206 }
207
208 static int _Mix_remove_all_effects(int channel, effect_info **e);
209
210 /*
211 * rcg06122001 Cleanup effect callbacks.
212 * MAKE SURE Mix_LockAudio() is called before this (or you're in the
213 * audio callback).
214 */
215 static void _Mix_channel_done_playing(int channel)
216 {
217 if (channel_done_callback) {
218 channel_done_callback(channel);
219 }
220
221 /*
222 * Call internal function directly, to avoid locking audio from
223 * inside audio callback.
224 */
225 _Mix_remove_all_effects(channel, &mix_channel[channel].effects);
226 }
227
228
229 static void *Mix_DoEffects(int chan, void *snd, int len)
230 {
231 int posteffect = (chan == MIX_CHANNEL_POST);
232 effect_info *e = ((posteffect) ? posteffects : mix_channel[chan].effects);
233 void *buf = snd;
234
235 if (e != NULL) { /* are there any registered effects? */
236 /* if this is the postmix, we can just overwrite the original. */
237 if (!posteffect) {
238 buf = SDL_malloc(len);
239 if (buf == NULL) {
240 return(snd);
241 }
242 SDL_memcpy(buf, snd, len);
243 }
244
245 for (; e != NULL; e = e->next) {
246 if (e->callback != NULL) {
247 e->callback(chan, buf, len, e->udata);
248 }
249 }
250 }
251
252 /* be sure to SDL_free() the return value if != snd ... */
253 return(buf);
254 }
255
256
257 /* Mixing function */
258 static void SDLCALL
259 mix_channels(void *udata, Uint8 *stream, int len)
260 {
261 Uint8 *mix_input;
262 int i, mixable, volume = MIX_MAX_VOLUME;
263 Uint32 sdl_ticks;
264
265 #if SDL_VERSION_ATLEAST(1, 3, 0)
266 /* Need to initialize the stream in SDL 1.3+ */
267 SDL_memset(stream, mixer.silence, len);
268 #endif
269
270 /* Mix the music (must be done before the channels are added) */
271 mix_music(music_data, stream, len);
272
273 /* Mix any playing channels... */
274 sdl_ticks = SDL_GetTicks();
275 for (i=0; i<num_channels; ++i) {
276 if (!mix_channel[i].paused) {
277 if (mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks) {
278 /* Expiration delay for that channel is reached */
279 mix_channel[i].playing = 0;
280 mix_channel[i].looping = 0;
281 mix_channel[i].fading = MIX_NO_FADING;
282 mix_channel[i].expire = 0;
283 _Mix_channel_done_playing(i);
284 } else if (mix_channel[i].fading != MIX_NO_FADING) {
285 Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
286 if (ticks >= mix_channel[i].fade_length) {
287 Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
288 if(mix_channel[i].fading == MIX_FADING_OUT) {
289 mix_channel[i].playing = 0;
290 mix_channel[i].looping = 0;
291 mix_channel[i].expire = 0;
292 _Mix_channel_done_playing(i);
293 }
294 mix_channel[i].fading = MIX_NO_FADING;
295 } else {
296 if (mix_channel[i].fading == MIX_FADING_OUT) {
297 Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
298 / mix_channel[i].fade_length);
299 } else {
300 Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length);
301 }
302 }
303 }
304 if (mix_channel[i].playing > 0) {
305 int index = 0;
306 int remaining = len;
307 while (mix_channel[i].playing > 0 && index < len) {
308 remaining = len - index;
309 volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME;
310 mixable = mix_channel[i].playing;
311 if (mixable > remaining) {
312 mixable = remaining;
313 }
314
315 mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable);
316 SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume);
317 if (mix_input != mix_channel[i].samples)
318 SDL_free(mix_input);
319
320 mix_channel[i].samples += mixable;
321 mix_channel[i].playing -= mixable;
322 index += mixable;
323
324 /* rcg06072001 Alert app if channel is done playing. */
325 if (!mix_channel[i].playing && !mix_channel[i].looping) {
326 _Mix_channel_done_playing(i);
327 }
328 }
329
330 /* If looping the sample and we are at its end, make sure
331 we will still return a full buffer */
332 while (mix_channel[i].looping && index < len) {
333 int alen = mix_channel[i].chunk->alen;
334 remaining = len - index;
335 if (remaining > alen) {
336 remaining = alen;
337 }
338
339 mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining);
340 SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume);
341 if (mix_input != mix_channel[i].chunk->abuf)
342 SDL_free(mix_input);
343
344 if (mix_channel[i].looping > 0) {
345 --mix_channel[i].looping;
346 }
347 mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining;
348 mix_channel[i].playing = mix_channel[i].chunk->alen - remaining;
349 index += remaining;
350 }
351 if (! mix_channel[i].playing && mix_channel[i].looping) {
352 if (mix_channel[i].looping > 0) {
353 --mix_channel[i].looping;
354 }
355 mix_channel[i].samples = mix_channel[i].chunk->abuf;
356 mix_channel[i].playing = mix_channel[i].chunk->alen;
357 }
358 }
359 }
360 }
361
362 /* rcg06122001 run posteffects... */
363 Mix_DoEffects(MIX_CHANNEL_POST, stream, len);
364
365 if (mix_postmix) {
366 mix_postmix(mix_postmix_data, stream, len);
367 }
368 }
369
370 #if 0
371 static void PrintFormat(char *title, SDL_AudioSpec *fmt)
372 {
373 printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF),
374 (fmt->format&0x8000) ? "signed" : "unsigned",
375 (fmt->channels > 2) ? "surround" :
376 (fmt->channels > 1) ? "stereo" : "mono", fmt->freq);
377 }
378 #endif
379
380 /* Open the mixer with a certain desired audio format */
381 int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize,
382 const char* device, int allowed_changes)
383 {
384 int i;
385 SDL_AudioSpec desired;
386
387 /* This used to call SDL_OpenAudio(), which initializes the audio
388 subsystem if necessary. Since SDL_OpenAudioDevice() doesn't,
389 we have to handle this case here. */
390 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
391 if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
392 return -1;
393 }
394 }
395
396 /* If the mixer is already opened, increment open count */
397 if (audio_opened) {
398 if (format == mixer.format && nchannels == mixer.channels) {
399 ++audio_opened;
400 return(0);
401 }
402 while (audio_opened) {
403 Mix_CloseAudio();
404 }
405 }
406
407 /* Set the desired format and frequency */
408 desired.freq = frequency;
409 desired.format = format;
410 desired.channels = nchannels;
411 desired.samples = chunksize;
412 desired.callback = mix_channels;
413 desired.userdata = NULL;
414
415 /* Accept nearly any audio format */
416 if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) {
417 return(-1);
418 }
419 #if 0
420 PrintFormat("Audio device", &mixer);
421 #endif
422
423 num_channels = MIX_CHANNELS;
424 mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel));
425
426 /* Clear out the audio channels */
427 for (i=0; i<num_channels; ++i) {
428 mix_channel[i].chunk = NULL;
429 mix_channel[i].playing = 0;
430 mix_channel[i].looping = 0;
431 mix_channel[i].volume = SDL_MIX_MAXVOLUME;
432 mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME;
433 mix_channel[i].fade_volume_reset = SDL_MIX_MAXVOLUME;
434 mix_channel[i].fading = MIX_NO_FADING;
435 mix_channel[i].tag = -1;
436 mix_channel[i].expire = 0;
437 mix_channel[i].effects = NULL;
438 mix_channel[i].paused = 0;
439 }
440 Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
441
442 _Mix_InitEffects();
443
444 add_chunk_decoder("WAVE");
445 add_chunk_decoder("AIFF");
446 add_chunk_decoder("VOC");
447
448 /* Initialize the music players */
449 open_music(&mixer);
450
451 audio_opened = 1;
452 SDL_PauseAudioDevice(audio_device, 0);
453 return(0);
454 }
455
456 /* Open the mixer with a certain desired audio format */
457 int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
458 {
459 return Mix_OpenAudioDevice(frequency, format, nchannels, chunksize, NULL,
460 SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
461 SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
462 }
463
464 /* Dynamically change the number of channels managed by the mixer.
465 If decreasing the number of channels, the upper channels are
466 stopped.
467 */
468 int Mix_AllocateChannels(int numchans)
469 {
470 if (numchans<0 || numchans==num_channels)
471 return(num_channels);
472
473 if (numchans < num_channels) {
474 /* Stop the affected channels */
475 int i;
476 for(i=numchans; i < num_channels; i++) {
477 Mix_UnregisterAllEffects(i);
478 Mix_HaltChannel(i);
479 }
480 }
481 Mix_LockAudio();
482 mix_channel = (struct _Mix_Channel *) SDL_realloc(mix_channel, numchans * sizeof(struct _Mix_Channel));
483 if (numchans > num_channels) {
484 /* Initialize the new channels */
485 int i;
486 for(i=num_channels; i < numchans; i++) {
487 mix_channel[i].chunk = NULL;
488 mix_channel[i].playing = 0;
489 mix_channel[i].looping = 0;
490 mix_channel[i].volume = MIX_MAX_VOLUME;
491 mix_channel[i].fade_volume = MIX_MAX_VOLUME;
492 mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME;
493 mix_channel[i].fading = MIX_NO_FADING;
494 mix_channel[i].tag = -1;
495 mix_channel[i].expire = 0;
496 mix_channel[i].effects = NULL;
497 mix_channel[i].paused = 0;
498 }
499 }
500 num_channels = numchans;
501 Mix_UnlockAudio();
502 return(num_channels);
503 }
504
505 /* Return the actual mixer parameters */
506 int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels)
507 {
508 if (audio_opened) {
509 if (frequency) {
510 *frequency = mixer.freq;
511 }
512 if (format) {
513 *format = mixer.format;
514 }
515 if (channels) {
516 *channels = mixer.channels;
517 }
518 }
519 return(audio_opened);
520 }
521
522 typedef struct _MusicFragment
523 {
524 Uint8 *data;
525 int size;
526 struct _MusicFragment *next;
527 } MusicFragment;
528
529 static SDL_AudioSpec *Mix_LoadMusic_RW(Mix_MusicType music_type, SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
530 {
531 int i;
532 Mix_MusicInterface *interface = NULL;
533 void *music = NULL;
534 Sint64 start;
535 SDL_bool playing;
536 MusicFragment *first = NULL, *last = NULL, *fragment = NULL;
537 int count = 0;
538 int fragment_size;
539
540 if (!load_music_type(music_type) || !open_music_type(music_type)) {
541 return NULL;
542 }
543
544 *spec = mixer;
545
546 /* Use fragments sized on full audio frame boundaries - this'll do */
547 fragment_size = spec->size;
548
549 start = SDL_RWtell(src);
550 for (i = 0; i < get_num_music_interfaces(); ++i) {
551 interface = get_music_interface(i);
552 if (!interface->opened) {
553 continue;
554 }
555 if (interface->type != music_type) {
556 continue;
557 }
558 if (!interface->CreateFromRW || !interface->GetAudio) {
559 continue;
560 }
561
562 /* These music interfaces are not safe to use while music is playing */
563 if (interface->api == MIX_MUSIC_CMD ||
564 interface->api == MIX_MUSIC_MIKMOD ||
565 interface->api == MIX_MUSIC_NATIVEMIDI) {
566 continue;
567 }
568
569 music = interface->CreateFromRW(src, freesrc);
570 if (music) {
571 /* The interface owns the data source now */
572 freesrc = SDL_FALSE;
573 break;
574 }
575
576 /* Reset the stream for the next decoder */
577 SDL_RWseek(src, start, RW_SEEK_SET);
578 }
579
580 if (!music) {
581 if (freesrc) {
582 SDL_RWclose(src);
583 }
584 Mix_SetError("Unrecognized audio format");
585 return NULL;
586 }
587
588 Mix_LockAudio();
589
590 if (interface->Play) {
591 interface->Play(music, 1);
592 }
593 playing = SDL_TRUE;
594
595 while (playing) {
596 int left;
597
598 fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment));
599 if (!fragment) {
600 /* Uh oh, out of memory, let's return what we have */
601 break;
602 }
603 fragment->data = (Uint8 *)SDL_malloc(fragment_size);
604 if (!fragment->data) {
605 /* Uh oh, out of memory, let's return what we have */
606 SDL_free(fragment);
607 break;
608 }
609 fragment->next = NULL;
610
611 left = interface->GetAudio(music, fragment->data, fragment_size);
612 if (left > 0) {
613 playing = SDL_FALSE;
614 } else if (interface->IsPlaying) {
615 playing = interface->IsPlaying(music);
616 }
617 fragment->size = (fragment_size - left);
618
619 if (!first) {
620 first = fragment;
621 }
622 if (last) {
623 last->next = fragment;
624 }
625 last = fragment;
626 ++count;
627 }
628
629 if (interface->Stop) {
630 interface->Stop(music);
631 }
632
633 if (music) {
634 interface->Delete(music);
635 }
636
637 Mix_UnlockAudio();
638
639 if (count > 0) {
640 *audio_len = (count - 1) * fragment_size + fragment->size;
641 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
642 if (*audio_buf) {
643 Uint8 *dst = *audio_buf;
644 for (fragment = first; fragment; fragment = fragment->next) {
645 SDL_memcpy(dst, fragment->data, fragment->size);
646 dst += fragment->size;
647 }
648 } else {
649 SDL_OutOfMemory();
650 spec = NULL;
651 }
652 } else {
653 Mix_SetError("No audio data");
654 spec = NULL;
655 }
656
657 while (first) {
658 fragment = first;
659 first = first->next;
660 SDL_free(fragment->data);
661 SDL_free(fragment);
662 }
663
664 if (freesrc) {
665 SDL_RWclose(src);
666 }
667 return spec;
668 }
669
670 /* Load a wave file */
671 Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
672 {
673 Uint8 magic[4];
674 Mix_Chunk *chunk;
675 SDL_AudioSpec wavespec, *loaded;
676 SDL_AudioCVT wavecvt;
677 int samplesize;
678
679 /* rcg06012001 Make sure src is valid */
680 if (!src) {
681 SDL_SetError("Mix_LoadWAV_RW with NULL src");
682 return(NULL);
683 }
684
685 /* Make sure audio has been opened */
686 if (!audio_opened) {
687 SDL_SetError("Audio device hasn't been opened");
688 if (freesrc) {
689 SDL_RWclose(src);
690 }
691 return(NULL);
692 }
693
694 /* Allocate the chunk memory */
695 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
696 if (chunk == NULL) {
697 SDL_SetError("Out of memory");
698 if (freesrc) {
699 SDL_RWclose(src);
700 }
701 return(NULL);
702 }
703
704 /* Find out what kind of audio file this is */
705 if (SDL_RWread(src, magic, 1, 4) != 4) {
706 if (freesrc) {
707 SDL_RWclose(src);
708 }
709 Mix_SetError("Couldn't read first 4 bytes of audio data");
710 return NULL;
711 }
712 /* Seek backwards for compatibility with older loaders */
713 SDL_RWseek(src, -4, RW_SEEK_CUR);
714
715 if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) {
716 loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
717 } else if (SDL_memcmp(magic, "FORM", 4) == 0) {
718 loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
719 } else if (SDL_memcmp(magic, "Crea", 4) == 0) {
720 loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
721 } else {
722 Mix_MusicType music_type = detect_music_type_from_magic(magic);
723 loaded = Mix_LoadMusic_RW(music_type, src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
724 }
725 if (!loaded) {
726 /* The individual loaders have closed src if needed */
727 SDL_free(chunk);
728 return(NULL);
729 }
730
731 #if 0
732 PrintFormat("Audio device", &mixer);
733 PrintFormat("-- Wave file", &wavespec);
734 #endif
735
736 /* Build the audio converter and create conversion buffers */
737 if (wavespec.format != mixer.format ||
738 wavespec.channels != mixer.channels ||
739 wavespec.freq != mixer.freq) {
740 if (SDL_BuildAudioCVT(&wavecvt,
741 wavespec.format, wavespec.channels, wavespec.freq,
742 mixer.format, mixer.channels, mixer.freq) < 0) {
743 SDL_free(chunk->abuf);
744 SDL_free(chunk);
745 return(NULL);
746 }
747 samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels;
748 wavecvt.len = chunk->alen & ~(samplesize-1);
749 wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
750 if (wavecvt.buf == NULL) {
751 SDL_SetError("Out of memory");
752 SDL_free(chunk->abuf);
753 SDL_free(chunk);
754 return(NULL);
755 }
756 SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len);
757 SDL_free(chunk->abuf);
758
759 /* Run the audio converter */
760 if (SDL_ConvertAudio(&wavecvt) < 0) {
761 SDL_free(wavecvt.buf);
762 SDL_free(chunk);
763 return(NULL);
764 }
765
766 chunk->abuf = wavecvt.buf;
767 chunk->alen = wavecvt.len_cvt;
768 }
769
770 chunk->allocated = 1;
771 chunk->volume = MIX_MAX_VOLUME;
772
773 return(chunk);
774 }
775
776 /* Load a wave file of the mixer format from a memory buffer */
777 Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem)
778 {
779 Mix_Chunk *chunk;
780 Uint8 magic[4];
781
782 /* Make sure audio has been opened */
783 if (! audio_opened) {
784 SDL_SetError("Audio device hasn't been opened");
785 return(NULL);
786 }
787
788 /* Allocate the chunk memory */
789 chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk));
790 if (chunk == NULL) {
791 SDL_SetError("Out of memory");
792 return(NULL);
793 }
794
795 /* Essentially just skip to the audio data (no error checking - fast) */
796 chunk->allocated = 0;
797 mem += 12; /* WAV header */
798 do {
799 SDL_memcpy(magic, mem, 4);
800 mem += 4;
801 chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0]));
802 mem += 4;
803 chunk->abuf = mem;
804 mem += chunk->alen;
805 } while (memcmp(magic, "data", 4) != 0);
806 chunk->volume = MIX_MAX_VOLUME;
807
808 return(chunk);
809 }
810
811 /* Load raw audio data of the mixer format from a memory buffer */
812 Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len)
813 {
814 Mix_Chunk *chunk;
815
816 /* Make sure audio has been opened */
817 if (! audio_opened) {
818 SDL_SetError("Audio device hasn't been opened");
819 return(NULL);
820 }
821
822 /* Allocate the chunk memory */
823 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
824 if (chunk == NULL) {
825 SDL_SetError("Out of memory");
826 return(NULL);
827 }
828
829 /* Essentially just point at the audio data (no error checking - fast) */
830 chunk->allocated = 0;
831 chunk->alen = len;
832 chunk->abuf = mem;
833 chunk->volume = MIX_MAX_VOLUME;
834
835 return(chunk);
836 }
837
838 /* Free an audio chunk previously loaded */
839 void Mix_FreeChunk(Mix_Chunk *chunk)
840 {
841 int i;
842
843 /* Caution -- if the chunk is playing, the mixer will crash */
844 if (chunk) {
845 /* Guarantee that this chunk isn't playing */
846 Mix_LockAudio();
847 if (mix_channel) {
848 for (i=0; i<num_channels; ++i) {
849 if (chunk == mix_channel[i].chunk) {
850 mix_channel[i].playing = 0;
851 mix_channel[i].looping = 0;
852 }
853 }
854 }
855 Mix_UnlockAudio();
856 /* Actually free the chunk */
857 if (chunk->allocated) {
858 SDL_free(chunk->abuf);
859 }
860 SDL_free(chunk);
861 }
862 }
863
864 /* Set a function that is called after all mixing is performed.
865 This can be used to provide real-time visual display of the audio stream
866 or add a custom mixer filter for the stream data.
867 */
868 void Mix_SetPostMix(void (SDLCALL *mix_func)
869 (void *udata, Uint8 *stream, int len), void *arg)
870 {
871 Mix_LockAudio();
872 mix_postmix_data = arg;
873 mix_postmix = mix_func;
874 Mix_UnlockAudio();
875 }
876
877 /* Add your own music player or mixer function.
878 If 'mix_func' is NULL, the default music player is re-enabled.
879 */
880 void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len),
881 void *arg)
882 {
883 Mix_LockAudio();
884 if (mix_func != NULL) {
885 music_data = arg;
886 mix_music = mix_func;
887 } else {
888 music_data = NULL;
889 mix_music = music_mixer;
890 }
891 Mix_UnlockAudio();
892 }
893
894 void *Mix_GetMusicHookData(void)
895 {
896 return(music_data);
897 }
898
899 void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel))
900 {
901 Mix_LockAudio();
902 channel_done_callback = channel_finished;
903 Mix_UnlockAudio();
904 }
905
906
907 /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
908 them dynamically to the next sample if requested with a -1 value below.
909 Returns the number of reserved channels.
910 */
911 int Mix_ReserveChannels(int num)
912 {
913 if (num > num_channels)
914 num = num_channels;
915 reserved_channels = num;
916 return num;
917 }
918
919 static int checkchunkintegral(Mix_Chunk *chunk)
920 {
921 int frame_width = 1;
922
923 if ((mixer.format & 0xFF) == 16) frame_width = 2;
924 frame_width *= mixer.channels;
925 while (chunk->alen % frame_width) chunk->alen--;
926 return chunk->alen;
927 }
928
929 /* Play an audio chunk on a specific channel.
930 If the specified channel is -1, play on the first free channel.
931 'ticks' is the number of milliseconds at most to play the sample, or -1
932 if there is no limit.
933 Returns which channel was used to play the sound.
934 */
935 int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
936 {
937 int i;
938
939 /* Don't play null pointers :-) */
940 if (chunk == NULL) {
941 Mix_SetError("Tried to play a NULL chunk");
942 return(-1);
943 }
944 if (!checkchunkintegral(chunk)) {
945 Mix_SetError("Tried to play a chunk with a bad frame");
946 return(-1);
947 }
948
949 /* Lock the mixer while modifying the playing channels */
950 Mix_LockAudio();
951 {
952 /* If which is -1, play on the first free channel */
953 if (which == -1) {
954 for (i=reserved_channels; i<num_channels; ++i) {
955 if (mix_channel[i].playing <= 0)
956 break;
957 }
958 if (i == num_channels) {
959 Mix_SetError("No free channels available");
960 which = -1;
961 } else {
962 which = i;
963 }
964 }
965
966 /* Queue up the audio data for this channel */
967 if (which >= 0 && which < num_channels) {
968 Uint32 sdl_ticks = SDL_GetTicks();
969 if (Mix_Playing(which))
970 _Mix_channel_done_playing(which);
971 mix_channel[which].samples = chunk->abuf;
972 mix_channel[which].playing = chunk->alen;
973 mix_channel[which].looping = loops;
974 mix_channel[which].chunk = chunk;
975 mix_channel[which].paused = 0;
976 mix_channel[which].fading = MIX_NO_FADING;
977 mix_channel[which].start_time = sdl_ticks;
978 mix_channel[which].expire = (ticks>0) ? (sdl_ticks + ticks) : 0;
979 }
980 }
981 Mix_UnlockAudio();
982
983 /* Return the channel on which the sound is being played */
984 return(which);
985 }
986
987 /* Change the expiration delay for a channel */
988 int Mix_ExpireChannel(int which, int ticks)
989 {
990 int status = 0;
991
992 if (which == -1) {
993 int i;
994 for (i=0; i < num_channels; ++ i) {
995 status += Mix_ExpireChannel(i, ticks);
996 }
997 } else if (which < num_channels) {
998 Mix_LockAudio();
999 mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + ticks) : 0;
1000 Mix_UnlockAudio();
1001 ++ status;
1002 }
1003 return(status);
1004 }
1005
1006 /* Fade in a sound on a channel, over ms milliseconds */
1007 int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int ticks)
1008 {
1009 int i;
1010
1011 /* Don't play null pointers :-) */
1012 if (chunk == NULL) {
1013 return(-1);
1014 }
1015 if (!checkchunkintegral(chunk)) {
1016 Mix_SetError("Tried to play a chunk with a bad frame");
1017 return(-1);
1018 }
1019
1020 /* Lock the mixer while modifying the playing channels */
1021 Mix_LockAudio();
1022 {
1023 /* If which is -1, play on the first free channel */
1024 if (which == -1) {
1025 for (i=reserved_channels; i<num_channels; ++i) {
1026 if (mix_channel[i].playing <= 0)
1027 break;
1028 }
1029 if (i == num_channels) {
1030 which = -1;
1031 } else {
1032 which = i;
1033 }
1034 }
1035
1036 /* Queue up the audio data for this channel */
1037 if (which >= 0 && which < num_channels) {
1038 Uint32 sdl_ticks = SDL_GetTicks();
1039 if (Mix_Playing(which))
1040 _Mix_channel_done_playing(which);
1041 mix_channel[which].samples = chunk->abuf;
1042 mix_channel[which].playing = chunk->alen;
1043 mix_channel[which].looping = loops;
1044 mix_channel[which].chunk = chunk;
1045 mix_channel[which].paused = 0;
1046 mix_channel[which].fading = MIX_FADING_IN;
1047 mix_channel[which].fade_volume = mix_channel[which].volume;
1048 mix_channel[which].fade_volume_reset = mix_channel[which].volume;
1049 mix_channel[which].volume = 0;
1050 mix_channel[which].fade_length = (Uint32)ms;
1051 mix_channel[which].start_time = mix_channel[which].ticks_fade = sdl_ticks;
1052 mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+ticks) : 0;
1053 }
1054 }
1055 Mix_UnlockAudio();
1056
1057 /* Return the channel on which the sound is being played */
1058 return(which);
1059 }
1060
1061 /* Set volume of a particular channel */
1062 int Mix_Volume(int which, int volume)
1063 {
1064 int i;
1065 int prev_volume = 0;
1066
1067 if (which == -1) {
1068 for (i=0; i<num_channels; ++i) {
1069 prev_volume += Mix_Volume(i, volume);
1070 }
1071 prev_volume /= num_channels;
1072 } else if (which < num_channels) {
1073 prev_volume = mix_channel[which].volume;
1074 if (volume >= 0) {
1075 if (volume > MIX_MAX_VOLUME) {
1076 volume = MIX_MAX_VOLUME;
1077 }
1078 mix_channel[which].volume = volume;
1079 }
1080 }
1081 return(prev_volume);
1082 }
1083 /* Set volume of a particular chunk */
1084 int Mix_VolumeChunk(Mix_Chunk *chunk, int volume)
1085 {
1086 int prev_volume;
1087
1088 prev_volume = chunk->volume;
1089 if (volume >= 0) {
1090 if (volume > MIX_MAX_VOLUME) {
1091 volume = MIX_MAX_VOLUME;
1092 }
1093 chunk->volume = volume;
1094 }
1095 return(prev_volume);
1096 }
1097
1098 /* Halt playing of a particular channel */
1099 int Mix_HaltChannel(int which)
1100 {
1101 int i;
1102
1103 if (which == -1) {
1104 for (i=0; i<num_channels; ++i) {
1105 Mix_HaltChannel(i);
1106 }
1107 } else if (which < num_channels) {
1108 Mix_LockAudio();
1109 if (mix_channel[which].playing) {
1110 _Mix_channel_done_playing(which);
1111 mix_channel[which].playing = 0;
1112 mix_channel[which].looping = 0;
1113 }
1114 mix_channel[which].expire = 0;
1115 if(mix_channel[which].fading != MIX_NO_FADING) /* Restore volume */
1116 mix_channel[which].volume = mix_channel[which].fade_volume_reset;
1117 mix_channel[which].fading = MIX_NO_FADING;
1118 Mix_UnlockAudio();
1119 }
1120 return(0);
1121 }
1122
1123 /* Halt playing of a particular group of channels */
1124 int Mix_HaltGroup(int tag)
1125 {
1126 int i;
1127
1128 for (i=0; i<num_channels; ++i) {
1129 if(mix_channel[i].tag == tag) {
1130 Mix_HaltChannel(i);
1131 }
1132 }
1133 return(0);
1134 }
1135
1136 /* Fade out a channel and then stop it automatically */
1137 int Mix_FadeOutChannel(int which, int ms)
1138 {
1139 int status;
1140
1141 status = 0;
1142 if (audio_opened) {
1143 if (which == -1) {
1144 int i;
1145
1146 for (i=0; i<num_channels; ++i) {
1147 status += Mix_FadeOutChannel(i, ms);
1148 }
1149 } else if (which < num_channels) {
1150 Mix_LockAudio();
1151 if (mix_channel[which].playing &&
1152 (mix_channel[which].volume > 0) &&
1153 (mix_channel[which].fading != MIX_FADING_OUT)) {
1154 mix_channel[which].fade_volume = mix_channel[which].volume;
1155 mix_channel[which].fading = MIX_FADING_OUT;
1156 mix_channel[which].fade_length = (Uint32)ms;
1157 mix_channel[which].ticks_fade = SDL_GetTicks();
1158
1159 /* only change fade_volume_reset if we're not fading. */
1160 if (mix_channel[which].fading == MIX_NO_FADING) {
1161 mix_channel[which].fade_volume_reset = mix_channel[which].volume;
1162 }
1163 ++status;
1164 }
1165 Mix_UnlockAudio();
1166 }
1167 }
1168 return(status);
1169 }
1170
1171 /* Halt playing of a particular group of channels */
1172 int Mix_FadeOutGroup(int tag, int ms)
1173 {
1174 int i;
1175 int status = 0;
1176 for (i=0; i<num_channels; ++i) {
1177 if(mix_channel[i].tag == tag) {
1178 status += Mix_FadeOutChannel(i,ms);
1179 }
1180 }
1181 return(status);
1182 }
1183
1184 Mix_Fading Mix_FadingChannel(int which)
1185 {
1186 if (which < 0 || which >= num_channels) {
1187 return MIX_NO_FADING;
1188 }
1189 return mix_channel[which].fading;
1190 }
1191
1192 /* Check the status of a specific channel.
1193 If the specified mix_channel is -1, check all mix channels.
1194 */
1195 int Mix_Playing(int which)
1196 {
1197 int status;
1198
1199 status = 0;
1200 if (which == -1) {
1201 int i;
1202
1203 for (i=0; i<num_channels; ++i) {
1204 if ((mix_channel[i].playing > 0) ||
1205 mix_channel[i].looping)
1206 {
1207 ++status;
1208 }
1209 }
1210 } else if (which < num_channels) {
1211 if ((mix_channel[which].playing > 0) ||
1212 mix_channel[which].looping)
1213 {
1214 ++status;
1215 }
1216 }
1217 return(status);
1218 }
1219
1220 /* rcg06072001 Get the chunk associated with a channel. */
1221 Mix_Chunk *Mix_GetChunk(int channel)
1222 {
1223 Mix_Chunk *retval = NULL;
1224
1225 if ((channel >= 0) && (channel < num_channels)) {
1226 retval = mix_channel[channel].chunk;
1227 }
1228
1229 return(retval);
1230 }
1231
1232 /* Close the mixer, halting all playing audio */
1233 void Mix_CloseAudio(void)
1234 {
1235 int i;
1236
1237 if (audio_opened) {
1238 if (audio_opened == 1) {
1239 for (i = 0; i < num_channels; i++) {
1240 Mix_UnregisterAllEffects(i);
1241 }
1242 Mix_UnregisterAllEffects(MIX_CHANNEL_POST);
1243 close_music();
1244 Mix_SetMusicCMD(NULL);
1245 Mix_HaltChannel(-1);
1246 _Mix_DeinitEffects();
1247 SDL_CloseAudioDevice(audio_device);
1248 audio_device = 0;
1249 SDL_free(mix_channel);
1250 mix_channel = NULL;
1251
1252 /* rcg06042009 report available decoders at runtime. */
1253 SDL_free((void *)chunk_decoders);
1254 chunk_decoders = NULL;
1255 num_decoders = 0;
1256 }
1257 --audio_opened;
1258 }
1259 }
1260
1261 /* Pause a particular channel (or all) */
1262 void Mix_Pause(int which)
1263 {
1264 Uint32 sdl_ticks = SDL_GetTicks();
1265 if (which == -1) {
1266 int i;
1267
1268 for (i=0; i<num_channels; ++i) {
1269 if (mix_channel[i].playing > 0) {
1270 mix_channel[i].paused = sdl_ticks;
1271 }
1272 }
1273 } else if (which < num_channels) {
1274 if (mix_channel[which].playing > 0) {
1275 mix_channel[which].paused = sdl_ticks;
1276 }
1277 }
1278 }
1279
1280 /* Resume a paused channel */
1281 void Mix_Resume(int which)
1282 {
1283 Uint32 sdl_ticks = SDL_GetTicks();
1284
1285 Mix_LockAudio();
1286 if (which == -1) {
1287 int i;
1288
1289 for (i=0; i<num_channels; ++i) {
1290 if (mix_channel[i].playing > 0) {
1291 if(mix_channel[i].expire > 0)
1292 mix_channel[i].expire += sdl_ticks - mix_channel[i].paused;
1293 mix_channel[i].paused = 0;
1294 }
1295 }
1296 } else if (which < num_channels) {
1297 if (mix_channel[which].playing > 0) {
1298 if(mix_channel[which].expire > 0)
1299 mix_channel[which].expire += sdl_ticks - mix_channel[which].paused;
1300 mix_channel[which].paused = 0;
1301 }
1302 }
1303 Mix_UnlockAudio();
1304 }
1305
1306 int Mix_Paused(int which)
1307 {
1308 if (which < 0) {
1309 int status = 0;
1310 int i;
1311 for(i=0; i < num_channels; ++i) {
1312 if (mix_channel[i].paused) {
1313 ++ status;
1314 }
1315 }
1316 return(status);
1317 } else if (which < num_channels) {
1318 return(mix_channel[which].paused != 0);
1319 } else {
1320 return(0);
1321 }
1322 }
1323
1324 /* Change the group of a channel */
1325 int Mix_GroupChannel(int which, int tag)
1326 {
1327 if (which < 0 || which > num_channels)
1328 return(0);
1329
1330 Mix_LockAudio();
1331 mix_channel[which].tag = tag;
1332 Mix_UnlockAudio();
1333 return(1);
1334 }
1335
1336 /* Assign several consecutive channels to a group */
1337 int Mix_GroupChannels(int from, int to, int tag)
1338 {
1339 int status = 0;
1340 for(; from <= to; ++ from) {
1341 status += Mix_GroupChannel(from, tag);
1342 }
1343 return(status);
1344 }
1345
1346 /* Finds the first available channel in a group of channels */
1347 int Mix_GroupAvailable(int tag)
1348 {
1349 int i;
1350 for(i=0; i < num_channels; i ++) {
1351 if (((tag == -1) || (tag == mix_channel[i].tag)) &&
1352 (mix_channel[i].playing <= 0))
1353 return i;
1354 }
1355 return(-1);
1356 }
1357
1358 int Mix_GroupCount(int tag)
1359 {
1360 int count = 0;
1361 int i;
1362 for(i=0; i < num_channels; i ++) {
1363 if (mix_channel[i].tag==tag || tag==-1)
1364 ++ count;
1365 }
1366 return(count);
1367 }
1368
1369 /* Finds the "oldest" sample playing in a group of channels */
1370 int Mix_GroupOldest(int tag)
1371 {
1372 int chan = -1;
1373 Uint32 mintime = SDL_GetTicks();
1374 int i;
1375 for(i=0; i < num_channels; i ++) {
1376 if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
1377 && mix_channel[i].start_time <= mintime) {
1378 mintime = mix_channel[i].start_time;
1379 chan = i;
1380 }
1381 }
1382 return(chan);
1383 }
1384
1385 /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
1386 int Mix_GroupNewer(int tag)
1387 {
1388 int chan = -1;
1389 Uint32 maxtime = 0;
1390 int i;
1391 for(i=0; i < num_channels; i ++) {
1392 if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
1393 && mix_channel[i].start_time >= maxtime) {
1394 maxtime = mix_channel[i].start_time;
1395 chan = i;
1396 }
1397 }
1398 return(chan);
1399 }
1400
1401
1402
1403 /*
1404 * rcg06122001 The special effects exportable API.
1405 * Please see effect_*.c for internally-implemented effects, such
1406 * as Mix_SetPanning().
1407 */
1408
1409 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1410 static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f,
1411 Mix_EffectDone_t d, void *arg)
1412 {
1413 effect_info *new_e;
1414
1415 if (!e) {
1416 Mix_SetError("Internal error");
1417 return(0);
1418 }
1419
1420 if (f == NULL) {
1421 Mix_SetError("NULL effect callback");
1422 return(0);
1423 }
1424
1425 new_e = SDL_malloc(sizeof (effect_info));
1426 if (new_e == NULL) {
1427 Mix_SetError("Out of memory");
1428 return(0);
1429 }
1430
1431 new_e->callback = f;
1432 new_e->done_callback = d;
1433 new_e->udata = arg;
1434 new_e->next = NULL;
1435
1436 /* add new effect to end of linked list... */
1437 if (*e == NULL) {
1438 *e = new_e;
1439 } else {
1440 effect_info *cur = *e;
1441 while (1) {
1442 if (cur->next == NULL) {
1443 cur->next = new_e;
1444 break;
1445 }
1446 cur = cur->next;
1447 }
1448 }
1449
1450 return(1);
1451 }
1452
1453
1454 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1455 static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f)
1456 {
1457 effect_info *cur;
1458 effect_info *prev = NULL;
1459 effect_info *next = NULL;
1460
1461 if (!e) {
1462 Mix_SetError("Internal error");
1463 return(0);
1464 }
1465
1466 for (cur = *e; cur != NULL; cur = cur->next) {
1467 if (cur->callback == f) {
1468 next = cur->next;
1469 if (cur->done_callback != NULL) {
1470 cur->done_callback(channel, cur->udata);
1471 }
1472 SDL_free(cur);
1473
1474 if (prev == NULL) { /* removing first item of list? */
1475 *e = next;
1476 } else {
1477 prev->next = next;
1478 }
1479 return(1);
1480 }
1481 prev = cur;
1482 }
1483
1484 Mix_SetError("No such effect registered");
1485 return(0);
1486 }
1487
1488
1489 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1490 static int _Mix_remove_all_effects(int channel, effect_info **e)
1491 {
1492 effect_info *cur;
1493 effect_info *next;
1494
1495 if (!e) {
1496 Mix_SetError("Internal error");
1497 return(0);
1498 }
1499
1500 for (cur = *e; cur != NULL; cur = next) {
1501 next = cur->next;
1502 if (cur->done_callback != NULL) {
1503 cur->done_callback(channel, cur->udata);
1504 }
1505 SDL_free(cur);
1506 }
1507 *e = NULL;
1508
1509 return(1);
1510 }
1511
1512
1513 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1514 int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
1515 Mix_EffectDone_t d, void *arg)
1516 {
1517 effect_info **e = NULL;
1518
1519 if (channel == MIX_CHANNEL_POST) {
1520 e = &posteffects;
1521 } else {
1522 if ((channel < 0) || (channel >= num_channels)) {
1523 Mix_SetError("Invalid channel number");
1524 return(0);
1525 }
1526 e = &mix_channel[channel].effects;
1527 }
1528
1529 return _Mix_register_effect(e, f, d, arg);
1530 }
1531
1532 int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f,
1533 Mix_EffectDone_t d, void *arg)
1534 {
1535 int retval;
1536 Mix_LockAudio();
1537 retval = _Mix_RegisterEffect_locked(channel, f, d, arg);
1538 Mix_UnlockAudio();
1539 return retval;
1540 }
1541
1542
1543 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1544 int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f)
1545 {
1546 effect_info **e = NULL;
1547
1548 if (channel == MIX_CHANNEL_POST) {
1549 e = &posteffects;
1550 } else {
1551 if ((channel < 0) || (channel >= num_channels)) {
1552 Mix_SetError("Invalid channel number");
1553 return(0);
1554 }
1555 e = &mix_channel[channel].effects;
1556 }
1557
1558 return _Mix_remove_effect(channel, e, f);
1559 }
1560
1561 int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
1562 {
1563 int retval;
1564 Mix_LockAudio();
1565 retval = _Mix_UnregisterEffect_locked(channel, f);
1566 Mix_UnlockAudio();
1567 return(retval);
1568 }
1569
1570 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1571 int _Mix_UnregisterAllEffects_locked(int channel)
1572 {
1573 effect_info **e = NULL;
1574
1575 if (channel == MIX_CHANNEL_POST) {
1576 e = &posteffects;
1577 } else {
1578 if ((channel < 0) || (channel >= num_channels)) {
1579 Mix_SetError("Invalid channel number");
1580 return(0);
1581 }
1582 e = &mix_channel[channel].effects;
1583 }
1584
1585 return _Mix_remove_all_effects(channel, e);
1586 }
1587
1588 int Mix_UnregisterAllEffects(int channel)
1589 {
1590 int retval;
1591 Mix_LockAudio();
1592 retval = _Mix_UnregisterAllEffects_locked(channel);
1593 Mix_UnlockAudio();
1594 return(retval);
1595 }
1596
1597 void Mix_LockAudio(void)
1598 {
1599 SDL_LockAudioDevice(audio_device);
1600 }
1601
1602 void Mix_UnlockAudio(void)
1603 {
1604 SDL_UnlockAudioDevice(audio_device);
1605 }
1606
1607 /* end of mixer.c ... */
1608
1609 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
mixer.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* Locking wrapper functions */
22 extern void Mix_LockAudio(void);
23 extern void Mix_UnlockAudio(void);
24
25 extern void add_chunk_decoder(const char *decoder);
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-1141
music.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include <string.h> /* for strtok() and strtok_s() */
21
22 #include "SDL_hints.h"
23 #include "SDL_log.h"
24 #include "SDL_timer.h"
25
26 #include "SDL_mixer.h"
27 #include "mixer.h"
28 #include "music.h"
29
30 #include "music_cmd.h"
31 #include "music_wav.h"
32 #include "music_mikmod.h"
33 #include "music_modplug.h"
34 #include "music_nativemidi.h"
35 #include "music_fluidsynth.h"
36 #include "music_timidity.h"
37 #include "music_ogg.h"
38 #include "music_opus.h"
39 #include "music_mpg123.h"
40 #include "music_mad.h"
41 #include "music_flac.h"
42 #include "native_midi/native_midi.h"
43
44 /* Check to make sure we are building with a new enough SDL */
45 #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 7)
46 #error You need SDL 2.0.7 or newer from http://www.libsdl.org
47 #endif
48
49 /* Set this hint to true if you want verbose logging of music interfaces */
50 #define SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES \
51 "SDL_MIXER_DEBUG_MUSIC_INTERFACES"
52
53 char *music_cmd = NULL;
54 static SDL_bool music_active = SDL_TRUE;
55 static int music_volume = MIX_MAX_VOLUME;
56 static Mix_Music * volatile music_playing = NULL;
57 SDL_AudioSpec music_spec;
58
59 struct _Mix_Music {
60 Mix_MusicInterface *interface;
61 void *context;
62
63 SDL_bool playing;
64 Mix_Fading fading;
65 int fade_step;
66 int fade_steps;
67 };
68
69 /* Used to calculate fading steps */
70 static int ms_per_step;
71
72 /* rcg06042009 report available decoders at runtime. */
73 static const char **music_decoders = NULL;
74 static int num_decoders = 0;
75
76 /* Semicolon-separated SoundFont paths */
77 static char* soundfont_paths = NULL;
78
79 /* Interfaces for the various music interfaces, ordered by priority */
80 static Mix_MusicInterface *s_music_interfaces[] =
81 {
82 #ifdef MUSIC_CMD
83 &Mix_MusicInterface_CMD,
84 #endif
85 #ifdef MUSIC_WAV
86 &Mix_MusicInterface_WAV,
87 #endif
88 #ifdef MUSIC_FLAC
89 &Mix_MusicInterface_FLAC,
90 #endif
91 #ifdef MUSIC_OGG
92 &Mix_MusicInterface_OGG,
93 #endif
94 #ifdef MUSIC_OPUS
95 &Mix_MusicInterface_Opus,
96 #endif
97 #ifdef MUSIC_MP3_MPG123
98 &Mix_MusicInterface_MPG123,
99 #endif
100 #ifdef MUSIC_MP3_MAD
101 &Mix_MusicInterface_MAD,
102 #endif
103 #ifdef MUSIC_MOD_MODPLUG
104 &Mix_MusicInterface_MODPLUG,
105 #endif
106 #ifdef MUSIC_MOD_MIKMOD
107 &Mix_MusicInterface_MIKMOD,
108 #endif
109 #ifdef MUSIC_MID_FLUIDSYNTH
110 &Mix_MusicInterface_FLUIDSYNTH,
111 #endif
112 #ifdef MUSIC_MID_TIMIDITY
113 &Mix_MusicInterface_TIMIDITY,
114 #endif
115 #ifdef MUSIC_MID_NATIVE
116 &Mix_MusicInterface_NATIVEMIDI,
117 #endif
118 };
119
120 int get_num_music_interfaces(void)
121 {
122 return SDL_arraysize(s_music_interfaces);
123 }
124
125 Mix_MusicInterface *get_music_interface(int index)
126 {
127 return s_music_interfaces[index];
128 }
129
130 int Mix_GetNumMusicDecoders(void)
131 {
132 return(num_decoders);
133 }
134
135 const char *Mix_GetMusicDecoder(int index)
136 {
137 if ((index < 0) || (index >= num_decoders)) {
138 return NULL;
139 }
140 return(music_decoders[index]);
141 }
142
143 static void add_music_decoder(const char *decoder)
144 {
145 void *ptr;
146 int i;
147
148 /* Check to see if we already have this decoder */
149 for (i = 0; i < num_decoders; ++i) {
150 if (SDL_strcmp(music_decoders[i], decoder) == 0) {
151 return;
152 }
153 }
154
155 ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *));
156 if (ptr == NULL) {
157 return; /* oh well, go on without it. */
158 }
159 music_decoders = (const char **) ptr;
160 music_decoders[num_decoders++] = decoder;
161 }
162
163 /* Local low-level functions prototypes */
164 static void music_internal_initialize_volume(void);
165 static void music_internal_volume(int volume);
166 static int music_internal_play(Mix_Music *music, int play_count, double position);
167 static int music_internal_position(double position);
168 static SDL_bool music_internal_playing(void);
169 static void music_internal_halt(void);
170
171
172 /* Support for hooking when the music has finished */
173 static void (SDLCALL *music_finished_hook)(void) = NULL;
174
175 void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void))
176 {
177 Mix_LockAudio();
178 music_finished_hook = music_finished;
179 Mix_UnlockAudio();
180 }
181
182 /* Convenience function to fill audio and mix at the specified volume
183 This is called from many music player's GetAudio callback.
184 */
185 int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
186 int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done))
187 {
188 Uint8 *snd = (Uint8 *)data;
189 Uint8 *dst;
190 int len = bytes;
191 SDL_bool done = SDL_FALSE;
192
193 if (volume == MIX_MAX_VOLUME) {
194 dst = snd;
195 } else {
196 dst = SDL_stack_alloc(Uint8, bytes);
197 }
198 while (len > 0 && !done) {
199 int consumed = GetSome(context, dst, len, &done);
200 if (consumed < 0) {
201 break;
202 }
203
204 if (volume == MIX_MAX_VOLUME) {
205 dst += consumed;
206 } else {
207 SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume);
208 snd += consumed;
209 }
210 len -= consumed;
211 }
212 if (volume != MIX_MAX_VOLUME) {
213 SDL_stack_free(dst);
214 }
215 return len;
216 }
217
218 /* Mixing function */
219 void SDLCALL music_mixer(void *udata, Uint8 *stream, int len)
220 {
221 while (music_playing && music_active && len > 0) {
222 /* Handle fading */
223 if (music_playing->fading != MIX_NO_FADING) {
224 if (music_playing->fade_step++ < music_playing->fade_steps) {
225 int volume;
226 int fade_step = music_playing->fade_step;
227 int fade_steps = music_playing->fade_steps;
228
229 if (music_playing->fading == MIX_FADING_OUT) {
230 volume = (music_volume * (fade_steps-fade_step)) / fade_steps;
231 } else { /* Fading in */
232 volume = (music_volume * fade_step) / fade_steps;
233 }
234 music_internal_volume(volume);
235 } else {
236 if (music_playing->fading == MIX_FADING_OUT) {
237 music_internal_halt();
238 if (music_finished_hook) {
239 music_finished_hook();
240 }
241 return;
242 }
243 music_playing->fading = MIX_NO_FADING;
244 }
245 }
246
247 if (music_playing->interface->GetAudio) {
248 int left = music_playing->interface->GetAudio(music_playing->context, stream, len);
249 if (left != 0) {
250 /* Either an error or finished playing with data left */
251 music_playing->playing = SDL_FALSE;
252 }
253 if (left > 0) {
254 stream += (len - left);
255 len = left;
256 } else {
257 len = 0;
258 }
259 } else {
260 len = 0;
261 }
262
263 if (!music_internal_playing()) {
264 music_internal_halt();
265 if (music_finished_hook) {
266 music_finished_hook();
267 }
268 }
269 }
270 }
271
272 /* Load the music interface libraries for a given music type */
273 SDL_bool load_music_type(Mix_MusicType type)
274 {
275 int i, loaded = 0;
276 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
277 Mix_MusicInterface *interface = s_music_interfaces[i];
278 if (interface->type != type) {
279 continue;
280 }
281 if (!interface->loaded) {
282 char hint[64];
283 SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag);
284 if (SDL_GetHintBoolean(hint, SDL_FALSE)) {
285 continue;
286 }
287
288 if (interface->Load && interface->Load() < 0) {
289 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
290 SDL_Log("Couldn't load %s: %s\n", interface->tag, Mix_GetError());
291 }
292 continue;
293 }
294 interface->loaded = SDL_TRUE;
295 }
296 ++loaded;
297 }
298 return (loaded > 0) ? SDL_TRUE : SDL_FALSE;
299 }
300
301 /* Open the music interfaces for a given music type */
302 SDL_bool open_music_type(Mix_MusicType type)
303 {
304 int i, opened = 0;
305 SDL_bool use_native_midi = SDL_FALSE;
306
307 if (!music_spec.format) {
308 /* Music isn't opened yet */
309 return SDL_FALSE;
310 }
311
312 #ifdef MUSIC_MID_NATIVE
313 if (type == MUS_MID && SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) {
314 use_native_midi = SDL_TRUE;
315 }
316 #endif
317
318 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
319 Mix_MusicInterface *interface = s_music_interfaces[i];
320 if (!interface->loaded) {
321 continue;
322 }
323 if (type != MUS_NONE && interface->type != type) {
324 continue;
325 }
326
327 if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) {
328 continue;
329 }
330
331 if (!interface->opened) {
332 if (interface->Open && interface->Open(&music_spec) < 0) {
333 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
334 SDL_Log("Couldn't open %s: %s\n", interface->tag, Mix_GetError());
335 }
336 continue;
337 }
338 interface->opened = SDL_TRUE;
339 add_music_decoder(interface->tag);
340 }
341 ++opened;
342 }
343
344 if (has_music(MUS_MOD)) {
345 add_music_decoder("MOD");
346 add_chunk_decoder("MOD");
347 }
348 if (has_music(MUS_MID)) {
349 add_music_decoder("MIDI");
350 add_chunk_decoder("MID");
351 }
352 if (has_music(MUS_OGG)) {
353 add_music_decoder("OGG");
354 add_chunk_decoder("OGG");
355 }
356 if (has_music(MUS_OPUS)) {
357 add_music_decoder("OPUS");
358 add_chunk_decoder("OPUS");
359 }
360 if (has_music(MUS_MP3)) {
361 add_music_decoder("MP3");
362 add_chunk_decoder("MP3");
363 }
364 if (has_music(MUS_FLAC)) {
365 add_music_decoder("FLAC");
366 add_chunk_decoder("FLAC");
367 }
368
369 return (opened > 0) ? SDL_TRUE : SDL_FALSE;
370 }
371
372 /* Initialize the music interfaces with a certain desired audio format */
373 void open_music(const SDL_AudioSpec *spec)
374 {
375 #ifdef MIX_INIT_SOUNDFONT_PATHS
376 if (!soundfont_paths) {
377 soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS);
378 }
379 #endif
380
381 /* Load the music interfaces that don't have explicit initialization */
382 load_music_type(MUS_CMD);
383 load_music_type(MUS_WAV);
384
385 /* Open all the interfaces that are loaded */
386 music_spec = *spec;
387 open_music_type(MUS_NONE);
388
389 Mix_VolumeMusic(MIX_MAX_VOLUME);
390
391 /* Calculate the number of ms for each callback */
392 ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq);
393 }
394
395 /* Return SDL_TRUE if the music type is available */
396 SDL_bool has_music(Mix_MusicType type)
397 {
398 int i;
399 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
400 Mix_MusicInterface *interface = s_music_interfaces[i];
401 if (interface->type != type) {
402 continue;
403 }
404 if (interface->opened) {
405 return SDL_TRUE;
406 }
407 }
408 return SDL_FALSE;
409 }
410
411 Mix_MusicType detect_music_type_from_magic(const Uint8 *magic)
412 {
413 /* Ogg Vorbis files have the magic four bytes "OggS" */
414 if (SDL_memcmp(magic, "OggS", 4) == 0) {
415 return MUS_OGG;
416 }
417
418 /* FLAC files have the magic four bytes "fLaC" */
419 if (SDL_memcmp(magic, "fLaC", 4) == 0) {
420 return MUS_FLAC;
421 }
422
423 /* MIDI files have the magic four bytes "MThd" */
424 if (SDL_memcmp(magic, "MThd", 4) == 0) {
425 return MUS_MID;
426 }
427
428 if (SDL_memcmp(magic, "ID3", 3) == 0 ||
429 (magic[0] == 0xFF && (magic[1] & 0xFE) == 0xFA)) {
430 return MUS_MP3;
431 }
432
433 /* Assume MOD format.
434 *
435 * Apparently there is no way to check if the file is really a MOD,
436 * or there are too many formats supported by MikMod/ModPlug, or
437 * MikMod/ModPlug does this check by itself. */
438 return MUS_MOD;
439 }
440
441 static Mix_MusicType detect_music_type(SDL_RWops *src)
442 {
443 Uint8 magic[12];
444 Mix_MusicType t;
445
446 if (SDL_RWread(src, magic, 1, 12) != 12) {
447 Mix_SetError("Couldn't read first 12 bytes of audio data");
448 return MUS_NONE;
449 }
450 SDL_RWseek(src, -12, RW_SEEK_CUR);
451
452 /* WAVE files have the magic four bytes "RIFF"
453 AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */
454 if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) ||
455 (SDL_memcmp(magic, "FORM", 4) == 0)) {
456 return MUS_WAV;
457 }
458 t = detect_music_type_from_magic(magic);
459 if (t == MUS_OGG) {
460 Sint64 pos = SDL_RWtell(src);
461 SDL_RWseek(src, 28, RW_SEEK_CUR);
462 SDL_RWread(src, magic, 1, 8);
463 SDL_RWseek(src, pos, RW_SEEK_SET);
464 if (SDL_memcmp(magic, "OpusHead", 8) == 0) {
465 return MUS_OPUS;
466 }
467 }
468 return t;
469 }
470
471 /* Load a music file */
472 Mix_Music *Mix_LoadMUS(const char *file)
473 {
474 int i;
475 void *context;
476 char *ext;
477 Mix_MusicType type;
478 SDL_RWops *src;
479
480 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
481 Mix_MusicInterface *interface = s_music_interfaces[i];
482 if (!interface->opened || !interface->CreateFromFile) {
483 continue;
484 }
485
486 context = interface->CreateFromFile(file);
487 if (context) {
488 /* Allocate memory for the music structure */
489 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
490 if (music == NULL) {
491 Mix_SetError("Out of memory");
492 return NULL;
493 }
494 music->interface = interface;
495 music->context = context;
496 return music;
497 }
498 }
499
500 src = SDL_RWFromFile(file, "rb");
501 if (src == NULL) {
502 Mix_SetError("Couldn't open '%s'", file);
503 return NULL;
504 }
505
506 /* Use the extension as a first guess on the file type */
507 type = MUS_NONE;
508 ext = strrchr(file, '.');
509 if (ext) {
510 ++ext; /* skip the dot in the extension */
511 if (SDL_strcasecmp(ext, "WAV") == 0) {
512 type = MUS_WAV;
513 } else if (SDL_strcasecmp(ext, "MID") == 0 ||
514 SDL_strcasecmp(ext, "MIDI") == 0 ||
515 SDL_strcasecmp(ext, "KAR") == 0) {
516 type = MUS_MID;
517 } else if (SDL_strcasecmp(ext, "OGG") == 0) {
518 type = MUS_OGG;
519 } else if (SDL_strcasecmp(ext, "OPUS") == 0) {
520 type = MUS_OPUS;
521 } else if (SDL_strcasecmp(ext, "FLAC") == 0) {
522 type = MUS_FLAC;
523 } else if (SDL_strcasecmp(ext, "MPG") == 0 ||
524 SDL_strcasecmp(ext, "MPEG") == 0 ||
525 SDL_strcasecmp(ext, "MP3") == 0 ||
526 SDL_strcasecmp(ext, "MAD") == 0) {
527 type = MUS_MP3;
528 } else if (SDL_strcasecmp(ext, "669") == 0 ||
529 SDL_strcasecmp(ext, "AMF") == 0 ||
530 SDL_strcasecmp(ext, "AMS") == 0 ||
531 SDL_strcasecmp(ext, "DBM") == 0 ||
532 SDL_strcasecmp(ext, "DSM") == 0 ||
533 SDL_strcasecmp(ext, "FAR") == 0 ||
534 SDL_strcasecmp(ext, "IT") == 0 ||
535 SDL_strcasecmp(ext, "MED") == 0 ||
536 SDL_strcasecmp(ext, "MDL") == 0 ||
537 SDL_strcasecmp(ext, "MOD") == 0 ||
538 SDL_strcasecmp(ext, "MOL") == 0 ||
539 SDL_strcasecmp(ext, "MTM") == 0 ||
540 SDL_strcasecmp(ext, "NST") == 0 ||
541 SDL_strcasecmp(ext, "OKT") == 0 ||
542 SDL_strcasecmp(ext, "PTM") == 0 ||
543 SDL_strcasecmp(ext, "S3M") == 0 ||
544 SDL_strcasecmp(ext, "STM") == 0 ||
545 SDL_strcasecmp(ext, "ULT") == 0 ||
546 SDL_strcasecmp(ext, "UMX") == 0 ||
547 SDL_strcasecmp(ext, "WOW") == 0 ||
548 SDL_strcasecmp(ext, "XM") == 0) {
549 type = MUS_MOD;
550 }
551 }
552 return Mix_LoadMUSType_RW(src, type, SDL_TRUE);
553 }
554
555 Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
556 {
557 return Mix_LoadMUSType_RW(src, MUS_NONE, freesrc);
558 }
559
560 Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc)
561 {
562 int i;
563 void *context;
564 Sint64 start;
565
566 if (!src) {
567 Mix_SetError("RWops pointer is NULL");
568 return NULL;
569 }
570 start = SDL_RWtell(src);
571
572 /* If the caller wants auto-detection, figure out what kind of file
573 * this is. */
574 if (type == MUS_NONE) {
575 if ((type = detect_music_type(src)) == MUS_NONE) {
576 /* Don't call Mix_SetError() since detect_music_type() does that. */
577 if (freesrc) {
578 SDL_RWclose(src);
579 }
580 return NULL;
581 }
582 }
583
584 Mix_ClearError();
585
586 if (load_music_type(type) && open_music_type(type)) {
587 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
588 Mix_MusicInterface *interface = s_music_interfaces[i];
589 if (!interface->opened || type != interface->type || !interface->CreateFromRW) {
590 continue;
591 }
592
593 context = interface->CreateFromRW(src, freesrc);
594 if (context) {
595 /* Allocate memory for the music structure */
596 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
597 if (music == NULL) {
598 interface->Delete(context);
599 Mix_SetError("Out of memory");
600 return NULL;
601 }
602 music->interface = interface;
603 music->context = context;
604
605 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
606 SDL_Log("Loaded music with %s\n", interface->tag);
607 }
608 return music;
609 }
610
611 /* Reset the stream for the next decoder */
612 SDL_RWseek(src, start, RW_SEEK_SET);
613 }
614 }
615
616 if (!*Mix_GetError()) {
617 Mix_SetError("Unrecognized audio format");
618 }
619 if (freesrc) {
620 SDL_RWclose(src);
621 } else {
622 SDL_RWseek(src, start, RW_SEEK_SET);
623 }
624 return NULL;
625 }
626
627 /* Free a music chunk previously loaded */
628 void Mix_FreeMusic(Mix_Music *music)
629 {
630 if (music) {
631 /* Stop the music if it's currently playing */
632 Mix_LockAudio();
633 if (music == music_playing) {
634 /* Wait for any fade out to finish */
635 while (music->fading == MIX_FADING_OUT) {
636 Mix_UnlockAudio();
637 SDL_Delay(100);
638 Mix_LockAudio();
639 }
640 if (music == music_playing) {
641 music_internal_halt();
642 }
643 }
644 Mix_UnlockAudio();
645
646 music->interface->Delete(music->context);
647 SDL_free(music);
648 }
649 }
650
651 /* Find out the music format of a mixer music, or the currently playing
652 music, if 'music' is NULL.
653 */
654 Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
655 {
656 Mix_MusicType type = MUS_NONE;
657
658 if (music) {
659 type = music->interface->type;
660 } else {
661 Mix_LockAudio();
662 if (music_playing) {
663 type = music_playing->interface->type;
664 }
665 Mix_UnlockAudio();
666 }
667 return(type);
668 }
669
670 /* Play a music chunk. Returns 0, or -1 if there was an error.
671 */
672 static int music_internal_play(Mix_Music *music, int play_count, double position)
673 {
674 int retval = 0;
675
676 #if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE)
677 /* This fixes a bug with native MIDI on Mac OS X, where you
678 can't really stop and restart MIDI from the audio callback.
679 */
680 if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) {
681 /* Just a seek suffices to restart playing */
682 music_internal_position(position);
683 return 0;
684 }
685 #endif
686
687 /* Note the music we're playing */
688 if (music_playing) {
689 music_internal_halt();
690 }
691 music_playing = music;
692 music_playing->playing = SDL_TRUE;
693
694 /* Set the initial volume */
695 music_internal_initialize_volume();
696
697 /* Set up for playback */
698 retval = music->interface->Play(music->context, play_count);
699
700 /* Set the playback position, note any errors if an offset is used */
701 if (retval == 0) {
702 if (position > 0.0) {
703 if (music_internal_position(position) < 0) {
704 Mix_SetError("Position not implemented for music type");
705 retval = -1;
706 }
707 } else {
708 music_internal_position(0.0);
709 }
710 }
711
712 /* If the setup failed, we're not playing any music anymore */
713 if (retval < 0) {
714 music->playing = SDL_FALSE;
715 music_playing = NULL;
716 }
717 return(retval);
718 }
719
720 int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
721 {
722 int retval;
723
724 if (ms_per_step == 0) {
725 SDL_SetError("Audio device hasn't been opened");
726 return(-1);
727 }
728
729 /* Don't play null pointers :-) */
730 if (music == NULL) {
731 Mix_SetError("music parameter was NULL");
732 return(-1);
733 }
734
735 /* Setup the data */
736 if (ms) {
737 music->fading = MIX_FADING_IN;
738 } else {
739 music->fading = MIX_NO_FADING;
740 }
741 music->fade_step = 0;
742 music->fade_steps = ms/ms_per_step;
743
744 /* Play the puppy */
745 Mix_LockAudio();
746 /* If the current music is fading out, wait for the fade to complete */
747 while (music_playing && (music_playing->fading == MIX_FADING_OUT)) {
748 Mix_UnlockAudio();
749 SDL_Delay(100);
750 Mix_LockAudio();
751 }
752 if (loops == 0) {
753 /* Loop is the number of times to play the audio */
754 loops = 1;
755 }
756 retval = music_internal_play(music, loops, position);
757 music_active = (retval == 0);
758 Mix_UnlockAudio();
759
760 return(retval);
761 }
762 int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
763 {
764 return Mix_FadeInMusicPos(music, loops, ms, 0.0);
765 }
766 int Mix_PlayMusic(Mix_Music *music, int loops)
767 {
768 return Mix_FadeInMusicPos(music, loops, 0, 0.0);
769 }
770
771 /* Set the playing music position */
772 int music_internal_position(double position)
773 {
774 if (music_playing->interface->Seek) {
775 return music_playing->interface->Seek(music_playing->context, position);
776 }
777 return -1;
778 }
779 int Mix_SetMusicPosition(double position)
780 {
781 int retval;
782
783 Mix_LockAudio();
784 if (music_playing) {
785 retval = music_internal_position(position);
786 if (retval < 0) {
787 Mix_SetError("Position not implemented for music type");
788 }
789 } else {
790 Mix_SetError("Music isn't playing");
791 retval = -1;
792 }
793 Mix_UnlockAudio();
794
795 return(retval);
796 }
797
798 /* Set the music's initial volume */
799 static void music_internal_initialize_volume(void)
800 {
801 if (music_playing->fading == MIX_FADING_IN) {
802 music_internal_volume(0);
803 } else {
804 music_internal_volume(music_volume);
805 }
806 }
807
808 /* Set the music volume */
809 static void music_internal_volume(int volume)
810 {
811 if (music_playing->interface->SetVolume) {
812 music_playing->interface->SetVolume(music_playing->context, volume);
813 }
814 }
815 int Mix_VolumeMusic(int volume)
816 {
817 int prev_volume;
818
819 prev_volume = music_volume;
820 if (volume < 0) {
821 return prev_volume;
822 }
823 if (volume > SDL_MIX_MAXVOLUME) {
824 volume = SDL_MIX_MAXVOLUME;
825 }
826 music_volume = volume;
827 Mix_LockAudio();
828 if (music_playing) {
829 music_internal_volume(music_volume);
830 }
831 Mix_UnlockAudio();
832 return(prev_volume);
833 }
834
835 /* Halt playing of music */
836 static void music_internal_halt(void)
837 {
838 if (music_playing->interface->Stop) {
839 music_playing->interface->Stop(music_playing->context);
840 }
841
842 music_playing->playing = SDL_FALSE;
843 music_playing->fading = MIX_NO_FADING;
844 music_playing = NULL;
845 }
846 int Mix_HaltMusic(void)
847 {
848 Mix_LockAudio();
849 if (music_playing) {
850 music_internal_halt();
851 if (music_finished_hook) {
852 music_finished_hook();
853 }
854 }
855 Mix_UnlockAudio();
856
857 return(0);
858 }
859
860 /* Progressively stop the music */
861 int Mix_FadeOutMusic(int ms)
862 {
863 int retval = 0;
864
865 if (ms_per_step == 0) {
866 SDL_SetError("Audio device hasn't been opened");
867 return 0;
868 }
869
870 if (ms <= 0) { /* just halt immediately. */
871 Mix_HaltMusic();
872 return 1;
873 }
874
875 Mix_LockAudio();
876 if (music_playing) {
877 int fade_steps = (ms + ms_per_step - 1) / ms_per_step;
878 if (music_playing->fading == MIX_NO_FADING) {
879 music_playing->fade_step = 0;
880 } else {
881 int step;
882 int old_fade_steps = music_playing->fade_steps;
883 if (music_playing->fading == MIX_FADING_OUT) {
884 step = music_playing->fade_step;
885 } else {
886 step = old_fade_steps - music_playing->fade_step + 1;
887 }
888 music_playing->fade_step = (step * fade_steps) / old_fade_steps;
889 }
890 music_playing->fading = MIX_FADING_OUT;
891 music_playing->fade_steps = fade_steps;
892 retval = 1;
893 }
894 Mix_UnlockAudio();
895
896 return(retval);
897 }
898
899 Mix_Fading Mix_FadingMusic(void)
900 {
901 Mix_Fading fading = MIX_NO_FADING;
902
903 Mix_LockAudio();
904 if (music_playing) {
905 fading = music_playing->fading;
906 }
907 Mix_UnlockAudio();
908
909 return(fading);
910 }
911
912 /* Pause/Resume the music stream */
913 void Mix_PauseMusic(void)
914 {
915 Mix_LockAudio();
916 if (music_playing) {
917 if (music_playing->interface->Pause) {
918 music_playing->interface->Pause(music_playing->context);
919 }
920 }
921 music_active = SDL_FALSE;
922 Mix_UnlockAudio();
923 }
924
925 void Mix_ResumeMusic(void)
926 {
927 Mix_LockAudio();
928 if (music_playing) {
929 if (music_playing->interface->Resume) {
930 music_playing->interface->Resume(music_playing->context);
931 }
932 }
933 music_active = SDL_TRUE;
934 Mix_UnlockAudio();
935 }
936
937 void Mix_RewindMusic(void)
938 {
939 Mix_SetMusicPosition(0.0);
940 }
941
942 int Mix_PausedMusic(void)
943 {
944 return (music_active == SDL_FALSE);
945 }
946
947 /* Check the status of the music */
948 static SDL_bool music_internal_playing(void)
949 {
950 if (!music_playing) {
951 return SDL_FALSE;
952 }
953
954 if (music_playing->interface->IsPlaying) {
955 music_playing->playing = music_playing->interface->IsPlaying(music_playing->context);
956 }
957 return music_playing->playing;
958 }
959 int Mix_PlayingMusic(void)
960 {
961 SDL_bool playing;
962
963 Mix_LockAudio();
964 playing = music_internal_playing();
965 Mix_UnlockAudio();
966
967 return playing ? 1 : 0;
968 }
969
970 /* Set the external music playback command */
971 int Mix_SetMusicCMD(const char *command)
972 {
973 Mix_HaltMusic();
974 if (music_cmd) {
975 SDL_free(music_cmd);
976 music_cmd = NULL;
977 }
978 if (command) {
979 size_t length = SDL_strlen(command) + 1;
980 music_cmd = (char *)SDL_malloc(length);
981 if (music_cmd == NULL) {
982 return SDL_OutOfMemory();
983 }
984 SDL_memcpy(music_cmd, command, length);
985 }
986 return 0;
987 }
988
989 int Mix_SetSynchroValue(int i)
990 {
991 /* Not supported by any players at this time */
992 return(-1);
993 }
994
995 int Mix_GetSynchroValue(void)
996 {
997 /* Not supported by any players at this time */
998 return(-1);
999 }
1000
1001
1002 /* Uninitialize the music interfaces */
1003 void close_music(void)
1004 {
1005 int i;
1006
1007 Mix_HaltMusic();
1008
1009 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
1010 Mix_MusicInterface *interface = s_music_interfaces[i];
1011 if (!interface || !interface->opened) {
1012 continue;
1013 }
1014
1015 if (interface->Close) {
1016 interface->Close();
1017 }
1018 interface->opened = SDL_FALSE;
1019 }
1020
1021 if (soundfont_paths) {
1022 SDL_free(soundfont_paths);
1023 soundfont_paths = NULL;
1024 }
1025
1026 /* rcg06042009 report available decoders at runtime. */
1027 if (music_decoders) {
1028 SDL_free((void *)music_decoders);
1029 music_decoders = NULL;
1030 }
1031 num_decoders = 0;
1032
1033 ms_per_step = 0;
1034 }
1035
1036 /* Unload the music interface libraries */
1037 void unload_music(void)
1038 {
1039 int i;
1040 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
1041 Mix_MusicInterface *interface = s_music_interfaces[i];
1042 if (!interface || !interface->loaded) {
1043 continue;
1044 }
1045
1046 if (interface->Unload) {
1047 interface->Unload();
1048 }
1049 interface->loaded = SDL_FALSE;
1050 }
1051 }
1052
1053 int Mix_SetSoundFonts(const char *paths)
1054 {
1055 if (soundfont_paths) {
1056 SDL_free(soundfont_paths);
1057 soundfont_paths = NULL;
1058 }
1059
1060 if (paths) {
1061 if (!(soundfont_paths = SDL_strdup(paths))) {
1062 Mix_SetError("Insufficient memory to set SoundFonts");
1063 return 0;
1064 }
1065 }
1066 return 1;
1067 }
1068
1069 const char* Mix_GetSoundFonts(void)
1070 {
1071 const char *env_paths = SDL_getenv("SDL_SOUNDFONTS");
1072 SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE);
1073 if (force_env_paths && (!env_paths || !*env_paths)) {
1074 force_env_paths = SDL_FALSE;
1075 }
1076 if (soundfont_paths && *soundfont_paths && !force_env_paths) {
1077 return soundfont_paths;
1078 }
1079 if (env_paths) {
1080 return env_paths;
1081 }
1082
1083 /* We don't have any sound fonts set programmatically or in the environment
1084 Time to start guessing where they might be...
1085 */
1086 {
1087 static char *s_soundfont_paths[] = {
1088 "/usr/share/sounds/sf2/FluidR3_GM.sf2" /* Remember to add ',' here */
1089 };
1090 unsigned i;
1091
1092 for (i = 0; i < SDL_arraysize(s_soundfont_paths); ++i) {
1093 SDL_RWops *rwops = SDL_RWFromFile(s_soundfont_paths[i], "rb");
1094 if (rwops) {
1095 SDL_RWclose(rwops);
1096 return s_soundfont_paths[i];
1097 }
1098 }
1099 }
1100 return NULL;
1101 }
1102
1103 int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data)
1104 {
1105 char *context, *path, *paths;
1106 const char* cpaths = Mix_GetSoundFonts();
1107 int soundfonts_found = 0;
1108
1109 if (!cpaths) {
1110 Mix_SetError("No SoundFonts have been requested");
1111 return 0;
1112 }
1113
1114 if (!(paths = SDL_strdup(cpaths))) {
1115 Mix_SetError("Insufficient memory to iterate over SoundFonts");
1116 return 0;
1117 }
1118
1119 #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__WATCOMC__)
1120 for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) {
1121 #elif defined(_WIN32)
1122 for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) {
1123 #else
1124 for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
1125 #endif
1126 if (!function(path, data)) {
1127 continue;
1128 } else {
1129 soundfonts_found++;
1130 }
1131 }
1132
1133 SDL_free(paths);
1134 if (soundfonts_found > 0)
1135 return 1;
1136 else
1137 return 0;
1138 }
1139
1140 /* vi: set ts=4 sw=4 expandtab: */
+0
-124
music.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_mixer.h"
21
22 #ifndef MUSIC_H_
23 #define MUSIC_H_
24
25 /* Supported music APIs, in order of preference */
26
27 typedef enum
28 {
29 MIX_MUSIC_CMD,
30 MIX_MUSIC_WAVE,
31 MIX_MUSIC_MODPLUG,
32 MIX_MUSIC_MIKMOD,
33 MIX_MUSIC_FLUIDSYNTH,
34 MIX_MUSIC_TIMIDITY,
35 MIX_MUSIC_NATIVEMIDI,
36 MIX_MUSIC_OGG,
37 MIX_MUSIC_MPG123,
38 MIX_MUSIC_MAD,
39 MIX_MUSIC_FLAC,
40 MIX_MUSIC_OPUS,
41 MIX_MUSIC_LAST
42 } Mix_MusicAPI;
43
44
45 /* Music API implementation */
46
47 typedef struct
48 {
49 const char *tag;
50 Mix_MusicAPI api;
51 Mix_MusicType type;
52 SDL_bool loaded;
53 SDL_bool opened;
54
55 /* Load the library */
56 int (*Load)(void);
57
58 /* Initialize for the audio output */
59 int (*Open)(const SDL_AudioSpec *spec);
60
61 /* Create a music object from an SDL_RWops stream
62 * If the function returns NULL, 'src' will be freed if needed by the caller.
63 */
64 void *(*CreateFromRW)(SDL_RWops *src, int freesrc);
65
66 /* Create a music object from a file, if SDL_RWops are not supported */
67 void *(*CreateFromFile)(const char *file);
68
69 /* Set the volume */
70 void (*SetVolume)(void *music, int volume);
71
72 /* Start playing music from the beginning with an optional loop count */
73 int (*Play)(void *music, int play_count);
74
75 /* Returns SDL_TRUE if music is still playing */
76 SDL_bool (*IsPlaying)(void *music);
77
78 /* Get music data, returns the number of bytes left */
79 int (*GetAudio)(void *music, void *data, int bytes);
80
81 /* Seek to a play position (in seconds) */
82 int (*Seek)(void *music, double position);
83
84 /* Pause playing music */
85 void (*Pause)(void *music);
86
87 /* Resume playing music */
88 void (*Resume)(void *music);
89
90 /* Stop playing music */
91 void (*Stop)(void *music);
92
93 /* Delete a music object */
94 void (*Delete)(void *music);
95
96 /* Close the library and clean up */
97 void (*Close)(void);
98
99 /* Unload the library */
100 void (*Unload)(void);
101
102 } Mix_MusicInterface;
103
104
105 extern int get_num_music_interfaces(void);
106 extern Mix_MusicInterface *get_music_interface(int index);
107 extern Mix_MusicType detect_music_type_from_magic(const Uint8 *magic);
108 extern SDL_bool load_music_type(Mix_MusicType type);
109 extern SDL_bool open_music_type(Mix_MusicType type);
110 extern SDL_bool has_music(Mix_MusicType type);
111 extern void open_music(const SDL_AudioSpec *spec);
112 extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
113 int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done));
114 extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len);
115 extern void close_music(void);
116 extern void unload_music(void);
117
118 extern char *music_cmd;
119 extern SDL_AudioSpec music_spec;
120
121 #endif /* MUSIC_H_ */
122
123 /* vi: set ts=4 sw=4 expandtab: */
+0
-292
music_cmd.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 /* This file supports an external command for playing music */
23
24 #ifdef MUSIC_CMD
25
26 #include <sys/types.h>
27 #include <sys/wait.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 #include <signal.h>
33 #include <ctype.h>
34 #include <limits.h>
35 #if defined(__linux__) && defined(__arm__)
36 # include <linux/limits.h>
37 #endif
38
39 #include "music_cmd.h"
40
41
42 typedef struct {
43 char *file;
44 char *cmd;
45 pid_t pid;
46 int play_count;
47 } MusicCMD;
48
49
50 /* Load a music stream from the given file */
51 static void *MusicCMD_CreateFromFile(const char *file)
52 {
53 MusicCMD *music;
54
55 if (!music_cmd) {
56 Mix_SetError("You must call Mix_SetMusicCMD() first");
57 return NULL;
58 }
59
60 /* Allocate and fill the music structure */
61 music = (MusicCMD *)SDL_calloc(1, sizeof *music);
62 if (music == NULL) {
63 Mix_SetError("Out of memory");
64 return NULL;
65 }
66 music->file = SDL_strdup(file);
67 music->cmd = SDL_strdup(music_cmd);
68 music->pid = 0;
69
70 /* We're done */
71 return music;
72 }
73
74 /* Parse a command line buffer into arguments */
75 static int ParseCommandLine(char *cmdline, char **argv)
76 {
77 char *bufp;
78 int argc;
79
80 argc = 0;
81 for (bufp = cmdline; *bufp;) {
82 /* Skip leading whitespace */
83 while (isspace(*bufp)) {
84 ++bufp;
85 }
86 /* Skip over argument */
87 if (*bufp == '"') {
88 ++bufp;
89 if (*bufp) {
90 if (argv) {
91 argv[argc] = bufp;
92 }
93 ++argc;
94 }
95 /* Skip over word */
96 while (*bufp && (*bufp != '"')) {
97 ++bufp;
98 }
99 } else {
100 if (*bufp) {
101 if (argv) {
102 argv[argc] = bufp;
103 }
104 ++argc;
105 }
106 /* Skip over word */
107 while (*bufp && ! isspace(*bufp)) {
108 ++bufp;
109 }
110 }
111 if (*bufp) {
112 if (argv) {
113 *bufp = '\0';
114 }
115 ++bufp;
116 }
117 }
118 if (argv) {
119 argv[argc] = NULL;
120 }
121 return(argc);
122 }
123
124 static char **parse_args(char *command, char *last_arg)
125 {
126 int argc;
127 char **argv;
128
129 /* Parse the command line */
130 argc = ParseCommandLine(command, NULL);
131 if (last_arg) {
132 ++argc;
133 }
134 argv = (char **)SDL_malloc((argc+1)*(sizeof *argv));
135 if (argv == NULL) {
136 return(NULL);
137 }
138 argc = ParseCommandLine(command, argv);
139
140 /* Add last command line argument */
141 if (last_arg) {
142 argv[argc++] = last_arg;
143 }
144 argv[argc] = NULL;
145
146 /* We're ready! */
147 return(argv);
148 }
149
150 /* Start playback of a given music stream */
151 static int MusicCMD_Play(void *context, int play_count)
152 {
153 MusicCMD *music = (MusicCMD *)context;
154
155 music->play_count = play_count;
156 #ifdef HAVE_FORK
157 music->pid = fork();
158 #else
159 music->pid = vfork();
160 #endif
161 switch(music->pid) {
162 /* Failed fork() system call */
163 case -1:
164 Mix_SetError("fork() failed");
165 return -1;
166
167 /* Child process - executes here */
168 case 0: {
169 char **argv;
170
171 /* Unblock signals in case we're called from a thread */
172 {
173 sigset_t mask;
174 sigemptyset(&mask);
175 sigprocmask(SIG_SETMASK, &mask, NULL);
176 }
177
178 /* Execute the command */
179 argv = parse_args(music->cmd, music->file);
180 if (argv != NULL) {
181 execvp(argv[0], argv);
182
183 /* exec() failed */
184 perror(argv[0]);
185 }
186 _exit(-1);
187 }
188 break;
189
190 /* Parent process - executes here */
191 default:
192 break;
193 }
194 return 0;
195 }
196
197 /* Return non-zero if a stream is currently playing */
198 static SDL_bool MusicCMD_IsPlaying(void *context)
199 {
200 MusicCMD *music = (MusicCMD *)context;
201 int status;
202
203 if (music->pid > 0) {
204 waitpid(music->pid, &status, WNOHANG);
205 if (kill(music->pid, 0) == 0) {
206 return SDL_TRUE;
207 }
208
209 /* We might want to loop */
210 if (music->play_count != 1) {
211 int play_count = -1;
212 if (music->play_count > 0) {
213 play_count = (music->play_count - 1);
214 }
215 MusicCMD_Play(music, play_count);
216 return SDL_TRUE;
217 }
218 }
219 return SDL_FALSE;
220 }
221
222 /* Pause playback of a given music stream */
223 static void MusicCMD_Pause(void *context)
224 {
225 MusicCMD *music = (MusicCMD *)context;
226 if (music->pid > 0) {
227 kill(music->pid, SIGSTOP);
228 }
229 }
230
231 /* Resume playback of a given music stream */
232 static void MusicCMD_Resume(void *context)
233 {
234 MusicCMD *music = (MusicCMD *)context;
235 if (music->pid > 0) {
236 kill(music->pid, SIGCONT);
237 }
238 }
239
240 /* Stop playback of a stream previously started with MusicCMD_Start() */
241 static void MusicCMD_Stop(void *context)
242 {
243 MusicCMD *music = (MusicCMD *)context;
244 int status;
245
246 if (music->pid > 0) {
247 while (kill(music->pid, 0) == 0) {
248 kill(music->pid, SIGTERM);
249 sleep(1);
250 waitpid(music->pid, &status, WNOHANG);
251 }
252 music->pid = 0;
253 }
254 }
255
256 /* Close the given music stream */
257 void MusicCMD_Delete(void *context)
258 {
259 MusicCMD *music = (MusicCMD *)context;
260 SDL_free(music->file);
261 SDL_free(music);
262 }
263
264 Mix_MusicInterface Mix_MusicInterface_CMD =
265 {
266 "CMD",
267 MIX_MUSIC_CMD,
268 MUS_CMD,
269 SDL_FALSE,
270 SDL_FALSE,
271
272 NULL, /* Load */
273 NULL, /* Open */
274 NULL, /* CreateFromRW */
275 MusicCMD_CreateFromFile,
276 NULL, /* SetVolume */
277 MusicCMD_Play,
278 MusicCMD_IsPlaying,
279 NULL, /* GetAudio */
280 NULL, /* Seek */
281 MusicCMD_Pause,
282 MusicCMD_Resume,
283 MusicCMD_Stop,
284 MusicCMD_Delete,
285 NULL, /* Close */
286 NULL, /* Unload */
287 };
288
289 #endif /* MUSIC_CMD */
290
291 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_cmd.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports an external command for playing music */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_CMD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-567
music_flac.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file is used to support SDL_LoadMUS playback of FLAC files.
21 ~ Austen Dicken (admin@cvpcs.org)
22 */
23
24 #ifdef MUSIC_FLAC
25
26 #include "SDL_assert.h"
27 #include "SDL_loadso.h"
28
29 #include "music_flac.h"
30
31 #include <FLAC/stream_decoder.h>
32
33
34 typedef struct {
35 int loaded;
36 void *handle;
37 FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(void);
38 void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder);
39 FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)(
40 FLAC__StreamDecoder *decoder,
41 FLAC__StreamDecoderReadCallback read_callback,
42 FLAC__StreamDecoderSeekCallback seek_callback,
43 FLAC__StreamDecoderTellCallback tell_callback,
44 FLAC__StreamDecoderLengthCallback length_callback,
45 FLAC__StreamDecoderEofCallback eof_callback,
46 FLAC__StreamDecoderWriteCallback write_callback,
47 FLAC__StreamDecoderMetadataCallback metadata_callback,
48 FLAC__StreamDecoderErrorCallback error_callback,
49 void *client_data);
50 FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder);
51 FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder);
52 FLAC__bool (*FLAC__stream_decoder_process_single)(
53 FLAC__StreamDecoder *decoder);
54 FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)(
55 FLAC__StreamDecoder *decoder);
56 FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)(
57 FLAC__StreamDecoder *decoder);
58 FLAC__bool (*FLAC__stream_decoder_seek_absolute)(
59 FLAC__StreamDecoder *decoder,
60 FLAC__uint64 sample);
61 FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)(
62 const FLAC__StreamDecoder *decoder);
63 } flac_loader;
64
65 static flac_loader flac = {
66 0, NULL
67 };
68
69 #ifdef FLAC_DYNAMIC
70 #define FUNCTION_LOADER(FUNC, SIG) \
71 flac.FUNC = (SIG) SDL_LoadFunction(flac.handle, #FUNC); \
72 if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; }
73 #else
74 #define FUNCTION_LOADER(FUNC, SIG) \
75 flac.FUNC = FUNC;
76 #endif
77
78 static int FLAC_Load(void)
79 {
80 if (flac.loaded == 0) {
81 #ifdef FLAC_DYNAMIC
82 flac.handle = SDL_LoadObject(FLAC_DYNAMIC);
83 if (flac.handle == NULL) {
84 return -1;
85 }
86 #elif defined(__MACOSX__)
87 extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import));
88 if (FLAC__stream_decoder_new == NULL)
89 {
90 /* Missing weakly linked framework */
91 Mix_SetError("Missing FLAC.framework");
92 return -1;
93 }
94 #endif
95
96 FUNCTION_LOADER(FLAC__stream_decoder_new, FLAC__StreamDecoder *(*)(void))
97 FUNCTION_LOADER(FLAC__stream_decoder_delete, void (*)(FLAC__StreamDecoder *))
98 FUNCTION_LOADER(FLAC__stream_decoder_init_stream, FLAC__StreamDecoderInitStatus (*)(
99 FLAC__StreamDecoder *,
100 FLAC__StreamDecoderReadCallback,
101 FLAC__StreamDecoderSeekCallback,
102 FLAC__StreamDecoderTellCallback,
103 FLAC__StreamDecoderLengthCallback,
104 FLAC__StreamDecoderEofCallback,
105 FLAC__StreamDecoderWriteCallback,
106 FLAC__StreamDecoderMetadataCallback,
107 FLAC__StreamDecoderErrorCallback,
108 void *))
109 FUNCTION_LOADER(FLAC__stream_decoder_finish, FLAC__bool (*)(FLAC__StreamDecoder *))
110 FUNCTION_LOADER(FLAC__stream_decoder_flush, FLAC__bool (*)(FLAC__StreamDecoder *))
111 FUNCTION_LOADER(FLAC__stream_decoder_process_single, FLAC__bool (*)(FLAC__StreamDecoder *))
112 FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_metadata, FLAC__bool (*)(FLAC__StreamDecoder *))
113 FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_stream, FLAC__bool (*)(FLAC__StreamDecoder *))
114 FUNCTION_LOADER(FLAC__stream_decoder_seek_absolute, FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64))
115 FUNCTION_LOADER(FLAC__stream_decoder_get_state, FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder))
116 }
117 ++flac.loaded;
118
119 return 0;
120 }
121
122 static void FLAC_Unload(void)
123 {
124 if (flac.loaded == 0) {
125 return;
126 }
127 if (flac.loaded == 1) {
128 #ifdef FLAC_DYNAMIC
129 SDL_UnloadObject(flac.handle);
130 #endif
131 }
132 --flac.loaded;
133 }
134
135
136 typedef struct {
137 int volume;
138 int play_count;
139 FLAC__StreamDecoder *flac_decoder;
140 unsigned sample_rate;
141 unsigned channels;
142 unsigned bits_per_sample;
143 SDL_RWops *src;
144 int freesrc;
145 SDL_AudioStream *stream;
146 } FLAC_Music;
147
148
149 static int FLAC_Seek(void *context, double position);
150
151 static FLAC__StreamDecoderReadStatus flac_read_music_cb(
152 const FLAC__StreamDecoder *decoder,
153 FLAC__byte buffer[],
154 size_t *bytes,
155 void *client_data)
156 {
157 FLAC_Music *data = (FLAC_Music*)client_data;
158
159 /* make sure there is something to be reading */
160 if (*bytes > 0) {
161 *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes);
162
163 if (*bytes == 0) { /* error or no data was read (EOF) */
164 return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
165 } else { /* data was read, continue */
166 return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
167 }
168 } else {
169 return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
170 }
171 }
172
173 static FLAC__StreamDecoderSeekStatus flac_seek_music_cb(
174 const FLAC__StreamDecoder *decoder,
175 FLAC__uint64 absolute_byte_offset,
176 void *client_data)
177 {
178 FLAC_Music *data = (FLAC_Music*)client_data;
179
180 if (SDL_RWseek(data->src, absolute_byte_offset, RW_SEEK_SET) < 0) {
181 return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
182 } else {
183 return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
184 }
185 }
186
187 static FLAC__StreamDecoderTellStatus flac_tell_music_cb(
188 const FLAC__StreamDecoder *decoder,
189 FLAC__uint64 *absolute_byte_offset,
190 void *client_data)
191 {
192 FLAC_Music *data = (FLAC_Music*)client_data;
193
194 Sint64 pos = SDL_RWtell(data->src);
195
196 if (pos < 0) {
197 return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
198 } else {
199 *absolute_byte_offset = (FLAC__uint64)pos;
200 return FLAC__STREAM_DECODER_TELL_STATUS_OK;
201 }
202 }
203
204 static FLAC__StreamDecoderLengthStatus flac_length_music_cb(
205 const FLAC__StreamDecoder *decoder,
206 FLAC__uint64 *stream_length,
207 void *client_data)
208 {
209 FLAC_Music *data = (FLAC_Music*)client_data;
210
211 Sint64 pos = SDL_RWtell(data->src);
212 Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END);
213
214 if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) {
215 /* there was an error attempting to return the stream to the original
216 * position, or the length was invalid. */
217 return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
218 } else {
219 *stream_length = (FLAC__uint64)length;
220 return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
221 }
222 }
223
224 static FLAC__bool flac_eof_music_cb(
225 const FLAC__StreamDecoder *decoder,
226 void *client_data)
227 {
228 FLAC_Music *data = (FLAC_Music*)client_data;
229
230 Sint64 pos = SDL_RWtell(data->src);
231 Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END);
232
233 /* was the original position equal to the end (a.k.a. the seek didn't move)? */
234 if (pos == end) {
235 /* must be EOF */
236 return true;
237 } else {
238 /* not EOF, return to the original position */
239 SDL_RWseek(data->src, pos, RW_SEEK_SET);
240 return false;
241 }
242 }
243
244 static FLAC__StreamDecoderWriteStatus flac_write_music_cb(
245 const FLAC__StreamDecoder *decoder,
246 const FLAC__Frame *frame,
247 const FLAC__int32 *const buffer[],
248 void *client_data)
249 {
250 FLAC_Music *music = (FLAC_Music *)client_data;
251 Sint16 *data;
252 unsigned int i, j, channels;
253 int shift_amount = 0;
254
255 if (!music->stream) {
256 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
257 }
258
259 switch (music->bits_per_sample) {
260 case 16:
261 shift_amount = 0;
262 break;
263 case 20:
264 shift_amount = 4;
265 break;
266 case 24:
267 shift_amount = 8;
268 break;
269 default:
270 SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample);
271 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
272 }
273
274 if (music->channels == 3) {
275 /* We'll just drop the center channel for now */
276 channels = 2;
277 } else {
278 channels = music->channels;
279 }
280
281 data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels));
282 if (!data) {
283 SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data)));
284 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
285 }
286 if (music->channels == 3) {
287 Sint16 *dst = data;
288 for (i = 0; i < frame->header.blocksize; ++i) {
289 Sint16 FL = (buffer[0][i] >> shift_amount);
290 Sint16 FR = (buffer[1][i] >> shift_amount);
291 Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f);
292 int sample;
293
294 sample = (FL + FCmix);
295 if (sample > SDL_MAX_SINT16) {
296 *dst = SDL_MAX_SINT16;
297 } else if (sample < SDL_MIN_SINT16) {
298 *dst = SDL_MIN_SINT16;
299 } else {
300 *dst = sample;
301 }
302 ++dst;
303
304 sample = (FR + FCmix);
305 if (sample > SDL_MAX_SINT16) {
306 *dst = SDL_MAX_SINT16;
307 } else if (sample < SDL_MIN_SINT16) {
308 *dst = SDL_MIN_SINT16;
309 } else {
310 *dst = sample;
311 }
312 ++dst;
313 }
314 } else {
315 for (i = 0; i < channels; ++i) {
316 Sint16 *dst = data + i;
317 for (j = 0; j < frame->header.blocksize; ++j) {
318 *dst = (buffer[i][j] >> shift_amount);
319 dst += channels;
320 }
321 }
322 }
323 SDL_AudioStreamPut(music->stream, data, (frame->header.blocksize * channels * sizeof(*data)));
324 SDL_stack_free(data);
325
326 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
327 }
328
329 static void flac_metadata_music_cb(
330 const FLAC__StreamDecoder *decoder,
331 const FLAC__StreamMetadata *metadata,
332 void *client_data)
333 {
334 FLAC_Music *music = (FLAC_Music *)client_data;
335 int channels;
336
337 if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO) {
338 return;
339 }
340
341 music->sample_rate = metadata->data.stream_info.sample_rate;
342 music->channels = metadata->data.stream_info.channels;
343 music->bits_per_sample = metadata->data.stream_info.bits_per_sample;
344 /*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/
345
346 /* SDL's channel mapping and FLAC channel mapping are the same,
347 except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC
348 */
349 if (music->channels == 3) {
350 channels = 2;
351 } else {
352 channels = music->channels;
353 }
354 /* We check for NULL stream later when we get data */
355 SDL_assert(!music->stream);
356 music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music->sample_rate,
357 music_spec.format, music_spec.channels, music_spec.freq);
358 }
359
360 static void flac_error_music_cb(
361 const FLAC__StreamDecoder *decoder,
362 FLAC__StreamDecoderErrorStatus status,
363 void *client_data)
364 {
365 /* print an SDL error based on the error status */
366 switch (status) {
367 case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
368 SDL_SetError("Error processing the FLAC file [LOST_SYNC].");
369 break;
370 case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
371 SDL_SetError("Error processing the FLAC file [BAD_HEADER].");
372 break;
373 case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
374 SDL_SetError("Error processing the FLAC file [CRC_MISMATCH].");
375 break;
376 case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM:
377 SDL_SetError("Error processing the FLAC file [UNPARSEABLE].");
378 break;
379 default:
380 SDL_SetError("Error processing the FLAC file [UNKNOWN].");
381 break;
382 }
383 }
384
385 /* Load an FLAC stream from an SDL_RWops object */
386 static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc)
387 {
388 FLAC_Music *music;
389 int init_stage = 0;
390 int was_error = 1;
391
392 music = (FLAC_Music *)SDL_calloc(1, sizeof(*music));
393 if (!music) {
394 SDL_OutOfMemory();
395 return NULL;
396 }
397 music->src = src;
398 music->volume = MIX_MAX_VOLUME;
399
400 music->flac_decoder = flac.FLAC__stream_decoder_new();
401 if (music->flac_decoder) {
402 init_stage++; /* stage 1! */
403
404 if (flac.FLAC__stream_decoder_init_stream(
405 music->flac_decoder,
406 flac_read_music_cb, flac_seek_music_cb,
407 flac_tell_music_cb, flac_length_music_cb,
408 flac_eof_music_cb, flac_write_music_cb,
409 flac_metadata_music_cb, flac_error_music_cb,
410 music) == FLAC__STREAM_DECODER_INIT_STATUS_OK) {
411 init_stage++; /* stage 2! */
412
413 if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) {
414 was_error = 0;
415 } else {
416 SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed");
417 }
418 } else {
419 SDL_SetError("FLAC__stream_decoder_init_stream() failed");
420 }
421 } else {
422 SDL_SetError("FLAC__stream_decoder_new() failed");
423 }
424
425 if (was_error) {
426 switch (init_stage) {
427 case 2:
428 flac.FLAC__stream_decoder_finish(music->flac_decoder);
429 case 1:
430 flac.FLAC__stream_decoder_delete(music->flac_decoder);
431 case 0:
432 SDL_free(music);
433 break;
434 }
435 return NULL;
436 }
437
438 music->freesrc = freesrc;
439 return music;
440 }
441
442 /* Set the volume for an FLAC stream */
443 static void FLAC_SetVolume(void *context, int volume)
444 {
445 FLAC_Music *music = (FLAC_Music *)context;
446 music->volume = volume;
447 }
448
449 /* Start playback of a given FLAC stream */
450 static int FLAC_Play(void *context, int play_count)
451 {
452 FLAC_Music *music = (FLAC_Music *)context;
453 music->play_count = play_count;
454 return FLAC_Seek(music, 0.0);
455 }
456
457 /* Read some FLAC stream data and convert it for output */
458 static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
459 {
460 FLAC_Music *music = (FLAC_Music *)context;
461 int filled;
462
463 filled = SDL_AudioStreamGet(music->stream, data, bytes);
464 if (filled != 0) {
465 return filled;
466 }
467
468 if (!music->play_count) {
469 /* All done */
470 *done = SDL_TRUE;
471 return 0;
472 }
473
474 if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) {
475 SDL_SetError("FLAC__stream_decoder_process_single() failed");
476 return -1;
477 }
478
479 if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) {
480 if (music->play_count == 1) {
481 music->play_count = 0;
482 SDL_AudioStreamFlush(music->stream);
483 } else {
484 int play_count = -1;
485 if (music->play_count > 0) {
486 play_count = (music->play_count - 1);
487 }
488 if (FLAC_Play(music, play_count) < 0) {
489 return -1;
490 }
491 }
492 }
493 return 0;
494 }
495
496 /* Play some of a stream previously started with FLAC_play() */
497 static int FLAC_GetAudio(void *context, void *data, int bytes)
498 {
499 FLAC_Music *music = (FLAC_Music *)context;
500 return music_pcm_getaudio(context, data, bytes, music->volume, FLAC_GetSome);
501 }
502
503 /* Jump (seek) to a given position (position is in seconds) */
504 static int FLAC_Seek(void *context, double position)
505 {
506 FLAC_Music *music = (FLAC_Music *)context;
507 double seek_sample = music->sample_rate * position;
508
509 if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) {
510 if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) {
511 flac.FLAC__stream_decoder_flush(music->flac_decoder);
512 }
513
514 SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
515 return -1;
516 }
517 return 0;
518 }
519
520 /* Close the given FLAC_Music object */
521 static void FLAC_Delete(void *context)
522 {
523 FLAC_Music *music = (FLAC_Music *)context;
524 if (music) {
525 if (music->flac_decoder) {
526 flac.FLAC__stream_decoder_finish(music->flac_decoder);
527 flac.FLAC__stream_decoder_delete(music->flac_decoder);
528 }
529 if (music->stream) {
530 SDL_FreeAudioStream(music->stream);
531 }
532 if (music->freesrc) {
533 SDL_RWclose(music->src);
534 }
535 SDL_free(music);
536 }
537 }
538
539 Mix_MusicInterface Mix_MusicInterface_FLAC =
540 {
541 "FLAC",
542 MIX_MUSIC_FLAC,
543 MUS_FLAC,
544 SDL_FALSE,
545 SDL_FALSE,
546
547 FLAC_Load,
548 NULL, /* Open */
549 FLAC_CreateFromRW,
550 NULL, /* CreateFromFile */
551 FLAC_SetVolume,
552 FLAC_Play,
553 NULL, /* IsPlaying */
554 FLAC_GetAudio,
555 FLAC_Seek,
556 NULL, /* Pause */
557 NULL, /* Resume */
558 NULL, /* Stop */
559 FLAC_Delete,
560 NULL, /* Close */
561 FLAC_Unload,
562 };
563
564 #endif /* MUSIC_FLAC */
565
566 /* vi: set ts=4 sw=4 expandtab: */
+0
-26
music_flac.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #include "music.h"
22
23 extern Mix_MusicInterface Mix_MusicInterface_FLAC;
24
25 /* vi: set ts=4 sw=4 expandtab: */
+0
-309
music_fluidsynth.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 James Le Cuirot
21 chewi@aura-online.co.uk
22 */
23
24 #ifdef MUSIC_MID_FLUIDSYNTH
25
26 #include <stdio.h>
27
28 #include "SDL_loadso.h"
29
30 #include "music_fluidsynth.h"
31
32 #include <fluidsynth.h>
33
34
35 typedef struct {
36 int loaded;
37 void *handle;
38
39 int (*delete_fluid_player)(fluid_player_t*);
40 void (*delete_fluid_settings)(fluid_settings_t*);
41 int (*delete_fluid_synth)(fluid_synth_t*);
42 int (*fluid_player_add)(fluid_player_t*, const char*);
43 int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t);
44 int (*fluid_player_get_status)(fluid_player_t*);
45 int (*fluid_player_play)(fluid_player_t*);
46 int (*fluid_player_set_loop)(fluid_player_t*, int);
47 int (*fluid_player_stop)(fluid_player_t*);
48 int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double);
49 fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*);
50 void (*fluid_synth_set_gain)(fluid_synth_t*, float);
51 int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int);
52 int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int);
53 fluid_player_t* (*new_fluid_player)(fluid_synth_t*);
54 fluid_settings_t* (*new_fluid_settings)(void);
55 fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*);
56 } fluidsynth_loader;
57
58 static fluidsynth_loader fluidsynth = {
59 0, NULL
60 };
61
62 #ifdef FLUIDSYNTH_DYNAMIC
63 #define FUNCTION_LOADER(FUNC, SIG) \
64 fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
65 if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
66 #else
67 #define FUNCTION_LOADER(FUNC, SIG) \
68 fluidsynth.FUNC = FUNC;
69 #endif
70
71 static int FLUIDSYNTH_Load()
72 {
73 if (fluidsynth.loaded == 0) {
74 #ifdef FLUIDSYNTH_DYNAMIC
75 fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
76 if (fluidsynth.handle == NULL) {
77 return -1;
78 }
79 #endif
80 FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*))
81 FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*))
82 FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*))
83 FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*))
84 FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t))
85 FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*))
86 FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*))
87 FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int))
88 FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*))
89 FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double))
90 FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*))
91 FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float))
92 FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int))
93 FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int))
94 FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*))
95 FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void))
96 FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*))
97 }
98 ++fluidsynth.loaded;
99
100 return 0;
101 }
102
103 static void FLUIDSYNTH_Unload()
104 {
105 if (fluidsynth.loaded == 0) {
106 return;
107 }
108 if (fluidsynth.loaded == 1) {
109 #ifdef FLUIDSYNTH_DYNAMIC
110 SDL_UnloadObject(fluidsynth.handle);
111 #endif
112 }
113 --fluidsynth.loaded;
114 }
115
116
117 typedef struct {
118 fluid_synth_t *synth;
119 fluid_player_t *player;
120 SDL_AudioStream *stream;
121 void *buffer;
122 int buffer_size;
123 } FLUIDSYNTH_Music;
124
125
126 static int SDLCALL fluidsynth_check_soundfont(const char *path, void *data)
127 {
128 FILE *file = fopen(path, "r");
129
130 if (file) {
131 fclose(file);
132 return 1;
133 } else {
134 Mix_SetError("Failed to access the SoundFont %s", path);
135 return 0;
136 }
137 }
138
139 static int SDLCALL fluidsynth_load_soundfont(const char *path, void *data)
140 {
141 /* If this fails, it's too late to try Timidity so pray that at least one works. */
142 fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1);
143 return 1;
144 }
145
146 static int FLUIDSYNTH_Open(const SDL_AudioSpec *spec)
147 {
148 if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) {
149 return -1;
150 }
151 return 0;
152 }
153
154 static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data)
155 {
156 SDL_RWops *src = (SDL_RWops *)data;
157 FLUIDSYNTH_Music *music;
158 fluid_settings_t *settings;
159
160 if ((music = SDL_calloc(1, sizeof(FLUIDSYNTH_Music)))) {
161 int channels = 2;
162 if ((music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music_spec.freq, music_spec.format, music_spec.channels, music_spec.freq))) {
163 music->buffer_size = music_spec.samples * sizeof(Sint16) * channels;
164 if ((music->buffer = SDL_malloc(music->buffer_size))) {
165 if ((settings = fluidsynth.new_fluid_settings())) {
166 fluidsynth.fluid_settings_setnum(settings, "synth.sample-rate", (double) music_spec.freq);
167
168 if ((music->synth = fluidsynth.new_fluid_synth(settings))) {
169 if (Mix_EachSoundFont(fluidsynth_load_soundfont, (void*) music->synth)) {
170 if ((music->player = fluidsynth.new_fluid_player(music->synth))) {
171 void *buffer;
172 size_t size;
173
174 buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE);
175 if (buffer) {
176 if (fluidsynth.fluid_player_add_mem(music->player, buffer, size) == FLUID_OK) {
177 SDL_free(buffer);
178 return music;
179 } else {
180 Mix_SetError("FluidSynth failed to load in-memory song");
181 }
182 SDL_free(buffer);
183 } else {
184 SDL_OutOfMemory();
185 }
186 fluidsynth.delete_fluid_player(music->player);
187 } else {
188 Mix_SetError("Failed to create FluidSynth player");
189 }
190 }
191 fluidsynth.delete_fluid_synth(music->synth);
192 } else {
193 Mix_SetError("Failed to create FluidSynth synthesizer");
194 }
195 fluidsynth.delete_fluid_settings(settings);
196 } else {
197 Mix_SetError("Failed to create FluidSynth settings");
198 }
199 } else {
200 SDL_OutOfMemory();
201 }
202 }
203 SDL_free(music);
204 } else {
205 SDL_OutOfMemory();
206 }
207 return NULL;
208 }
209
210 static void *FLUIDSYNTH_CreateFromRW(SDL_RWops *src, int freesrc)
211 {
212 FLUIDSYNTH_Music *music;
213
214 music = FLUIDSYNTH_LoadMusic(src);
215 if (music && freesrc) {
216 SDL_RWclose(src);
217 }
218 return music;
219 }
220
221 static void FLUIDSYNTH_SetVolume(void *context, int volume)
222 {
223 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
224 /* FluidSynth's default is 0.2. Make 1.2 the maximum. */
225 fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME));
226 }
227
228 static int FLUIDSYNTH_Play(void *context, int play_count)
229 {
230 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
231 fluidsynth.fluid_player_set_loop(music->player, play_count);
232 fluidsynth.fluid_player_play(music->player);
233 return 0;
234 }
235
236 static SDL_bool FLUIDSYNTH_IsPlaying(void *context)
237 {
238 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
239 return fluidsynth.fluid_player_get_status(music->player) == FLUID_PLAYER_PLAYING ? SDL_TRUE : SDL_FALSE;
240 }
241
242 static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *done)
243 {
244 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
245 int filled;
246
247 filled = SDL_AudioStreamGet(music->stream, data, bytes);
248 if (filled != 0) {
249 return filled;
250 }
251
252 if (fluidsynth.fluid_synth_write_s16(music->synth, music_spec.samples, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) {
253 Mix_SetError("Error generating FluidSynth audio");
254 return -1;
255 }
256 if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) {
257 return -1;
258 }
259 return 0;
260 }
261 static int FLUIDSYNTH_GetAudio(void *context, void *data, int bytes)
262 {
263 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, FLUIDSYNTH_GetSome);
264 }
265
266 static void FLUIDSYNTH_Stop(void *context)
267 {
268 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
269 fluidsynth.fluid_player_stop(music->player);
270 }
271
272 static void FLUIDSYNTH_Delete(void *context)
273 {
274 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
275 fluidsynth.delete_fluid_player(music->player);
276 fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(music->synth));
277 fluidsynth.delete_fluid_synth(music->synth);
278 SDL_free(music);
279 }
280
281 Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH =
282 {
283 "FLUIDSYNTH",
284 MIX_MUSIC_FLUIDSYNTH,
285 MUS_MID,
286 SDL_FALSE,
287 SDL_FALSE,
288
289 FLUIDSYNTH_Load,
290 FLUIDSYNTH_Open,
291 FLUIDSYNTH_CreateFromRW,
292 NULL, /* CreateFromFile */
293 FLUIDSYNTH_SetVolume,
294 FLUIDSYNTH_Play,
295 FLUIDSYNTH_IsPlaying,
296 FLUIDSYNTH_GetAudio,
297 NULL, /* Seek */
298 NULL, /* Pause */
299 NULL, /* Resume */
300 FLUIDSYNTH_Stop,
301 FLUIDSYNTH_Delete,
302 NULL, /* Close */
303 FLUIDSYNTH_Unload,
304 };
305
306 #endif /* MUSIC_MID_FLUIDSYNTH */
307
308 /* vi: set ts=4 sw=4 expandtab: */
+0
-31
music_fluidsynth.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 James Le Cuirot
21 chewi@aura-online.co.uk
22 */
23
24 /* This file supports playing MIDI files with FluidSynth */
25
26 #include "music.h"
27
28 extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH;
29
30 /* vi: set ts=4 sw=4 expandtab: */
+0
-554
music_mad.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MP3_MAD
22
23 #include "music_mad.h"
24
25 #include "mad.h"
26
27
28 /* NOTE: The dithering functions are GPL, which should be fine if your
29 application is GPL (which would need to be true if you enabled
30 libmad support in SDL_mixer). If you're using libmad under the
31 commercial license, you need to disable this code.
32 */
33 /************************ dithering functions ***************************/
34
35 #ifdef MUSIC_MP3_MAD_GPL_DITHERING
36
37 /* All dithering done here is taken from the GPL'ed xmms-mad plugin. */
38
39 /* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */
40 /* Any feedback is very welcome. For any question, comments, */
41 /* see http://www.math.keio.ac.jp/matumoto/emt.html or email */
42 /* matumoto@math.keio.ac.jp */
43
44 /* Period parameters */
45 #define MP3_DITH_N 624
46 #define MP3_DITH_M 397
47 #define MATRIX_A 0x9908b0df /* constant vector a */
48 #define UPPER_MASK 0x80000000 /* most significant w-r bits */
49 #define LOWER_MASK 0x7fffffff /* least significant r bits */
50
51 /* Tempering parameters */
52 #define TEMPERING_MASK_B 0x9d2c5680
53 #define TEMPERING_MASK_C 0xefc60000
54 #define TEMPERING_SHIFT_U(y) (y >> 11)
55 #define TEMPERING_SHIFT_S(y) (y << 7)
56 #define TEMPERING_SHIFT_T(y) (y << 15)
57 #define TEMPERING_SHIFT_L(y) (y >> 18)
58
59 static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */
60 static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */
61
62 /* initializing the array with a NONZERO seed */
63 static void sgenrand(unsigned long seed)
64 {
65 /* setting initial seeds to mt[MP3_DITH_N] using */
66 /* the generator Line 25 of Table 1 in */
67 /* [KNUTH 1981, The Art of Computer Programming */
68 /* Vol. 2 (2nd Ed.), pp102] */
69 mt[0]= seed & 0xffffffff;
70 for (mti=1; mti<MP3_DITH_N; mti++)
71 mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
72 }
73
74 static unsigned long genrand(void)
75 {
76 unsigned long y;
77 static unsigned long mag01[2]={0x0, MATRIX_A};
78 /* mag01[x] = x * MATRIX_A for x=0,1 */
79
80 if (mti >= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */
81 int kk;
82
83 if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */
84 sgenrand(4357); /* a default initial seed is used */
85
86 for (kk=0;kk<MP3_DITH_N-MP3_DITH_M;kk++) {
87 y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
88 mt[kk] = mt[kk+MP3_DITH_M] ^ (y >> 1) ^ mag01[y & 0x1];
89 }
90 for (;kk<MP3_DITH_N-1;kk++) {
91 y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
92 mt[kk] = mt[kk+(MP3_DITH_M-MP3_DITH_N)] ^ (y >> 1) ^ mag01[y & 0x1];
93 }
94 y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
95 mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1];
96
97 mti = 0;
98 }
99
100 y = mt[mti++];
101 y ^= TEMPERING_SHIFT_U(y);
102 y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
103 y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
104 y ^= TEMPERING_SHIFT_L(y);
105
106 return y;
107 }
108
109 static long triangular_dither_noise(int nbits) {
110 /* parameter nbits : the peak-to-peak amplitude desired (in bits)
111 * use with nbits set to 2 + nber of bits to be trimmed.
112 * (because triangular is made from two uniformly distributed processes,
113 * it starts at 2 bits peak-to-peak amplitude)
114 * see The Theory of Dithered Quantization by Robert Alexander Wannamaker
115 * for complete proof of why that's optimal
116 */
117 long v = (genrand()/2 - genrand()/2); /* in ]-2^31, 2^31[ */
118 long P = 1 << (32 - nbits); /* the power of 2 */
119 v /= P;
120 /* now v in ]-2^(nbits-1), 2^(nbits-1) [ */
121
122 return v;
123 }
124
125 #endif /* MUSIC_MP3_MAD_GPL_DITHERING */
126
127
128 #define MAD_INPUT_BUFFER_SIZE (5*8192)
129
130 enum {
131 MS_input_eof = 0x0001,
132 MS_input_error = 0x0001,
133 MS_decode_error = 0x0002,
134 MS_error_flags = 0x000f,
135 };
136
137 typedef struct {
138 int play_count;
139 SDL_RWops *src;
140 int freesrc;
141 struct mad_stream stream;
142 struct mad_frame frame;
143 struct mad_synth synth;
144 mad_timer_t next_frame_start;
145 int volume;
146 int status;
147 SDL_AudioStream *audiostream;
148
149 unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
150 } MAD_Music;
151
152
153 static int MAD_Seek(void *context, double position);
154
155 static void *MAD_CreateFromRW(SDL_RWops *src, int freesrc)
156 {
157 MAD_Music *music;
158
159 music = (MAD_Music *)SDL_calloc(1, sizeof(MAD_Music));
160 if (!music) {
161 SDL_OutOfMemory();
162 return NULL;
163 }
164 music->src = src;
165 music->volume = MIX_MAX_VOLUME;
166
167 mad_stream_init(&music->stream);
168 mad_frame_init(&music->frame);
169 mad_synth_init(&music->synth);
170 mad_timer_reset(&music->next_frame_start);
171
172 music->freesrc = freesrc;
173 return music;
174 }
175
176 static void MAD_SetVolume(void *context, int volume)
177 {
178 MAD_Music *music = (MAD_Music *)context;
179 music->volume = volume;
180 }
181
182 /* Starts the playback. */
183 static int MAD_Play(void *context, int play_count)
184 {
185 MAD_Music *music = (MAD_Music *)context;
186 music->play_count = play_count;
187 return MAD_Seek(music, 0.0);
188 }
189
190
191 /*************************** TAG HANDLING: ******************************/
192
193 static SDL_INLINE SDL_bool is_id3v1(const Uint8 *data, size_t length)
194 {
195 /* http://id3.org/ID3v1 : 3 bytes "TAG" identifier and 125 bytes tag data */
196 if (length < 3 || SDL_memcmp(data,"TAG",3) != 0) {
197 return SDL_FALSE;
198 }
199 return SDL_TRUE;
200 }
201 static SDL_INLINE SDL_bool is_id3v2(const Uint8 *data, size_t length)
202 {
203 /* ID3v2 header is 10 bytes: http://id3.org/id3v2.4.0-structure */
204 /* bytes 0-2: "ID3" identifier */
205 if (length < 10 || SDL_memcmp(data,"ID3",3) != 0) {
206 return SDL_FALSE;
207 }
208 /* bytes 3-4: version num (major,revision), each byte always less than 0xff. */
209 if (data[3] == 0xff || data[4] == 0xff) {
210 return SDL_FALSE;
211 }
212 /* bytes 6-9 are the ID3v2 tag size: a 32 bit 'synchsafe' integer, i.e. the
213 * highest bit 7 in each byte zeroed. i.e.: 7 bit information in each byte ->
214 * effectively a 28 bit value. */
215 if (data[6] >= 0x80 || data[7] >= 0x80 || data[8] >= 0x80 || data[9] >= 0x80) {
216 return SDL_FALSE;
217 }
218 return SDL_TRUE;
219 }
220 static SDL_INLINE SDL_bool is_apetag(const Uint8 *data, size_t length)
221 {
222 /* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification
223 * APEv2 header is 32 bytes: bytes 0-7 ident, bytes 8-11 version,
224 * bytes 12-17 size. bytes 24-31 are reserved: must be all zeroes.
225 * APEv1 has no header, so no luck. */
226 Uint32 v;
227
228 if (length < 32 || SDL_memcmp(data,"APETAGEX",8) != 0) {
229 return SDL_FALSE;
230 }
231 v = (data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]; /* version */
232 if (v != 2000U) {
233 return SDL_FALSE;
234 }
235 v = 0; /* reserved bits : */
236 if (SDL_memcmp(&data[24],&v,4) != 0 || SDL_memcmp(&data[28],&v,4) != 0) {
237 return SDL_FALSE;
238 }
239 return SDL_TRUE;
240 }
241
242 static size_t get_tagsize(const Uint8 *data, size_t length)
243 {
244 size_t size;
245
246 if (is_id3v1(data, length)) {
247 return 128; /* fixed length */
248 }
249 if (is_id3v2(data, length)) {
250 /* size is a 'synchsafe' integer (see above) */
251 size = (data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9];
252 size += 10; /* header size */
253 /* ID3v2 header[5] is flags (bits 4-7 only, 0-3 are zero).
254 * bit 4 set: footer is present (a copy of the header but
255 * with "3DI" as ident.) */
256 if (data[5] & 0x10) {
257 size += 10; /* footer size */
258 }
259 /* optional padding (always zeroes) */
260 while (size < length && data[size] == 0) {
261 ++size;
262 }
263 return size;
264 }
265 if (is_apetag(data, length)) {
266 size = (data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12];
267 size += 32; /* header size */
268 return size;
269 }
270 return 0;
271 }
272
273 static int consume_tag(struct mad_stream *stream)
274 {
275 /* FIXME: what if the buffer doesn't have the full tag ??? */
276 size_t remaining = stream->bufend - stream->next_frame;
277 size_t tagsize = get_tagsize(stream->this_frame, remaining);
278 if (tagsize != 0) {
279 mad_stream_skip(stream, tagsize);
280 return 0;
281 }
282 return -1;
283 }
284
285 /* Reads the next frame from the file.
286 Returns true on success or false on failure.
287 */
288 static SDL_bool read_next_frame(MAD_Music *music)
289 {
290 if (music->stream.buffer == NULL ||
291 music->stream.error == MAD_ERROR_BUFLEN) {
292 size_t read_size;
293 size_t remaining;
294 unsigned char *read_start;
295
296 /* There might be some bytes in the buffer left over from last
297 time. If so, move them down and read more bytes following
298 them. */
299 if (music->stream.next_frame != NULL) {
300 remaining = music->stream.bufend - music->stream.next_frame;
301 memmove(music->input_buffer, music->stream.next_frame, remaining);
302 read_start = music->input_buffer + remaining;
303 read_size = MAD_INPUT_BUFFER_SIZE - remaining;
304
305 } else {
306 read_size = MAD_INPUT_BUFFER_SIZE;
307 read_start = music->input_buffer;
308 remaining = 0;
309 }
310
311 /* Now read additional bytes from the input file. */
312 read_size = SDL_RWread(music->src, read_start, 1, read_size);
313
314 if (read_size == 0) {
315 if ((music->status & (MS_input_eof | MS_input_error)) == 0) {
316 /* FIXME: how to detect error? */
317 music->status |= MS_input_eof;
318
319 /* At the end of the file, we must stuff MAD_BUFFER_GUARD
320 number of 0 bytes. */
321 SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD);
322 read_size += MAD_BUFFER_GUARD;
323 }
324 }
325
326 /* Now feed those bytes into the libmad stream. */
327 mad_stream_buffer(&music->stream, music->input_buffer,
328 read_size + remaining);
329 music->stream.error = MAD_ERROR_NONE;
330 }
331
332 /* Now ask libmad to extract a frame from the data we just put in
333 its buffer. */
334 if (mad_frame_decode(&music->frame, &music->stream)) {
335 if (MAD_RECOVERABLE(music->stream.error)) {
336 consume_tag(&music->stream); /* consume any ID3 tags */
337 mad_stream_sync(&music->stream); /* to frame seek mode */
338 return SDL_FALSE;
339
340 } else if (music->stream.error == MAD_ERROR_BUFLEN) {
341 return SDL_FALSE;
342
343 } else {
344 Mix_SetError("mad_frame_decode() failed, corrupt stream?");
345 music->status |= MS_decode_error;
346 return SDL_FALSE;
347 }
348 }
349
350 mad_timer_add(&music->next_frame_start, music->frame.header.duration);
351
352 return SDL_TRUE;
353 }
354
355 /* Scale a MAD sample to 16 bits for output. */
356 static Sint16 scale(mad_fixed_t sample)
357 {
358 const int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16;
359
360 /* round */
361 sample += (1L << (n_bits_to_loose - 1));
362
363 #ifdef MUSIC_MP3_MAD_GPL_DITHERING
364 sample += triangular_dither_noise(n_bits_to_loose + 1);
365 #endif
366
367 /* clip */
368 if (sample >= MAD_F_ONE)
369 sample = MAD_F_ONE - 1;
370 else if (sample < -MAD_F_ONE)
371 sample = -MAD_F_ONE;
372
373 /* quantize */
374 return (Sint16)(sample >> n_bits_to_loose);
375 }
376
377 /* Once the frame has been read, copies its samples into the output buffer. */
378 static SDL_bool decode_frame(MAD_Music *music)
379 {
380 struct mad_pcm *pcm;
381 unsigned int i, nchannels, nsamples;
382 mad_fixed_t const *left_ch, *right_ch;
383 Sint16 *buffer, *dst;
384 int result;
385
386 mad_synth_frame(&music->synth, &music->frame);
387 pcm = &music->synth.pcm;
388
389 if (!music->audiostream) {
390 music->audiostream = SDL_NewAudioStream(AUDIO_S16, pcm->channels, pcm->samplerate, music_spec.format, music_spec.channels, music_spec.freq);
391 if (!music->audiostream) {
392 return SDL_FALSE;
393 }
394 }
395
396 nchannels = pcm->channels;
397 nsamples = pcm->length;
398 left_ch = pcm->samples[0];
399 right_ch = pcm->samples[1];
400 buffer = SDL_stack_alloc(Sint16, nsamples*nchannels);
401 if (!buffer) {
402 SDL_OutOfMemory();
403 return SDL_FALSE;
404 }
405
406 dst = buffer;
407 if (nchannels == 1) {
408 for (i = nsamples; i--;) {
409 *dst++ = scale(*left_ch++);
410 }
411 } else {
412 for (i = nsamples; i--;) {
413 *dst++ = scale(*left_ch++);
414 *dst++ = scale(*right_ch++);
415 }
416 }
417
418 result = SDL_AudioStreamPut(music->audiostream, buffer, (nsamples * nchannels * sizeof(Sint16)));
419 SDL_stack_free(buffer);
420
421 if (result < 0) {
422 return SDL_FALSE;
423 }
424 return SDL_TRUE;
425 }
426
427 static int MAD_GetSome(void *context, void *data, int bytes, SDL_bool *done)
428 {
429 MAD_Music *music = (MAD_Music *)context;
430 int filled;
431
432 if (music->audiostream) {
433 filled = SDL_AudioStreamGet(music->audiostream, data, bytes);
434 if (filled != 0) {
435 return filled;
436 }
437 }
438
439 if (!music->play_count) {
440 /* All done */
441 *done = SDL_TRUE;
442 return 0;
443 }
444
445 if (read_next_frame(music)) {
446 if (!decode_frame(music)) {
447 return -1;
448 }
449 } else if (music->status & MS_input_eof) {
450 int play_count = -1;
451 if (music->play_count > 0) {
452 play_count = (music->play_count - 1);
453 }
454 if (MAD_Play(music, play_count) < 0) {
455 return -1;
456 }
457 } else if (music->status & MS_decode_error) {
458 return -1;
459 }
460 return 0;
461 }
462 static int MAD_GetAudio(void *context, void *data, int bytes)
463 {
464 MAD_Music *music = (MAD_Music *)context;
465 return music_pcm_getaudio(context, data, bytes, music->volume, MAD_GetSome);
466 }
467
468 static int MAD_Seek(void *context, double position)
469 {
470 MAD_Music *music = (MAD_Music *)context;
471 mad_timer_t target;
472 int int_part;
473
474 int_part = (int)position;
475 mad_timer_set(&target, int_part, (int)((position - int_part) * 1000000), 1000000);
476
477 if (mad_timer_compare(music->next_frame_start, target) > 0) {
478 /* In order to seek backwards in a VBR file, we have to rewind and
479 start again from the beginning. This isn't necessary if the
480 file happens to be CBR, of course; in that case we could seek
481 directly to the frame we want. But I leave that little
482 optimization for the future developer who discovers she really
483 needs it. */
484 mad_timer_reset(&music->next_frame_start);
485 music->status &= ~MS_error_flags;
486
487 SDL_RWseek(music->src, 0, RW_SEEK_SET);
488 }
489
490 /* Now we have to skip frames until we come to the right one.
491 Again, only truly necessary if the file is VBR. */
492 while (mad_timer_compare(music->next_frame_start, target) < 0) {
493 if (!read_next_frame(music)) {
494 if ((music->status & MS_error_flags) != 0) {
495 /* Couldn't read a frame; either an error condition or
496 end-of-file. Stop. */
497 return Mix_SetError("Seek position out of range");
498 }
499 }
500 }
501
502 /* Here we are, at the beginning of the frame that contains the
503 target time. Ehh, I say that's close enough. If we wanted to,
504 we could get more precise by decoding the frame now and counting
505 the appropriate number of samples out of it. */
506 return 0;
507 }
508
509 static void MAD_Delete(void *context)
510 {
511 MAD_Music *music = (MAD_Music *)context;
512
513 mad_stream_finish(&music->stream);
514 mad_frame_finish(&music->frame);
515 mad_synth_finish(&music->synth);
516
517 if (music->audiostream) {
518 SDL_FreeAudioStream(music->audiostream);
519 }
520 if (music->freesrc) {
521 SDL_RWclose(music->src);
522 }
523 SDL_free(music);
524 }
525
526 Mix_MusicInterface Mix_MusicInterface_MAD =
527 {
528 "MAD",
529 MIX_MUSIC_MAD,
530 MUS_MP3,
531 SDL_FALSE,
532 SDL_FALSE,
533
534 NULL, /* Load */
535 NULL, /* Open */
536 MAD_CreateFromRW,
537 NULL, /* CreateFromFile */
538 MAD_SetVolume,
539 MAD_Play,
540 NULL, /* IsPlaying */
541 MAD_GetAudio,
542 MAD_Seek,
543 NULL, /* Pause */
544 NULL, /* Resume */
545 NULL, /* Stop */
546 MAD_Delete,
547 NULL, /* Close */
548 NULL, /* Unload */
549 };
550
551 #endif /* MUSIC_MP3_MAD */
552
553 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_mad.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with libmad */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MAD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-488
music_mikmod.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MOD_MIKMOD
22
23 /* This file supports MOD tracker music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_mikmod.h"
28
29 #include "mikmod.h"
30
31
32 /* libmikmod >= 3.3.2 constified several funcs */
33 #if (LIBMIKMOD_VERSION < 0x030302)
34 #define MIKMOD3_CONST
35 #else
36 #define MIKMOD3_CONST const
37 #endif
38
39 typedef struct {
40 int loaded;
41 void *handle;
42
43 void (*MikMod_Exit)(void);
44 CHAR* (*MikMod_InfoDriver)(void);
45 CHAR* (*MikMod_InfoLoader)(void);
46 int (*MikMod_Init)(MIKMOD3_CONST CHAR*);
47 void (*MikMod_RegisterAllLoaders)(void);
48 void (*MikMod_RegisterDriver)(struct MDRIVER*);
49 int* MikMod_errno;
50 MIKMOD3_CONST char* (*MikMod_strerror)(int);
51 void (*MikMod_free)(void*);
52 BOOL (*Player_Active)(void);
53 void (*Player_Free)(MODULE*);
54 MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL);
55 void (*Player_SetPosition)(UWORD);
56 void (*Player_SetVolume)(SWORD);
57 void (*Player_Start)(MODULE*);
58 void (*Player_Stop)(void);
59 ULONG (*VC_WriteBytes)(SBYTE*,ULONG);
60 struct MDRIVER* drv_nos;
61 UWORD* md_device;
62 UWORD* md_mixfreq;
63 UWORD* md_mode;
64 UBYTE* md_musicvolume;
65 UBYTE* md_pansep;
66 UBYTE* md_reverb;
67 UBYTE* md_sndfxvolume;
68 UBYTE* md_volume;
69 } mikmod_loader;
70
71 static mikmod_loader mikmod = {
72 0, NULL
73 };
74
75 #ifdef MIKMOD_DYNAMIC
76 #define FUNCTION_LOADER(FUNC, SIG) \
77 mikmod.FUNC = (SIG) SDL_LoadFunction(mikmod.handle, #FUNC); \
78 if (mikmod.FUNC == NULL) { SDL_UnloadObject(mikmod.handle); return -1; }
79 #define VARIABLE_LOADER(NAME, SIG) \
80 mikmod.NAME = (SIG) SDL_LoadFunction(mikmod.handle, #NAME); \
81 if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; }
82 #else
83 #define FUNCTION_LOADER(FUNC, SIG) \
84 mikmod.FUNC = FUNC;
85 #define VARIABLE_LOADER(NAME, SIG) \
86 mikmod.NAME = &NAME;
87 #endif
88
89 static int MIKMOD_Load()
90 {
91 if (mikmod.loaded == 0) {
92 #ifdef MIKMOD_DYNAMIC
93 mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC);
94 if (mikmod.handle == NULL) {
95 return -1;
96 }
97 #elif defined(__MACOSX__)
98 extern void Player_Start(MODULE*) __attribute__((weak_import));
99 if (Player_Start == NULL)
100 {
101 /* Missing weakly linked framework */
102 Mix_SetError("Missing mikmod.framework");
103 return -1;
104 }
105 #endif
106 FUNCTION_LOADER(MikMod_Exit, void (*)(void))
107 FUNCTION_LOADER(MikMod_InfoDriver, CHAR* (*)(void))
108 FUNCTION_LOADER(MikMod_InfoLoader, CHAR* (*)(void))
109 FUNCTION_LOADER(MikMod_Init, int (*)(MIKMOD3_CONST CHAR*))
110 FUNCTION_LOADER(MikMod_RegisterAllLoaders, void (*)(void))
111 FUNCTION_LOADER(MikMod_RegisterDriver, void (*)(struct MDRIVER*))
112 VARIABLE_LOADER(MikMod_errno, int*)
113 FUNCTION_LOADER(MikMod_strerror, MIKMOD3_CONST char* (*)(int))
114 #ifdef MIKMOD_DYNAMIC
115 mikmod.MikMod_free = (void (*)(void*)) SDL_LoadFunction(mikmod.handle, "MikMod_free");
116 if (!mikmod.MikMod_free) {
117 /* libmikmod 3.1 and earlier doesn't have it */
118 mikmod.MikMod_free = free;
119 }
120 #else
121 #if (LIBMIKMOD_VERSION < 0x030200) || !defined(DMODE_NOISEREDUCTION)
122 /* libmikmod 3.2.0-beta2 or older */
123 mikmod.MikMod_free = free;
124 #else
125 mikmod.MikMod_free = MikMod_free;
126 #endif
127 #endif /* MIKMOD_DYNAMIC */
128 FUNCTION_LOADER(Player_Active, BOOL (*)(void))
129 FUNCTION_LOADER(Player_Free, void (*)(MODULE*))
130 FUNCTION_LOADER(Player_LoadGeneric, MODULE* (*)(MREADER*,int,BOOL))
131 FUNCTION_LOADER(Player_SetPosition, void (*)(UWORD))
132 FUNCTION_LOADER(Player_SetVolume, void (*)(SWORD))
133 FUNCTION_LOADER(Player_Start, void (*)(MODULE*))
134 FUNCTION_LOADER(Player_Stop, void (*)(void))
135 FUNCTION_LOADER(VC_WriteBytes, ULONG (*)(SBYTE*,ULONG))
136 VARIABLE_LOADER(drv_nos, MDRIVER*)
137 VARIABLE_LOADER(md_device, UWORD*)
138 VARIABLE_LOADER(md_mixfreq, UWORD*)
139 VARIABLE_LOADER(md_mode, UWORD*)
140 VARIABLE_LOADER(md_musicvolume, UBYTE*)
141 VARIABLE_LOADER(md_pansep, UBYTE*)
142 VARIABLE_LOADER(md_reverb, UBYTE*)
143 VARIABLE_LOADER(md_sndfxvolume, UBYTE*)
144 VARIABLE_LOADER(md_volume, UBYTE*)
145 }
146 ++mikmod.loaded;
147
148 return 0;
149 }
150
151 static void MIKMOD_Unload()
152 {
153 if (mikmod.loaded == 0) {
154 return;
155 }
156 if (mikmod.loaded == 1) {
157 #ifdef MIKMOD_DYNAMIC
158 SDL_UnloadObject(mikmod.handle);
159 #endif
160 }
161 --mikmod.loaded;
162 }
163
164
165 typedef struct
166 {
167 int play_count;
168 int volume;
169 MODULE *module;
170 SDL_AudioStream *stream;
171 SBYTE *buffer;
172 ULONG buffer_size;
173 } MIKMOD_Music;
174
175
176 static int MIKMOD_Seek(void *context, double position);
177 static void MIKMOD_Delete(void *context);
178
179 /* Initialize the MOD player, with the given mixer settings
180 This function returns 0, or -1 if there was an error.
181 */
182 static int MIKMOD_Open(const SDL_AudioSpec *spec)
183 {
184 CHAR *list;
185
186 /* Set the MikMod music format */
187 if (spec->format == AUDIO_S8 || spec->format == AUDIO_U8) {
188 /* MIKMOD audio format is AUDIO_U8 */
189 *mikmod.md_mode = 0;
190 } else {
191 /* MIKMOD audio format is AUDIO_S16SYS */
192 *mikmod.md_mode = DMODE_16BITS;
193 }
194 if (spec->channels > 1) {
195 *mikmod.md_mode |= DMODE_STEREO;
196 }
197 *mikmod.md_mixfreq = spec->freq;
198 *mikmod.md_device = 0;
199 *mikmod.md_volume = 96;
200 *mikmod.md_musicvolume = 128;
201 *mikmod.md_sndfxvolume = 128;
202 *mikmod.md_pansep = 128;
203 *mikmod.md_reverb = 0;
204 *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND;
205
206 list = mikmod.MikMod_InfoDriver();
207 if (list) {
208 mikmod.MikMod_free(list);
209 } else {
210 mikmod.MikMod_RegisterDriver(mikmod.drv_nos);
211 }
212
213 list = mikmod.MikMod_InfoLoader();
214 if (list) {
215 mikmod.MikMod_free(list);
216 } else {
217 mikmod.MikMod_RegisterAllLoaders();
218 }
219
220 if (mikmod.MikMod_Init(NULL)) {
221 Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
222 return -1;
223 }
224 return 0;
225 }
226
227 /* Uninitialize the music players */
228 static void MIKMOD_Close(void)
229 {
230 if (mikmod.MikMod_Exit) {
231 mikmod.MikMod_Exit();
232 }
233 }
234
235 typedef struct
236 {
237 MREADER mr;
238 /* struct MREADER in libmikmod <= 3.2.0-beta2
239 * doesn't have iobase members. adding them here
240 * so that if we compile against 3.2.0-beta2, we
241 * can still run OK against 3.2.0b3 and newer. */
242 long iobase, prev_iobase;
243 Sint64 offset;
244 Sint64 eof;
245 SDL_RWops *src;
246 } LMM_MREADER;
247
248 int LMM_Seek(struct MREADER *mr,long to,int dir)
249 {
250 Sint64 offset = to;
251 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
252 if (dir == SEEK_SET) {
253 offset += lmmmr->offset;
254 if (offset < lmmmr->offset)
255 return -1;
256 }
257 return (SDL_RWseek(lmmmr->src, offset, dir) < lmmmr->offset)? -1 : 0;
258 }
259 long LMM_Tell(struct MREADER *mr)
260 {
261 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
262 return (long)(SDL_RWtell(lmmmr->src) - lmmmr->offset);
263 }
264 BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz)
265 {
266 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
267 return SDL_RWread(lmmmr->src, buf, sz, 1);
268 }
269 int LMM_Get(struct MREADER *mr)
270 {
271 unsigned char c;
272 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
273 if (SDL_RWread(lmmmr->src, &c, 1, 1)) {
274 return c;
275 }
276 return EOF;
277 }
278 BOOL LMM_Eof(struct MREADER *mr)
279 {
280 Sint64 offset;
281 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
282 offset = LMM_Tell(mr);
283 return offset >= lmmmr->eof;
284 }
285 MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan)
286 {
287 LMM_MREADER lmmmr = {
288 { LMM_Seek, LMM_Tell, LMM_Read, LMM_Get, LMM_Eof },
289 0,
290 0,
291 0
292 };
293 lmmmr.offset = SDL_RWtell(src);
294 SDL_RWseek(src, 0, RW_SEEK_END);
295 lmmmr.eof = SDL_RWtell(src);
296 SDL_RWseek(src, lmmmr.offset, RW_SEEK_SET);
297 lmmmr.src = src;
298 return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0);
299 }
300
301 /* Load a MOD stream from an SDL_RWops object */
302 void *MIKMOD_CreateFromRW(SDL_RWops *src, int freesrc)
303 {
304 MIKMOD_Music *music;
305 SDL_AudioFormat format;
306 Uint8 channels;
307
308 music = (MIKMOD_Music *)SDL_calloc(1, sizeof(*music));
309 if (!music) {
310 SDL_OutOfMemory();
311 return NULL;
312 }
313 music->volume = MIX_MAX_VOLUME;
314
315 music->module = MikMod_LoadSongRW(src, 64);
316 if (!music->module) {
317 Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
318 MIKMOD_Delete(music);
319 return NULL;
320 }
321
322 /* Allow implicit looping, disable fade out and other flags. */
323 music->module->extspd = 1;
324 music->module->panflag = 1;
325 music->module->wrap = 0;
326 music->module->loop = 1;
327 music->module->fadeout = 0;
328
329 if ((*mikmod.md_mode & DMODE_16BITS) == DMODE_16BITS) {
330 format = AUDIO_S16SYS;
331 } else {
332 format = AUDIO_U8;
333 }
334 if ((*mikmod.md_mode & DMODE_STEREO) == DMODE_STEREO) {
335 channels = 2;
336 } else {
337 channels = 1;
338 }
339 music->stream = SDL_NewAudioStream(format, channels, *mikmod.md_mixfreq,
340 music_spec.format, music_spec.channels, music_spec.freq);
341 if (!music->stream) {
342 MIKMOD_Delete(music);
343 return NULL;
344 }
345
346 music->buffer_size = music_spec.samples * (SDL_AUDIO_BITSIZE(format) / 8) * channels;
347 music->buffer = (SBYTE *)SDL_malloc(music->buffer_size);
348 if (!music->buffer) {
349 SDL_OutOfMemory();
350 MIKMOD_Delete(music);
351 return NULL;
352 }
353
354 if (freesrc) {
355 SDL_RWclose(src);
356 }
357 return music;
358 }
359
360 /* Set the volume for a MOD stream */
361 static void MIKMOD_SetVolume(void *context, int volume)
362 {
363 MIKMOD_Music *music = (MIKMOD_Music *)context;
364 music->volume = volume;
365 mikmod.Player_SetVolume((SWORD)volume);
366 }
367
368 /* Start playback of a given MOD stream */
369 static int MIKMOD_Play(void *context, int play_count)
370 {
371 MIKMOD_Music *music = (MIKMOD_Music *)context;
372 music->play_count = play_count;
373 music->module->initvolume = music->volume;
374 mikmod.Player_Start(music->module);
375 return MIKMOD_Seek(music, 0.0);
376 }
377
378 /* Return non-zero if a stream is currently playing */
379 static SDL_bool MIKMOD_IsPlaying(void *context)
380 {
381 return mikmod.Player_Active() ? SDL_TRUE : SDL_FALSE;
382 }
383
384 /* Play some of a stream previously started with MOD_play() */
385 static int MIKMOD_GetSome(void *context, void *data, int bytes, SDL_bool *done)
386 {
387 MIKMOD_Music *music = (MIKMOD_Music *)context;
388 int filled;
389
390 filled = SDL_AudioStreamGet(music->stream, data, bytes);
391 if (filled != 0) {
392 return filled;
393 }
394
395 if (!music->play_count) {
396 /* All done */
397 *done = SDL_TRUE;
398 return 0;
399 }
400
401 /* This never fails, and always writes a full buffer */
402 mikmod.VC_WriteBytes(music->buffer, music->buffer_size);
403
404 if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) {
405 return -1;
406 }
407
408 /* Check to see if we're done now */
409 if (!mikmod.Player_Active()) {
410 if (music->play_count == 1) {
411 music->play_count = 0;
412 SDL_AudioStreamFlush(music->stream);
413 } else {
414 int play_count = -1;
415 if (music->play_count > 0) {
416 play_count = (music->play_count - 1);
417 }
418 if (MIKMOD_Play(music, play_count) < 0) {
419 return -1;
420 }
421 }
422 }
423 return 0;
424 }
425 static int MIKMOD_GetAudio(void *context, void *data, int bytes)
426 {
427 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MIKMOD_GetSome);
428 }
429
430 /* Jump (seek) to a given position (time is in seconds) */
431 static int MIKMOD_Seek(void *context, double position)
432 {
433 mikmod.Player_SetPosition((UWORD)position);
434 return 0;
435 }
436
437 /* Stop playback of a stream previously started with MOD_play() */
438 static void MIKMOD_Stop(void *context)
439 {
440 mikmod.Player_Stop();
441 }
442
443 /* Close the given MOD stream */
444 static void MIKMOD_Delete(void *context)
445 {
446 MIKMOD_Music *music = (MIKMOD_Music *)context;
447
448 if (music->module) {
449 mikmod.Player_Free(music->module);
450 }
451 if (music->stream) {
452 SDL_FreeAudioStream(music->stream);
453 }
454 if (music->buffer) {
455 SDL_free(music->buffer);
456 }
457 SDL_free(music);
458 }
459
460 Mix_MusicInterface Mix_MusicInterface_MIKMOD =
461 {
462 "MIKMOD",
463 MIX_MUSIC_MIKMOD,
464 MUS_MOD,
465 SDL_FALSE,
466 SDL_FALSE,
467
468 MIKMOD_Load,
469 MIKMOD_Open,
470 MIKMOD_CreateFromRW,
471 NULL, /* CreateFromFile */
472 MIKMOD_SetVolume,
473 MIKMOD_Play,
474 MIKMOD_IsPlaying,
475 MIKMOD_GetAudio,
476 MIKMOD_Seek,
477 NULL, /* Pause */
478 NULL, /* Resume */
479 MIKMOD_Stop,
480 MIKMOD_Delete,
481 MIKMOD_Close,
482 MIKMOD_Unload,
483 };
484
485 #endif /* MUSIC_MOD_MIKMOD */
486
487 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_mikmod.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MOD files with libmikmod */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MIKMOD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-310
music_modplug.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MOD_MODPLUG
22
23 #include "SDL_loadso.h"
24
25 #include "music_modplug.h"
26
27 #ifdef MODPLUG_HEADER
28 #include MODPLUG_HEADER
29 #else
30 #include <libmodplug/modplug.h>
31 #endif
32
33 typedef struct {
34 int loaded;
35 void *handle;
36
37 ModPlugFile* (*ModPlug_Load)(const void* data, int size);
38 void (*ModPlug_Unload)(ModPlugFile* file);
39 int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size);
40 void (*ModPlug_Seek)(ModPlugFile* file, int millisecond);
41 void (*ModPlug_GetSettings)(ModPlug_Settings* settings);
42 void (*ModPlug_SetSettings)(const ModPlug_Settings* settings);
43 void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol) ;
44 } modplug_loader;
45
46 static modplug_loader modplug = {
47 0, NULL
48 };
49
50
51 static ModPlug_Settings settings;
52
53 #ifdef MODPLUG_DYNAMIC
54 #define FUNCTION_LOADER(FUNC, SIG) \
55 modplug.FUNC = (SIG) SDL_LoadFunction(modplug.handle, #FUNC); \
56 if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; }
57 #else
58 #define FUNCTION_LOADER(FUNC, SIG) \
59 modplug.FUNC = FUNC;
60 #endif
61
62 static int MODPLUG_Load(void)
63 {
64 if (modplug.loaded == 0) {
65 #ifdef MODPLUG_DYNAMIC
66 modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC);
67 if (modplug.handle == NULL) {
68 return -1;
69 }
70 #elif defined(__MACOSX__)
71 extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import));
72 if (ModPlug_Load == NULL)
73 {
74 /* Missing weakly linked framework */
75 Mix_SetError("Missing modplug.framework");
76 return -1;
77 }
78 #endif
79 FUNCTION_LOADER(ModPlug_Load, ModPlugFile* (*)(const void* data, int size))
80 FUNCTION_LOADER(ModPlug_Unload, void (*)(ModPlugFile* file))
81 FUNCTION_LOADER(ModPlug_Read, int (*)(ModPlugFile* file, void* buffer, int size))
82 FUNCTION_LOADER(ModPlug_Seek, void (*)(ModPlugFile* file, int millisecond))
83 FUNCTION_LOADER(ModPlug_GetSettings, void (*)(ModPlug_Settings* settings))
84 FUNCTION_LOADER(ModPlug_SetSettings, void (*)(const ModPlug_Settings* settings))
85 FUNCTION_LOADER(ModPlug_SetMasterVolume, void (*)(ModPlugFile* file,unsigned int cvol))
86 }
87 ++modplug.loaded;
88
89 return 0;
90 }
91
92 static void MODPLUG_Unload(void)
93 {
94 if (modplug.loaded == 0) {
95 return;
96 }
97 if (modplug.loaded == 1) {
98 #ifdef MODPLUG_DYNAMIC
99 SDL_UnloadObject(modplug.handle);
100 #endif
101 }
102 --modplug.loaded;
103 }
104
105
106 typedef struct
107 {
108 int play_count;
109 ModPlugFile *file;
110 SDL_AudioStream *stream;
111 void *buffer;
112 int buffer_size;
113 } MODPLUG_Music;
114
115
116 static int MODPLUG_Seek(void *context, double position);
117 static void MODPLUG_Delete(void *context);
118
119 static int MODPLUG_Open(const SDL_AudioSpec *spec)
120 {
121 /* ModPlug supports U8 or S16 audio output */
122 modplug.ModPlug_GetSettings(&settings);
123 settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
124 if (spec->channels == 1) {
125 settings.mChannels = 1;
126 } else {
127 settings.mChannels = 2;
128 }
129 if (SDL_AUDIO_BITSIZE(spec->format) == 8) {
130 settings.mBits = 8;
131 } else {
132 settings.mBits = 16;
133 }
134 if (spec->freq >= 44100) {
135 settings.mFrequency = 44100;
136 } else if (spec->freq >= 22050) {
137 settings.mFrequency = 22050;
138 } else {
139 settings.mFrequency = 11025;
140 }
141 settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
142 settings.mReverbDepth = 0;
143 settings.mReverbDelay = 100;
144 settings.mBassAmount = 0;
145 settings.mBassRange = 50;
146 settings.mSurroundDepth = 0;
147 settings.mSurroundDelay = 10;
148 settings.mLoopCount = 0;
149 modplug.ModPlug_SetSettings(&settings);
150 return 0;
151 }
152
153 /* Load a modplug stream from an SDL_RWops object */
154 void *MODPLUG_CreateFromRW(SDL_RWops *src, int freesrc)
155 {
156 MODPLUG_Music *music;
157 void *buffer;
158 size_t size;
159
160 music = (MODPLUG_Music *)SDL_calloc(1, sizeof(*music));
161 if (!music) {
162 SDL_OutOfMemory();
163 return NULL;
164 }
165
166 music->stream = SDL_NewAudioStream((settings.mBits == 8) ? AUDIO_U8 : AUDIO_S16SYS, settings.mChannels, settings.mFrequency,
167 music_spec.format, music_spec.channels, music_spec.freq);
168 if (!music->stream) {
169 MODPLUG_Delete(music);
170 return NULL;
171 }
172
173 music->buffer_size = music_spec.samples * (settings.mBits / 8) * settings.mChannels;
174 music->buffer = SDL_malloc(music->buffer_size);
175 if (!music->buffer) {
176 MODPLUG_Delete(music);
177 return NULL;
178 }
179
180 buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE);
181 if (buffer) {
182 music->file = modplug.ModPlug_Load(buffer, (int)size);
183 if (!music->file) {
184 Mix_SetError("ModPlug_Load failed");
185 }
186 SDL_free(buffer);
187 }
188
189 if (!music->file) {
190 MODPLUG_Delete(music);
191 return NULL;
192 }
193
194 if (freesrc) {
195 SDL_RWclose(src);
196 }
197 return music;
198 }
199
200 /* Set the volume for a modplug stream */
201 static void MODPLUG_SetVolume(void *context, int volume)
202 {
203 MODPLUG_Music *music = (MODPLUG_Music *)context;
204 modplug.ModPlug_SetMasterVolume(music->file, volume*4);
205 }
206
207 /* Start playback of a given modplug stream */
208 static int MODPLUG_Play(void *context, int play_count)
209 {
210 MODPLUG_Music *music = (MODPLUG_Music *)context;
211 music->play_count = play_count;
212 return MODPLUG_Seek(music, 0.0);
213 }
214
215 /* Play some of a stream previously started with modplug_play() */
216 static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
217 {
218 MODPLUG_Music *music = (MODPLUG_Music *)context;
219 int filled, amount;
220
221 filled = SDL_AudioStreamGet(music->stream, data, bytes);
222 if (filled != 0) {
223 return filled;
224 }
225
226 if (!music->play_count) {
227 /* All done */
228 *done = SDL_TRUE;
229 return 0;
230 }
231
232 amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size);
233 if (amount > 0) {
234 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
235 return -1;
236 }
237 } else {
238 if (music->play_count == 1) {
239 music->play_count = 0;
240 SDL_AudioStreamFlush(music->stream);
241 } else {
242 int play_count = -1;
243 if (music->play_count > 0) {
244 play_count = (music->play_count - 1);
245 }
246 if (MODPLUG_Play(music, play_count) < 0) {
247 return -1;
248 }
249 }
250 }
251 return 0;
252 }
253 static int MODPLUG_GetAudio(void *context, void *data, int bytes)
254 {
255 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MODPLUG_GetSome);
256 }
257
258 /* Jump (seek) to a given position */
259 static int MODPLUG_Seek(void *context, double position)
260 {
261 MODPLUG_Music *music = (MODPLUG_Music *)context;
262 modplug.ModPlug_Seek(music->file, (int)(position*1000));
263 return 0;
264 }
265
266 /* Close the given modplug stream */
267 static void MODPLUG_Delete(void *context)
268 {
269 MODPLUG_Music *music = (MODPLUG_Music *)context;
270 if (music->file) {
271 modplug.ModPlug_Unload(music->file);
272 }
273 if (music->stream) {
274 SDL_FreeAudioStream(music->stream);
275 }
276 if (music->buffer) {
277 SDL_free(music->buffer);
278 }
279 SDL_free(music);
280 }
281
282 Mix_MusicInterface Mix_MusicInterface_MODPLUG =
283 {
284 "MODPLUG",
285 MIX_MUSIC_MODPLUG,
286 MUS_MOD,
287 SDL_FALSE,
288 SDL_FALSE,
289
290 MODPLUG_Load,
291 MODPLUG_Open,
292 MODPLUG_CreateFromRW,
293 NULL, /* CreateFromFile */
294 MODPLUG_SetVolume,
295 MODPLUG_Play,
296 NULL, /* IsPlaying */
297 MODPLUG_GetAudio,
298 MODPLUG_Seek,
299 NULL, /* Pause */
300 NULL, /* Resume */
301 NULL, /* Stop */
302 MODPLUG_Delete,
303 NULL, /* Close */
304 MODPLUG_Unload,
305 };
306
307 #endif /* MUSIC_MOD_MODPLUG */
308
309 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_modplug.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MOD files with libmodplug */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MODPLUG;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-431
music_mpg123.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with mpg123 */
22
23 #ifdef MUSIC_MP3_MPG123
24
25 #include <stdio.h> // For SEEK_SET
26
27 #include "SDL_assert.h"
28 #include "SDL_loadso.h"
29
30 #include "music_mpg123.h"
31
32 #include <mpg123.h>
33
34
35 typedef struct {
36 int loaded;
37 void *handle;
38
39 int (*mpg123_close)(mpg123_handle *mh);
40 void (*mpg123_delete)(mpg123_handle *mh);
41 void (*mpg123_exit)(void);
42 int (*mpg123_format)( mpg123_handle *mh, long rate, int channels, int encodings );
43 int (*mpg123_format_none)(mpg123_handle *mh);
44 int (*mpg123_getformat)( mpg123_handle *mh, long *rate, int *channels, int *encoding );
45 int (*mpg123_init)(void);
46 mpg123_handle *(*mpg123_new)(const char* decoder, int *error);
47 int (*mpg123_open_handle)(mpg123_handle *mh, void *iohandle);
48 const char* (*mpg123_plain_strerror)(int errcode);
49 void (*mpg123_rates)(const long **list, size_t *number);
50 int (*mpg123_read)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done );
51 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*) );
52 off_t (*mpg123_seek)( mpg123_handle *mh, off_t sampleoff, int whence );
53 const char* (*mpg123_strerror)(mpg123_handle *mh);
54 } mpg123_loader;
55
56 static mpg123_loader mpg123 = {
57 0, NULL
58 };
59
60 #ifdef MPG123_DYNAMIC
61 #define FUNCTION_LOADER(FUNC, SIG) \
62 mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \
63 if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; }
64 #else
65 #define FUNCTION_LOADER(FUNC, SIG) \
66 mpg123.FUNC = FUNC;
67 #endif
68
69 static int MPG123_Load(void)
70 {
71 if (mpg123.loaded == 0) {
72 #ifdef MPG123_DYNAMIC
73 mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC);
74 if (mpg123.handle == NULL) {
75 return -1;
76 }
77 #elif defined(__MACOSX__)
78 extern int mpg123_init(void) __attribute__((weak_import));
79 if (mpg123_init == NULL)
80 {
81 /* Missing weakly linked framework */
82 Mix_SetError("Missing mpg123.framework");
83 return -1;
84 }
85 #endif
86 FUNCTION_LOADER(mpg123_close, int (*)(mpg123_handle *mh))
87 FUNCTION_LOADER(mpg123_delete, void (*)(mpg123_handle *mh))
88 FUNCTION_LOADER(mpg123_exit, void (*)(void))
89 FUNCTION_LOADER(mpg123_format, int (*)( mpg123_handle *mh, long rate, int channels, int encodings ))
90 FUNCTION_LOADER(mpg123_format_none, int (*)(mpg123_handle *mh))
91 FUNCTION_LOADER(mpg123_getformat, int (*)( mpg123_handle *mh, long *rate, int *channels, int *encoding ))
92 FUNCTION_LOADER(mpg123_init, int (*)(void))
93 FUNCTION_LOADER(mpg123_new, mpg123_handle *(*)(const char* decoder, int *error))
94 FUNCTION_LOADER(mpg123_open_handle, int (*)(mpg123_handle *mh, void *iohandle))
95 FUNCTION_LOADER(mpg123_plain_strerror, const char* (*)(int errcode))
96 FUNCTION_LOADER(mpg123_rates, void (*)(const long **list, size_t *number));
97 FUNCTION_LOADER(mpg123_read, int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done ))
98 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*) ))
99 FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence ))
100 FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh))
101 }
102 ++mpg123.loaded;
103
104 return 0;
105 }
106
107 static void MPG123_Unload(void)
108 {
109 if (mpg123.loaded == 0) {
110 return;
111 }
112 if (mpg123.loaded == 1) {
113 #ifdef MPG123_DYNAMIC
114 SDL_UnloadObject(mpg123.handle);
115 #endif
116 }
117 --mpg123.loaded;
118 }
119
120
121 typedef struct
122 {
123 int play_count;
124 SDL_RWops* src;
125 int freesrc;
126 int volume;
127
128 mpg123_handle* handle;
129 SDL_AudioStream *stream;
130 unsigned char *buffer;
131 size_t buffer_size;
132 } MPG123_Music;
133
134
135 static int MPG123_Seek(void *context, double secs);
136 static void MPG123_Delete(void *context);
137
138 static int mpg123_format_to_sdl(int fmt)
139 {
140 switch (fmt)
141 {
142 case MPG123_ENC_SIGNED_8: return AUDIO_S8;
143 case MPG123_ENC_UNSIGNED_8: return AUDIO_U8;
144 case MPG123_ENC_SIGNED_16: return AUDIO_S16SYS;
145 case MPG123_ENC_UNSIGNED_16: return AUDIO_U16SYS;
146 case MPG123_ENC_SIGNED_32: return AUDIO_S32SYS;
147 case MPG123_ENC_FLOAT_32: return AUDIO_F32SYS;
148 default: return -1;
149 }
150 }
151
152 /*
153 static const char *mpg123_format_str(int fmt)
154 {
155 switch (fmt)
156 {
157 #define f(x) case x: return #x;
158 f(MPG123_ENC_UNSIGNED_8)
159 f(MPG123_ENC_UNSIGNED_16)
160 f(MPG123_ENC_SIGNED_8)
161 f(MPG123_ENC_SIGNED_16)
162 f(MPG123_ENC_SIGNED_32)
163 f(MPG123_ENC_FLOAT_32)
164 #undef f
165 }
166 return "unknown";
167 }
168 */
169
170 static char const* mpg_err(mpg123_handle* mpg, int result)
171 {
172 char const* err = "unknown error";
173
174 if (mpg && result == MPG123_ERR) {
175 err = mpg123.mpg123_strerror(mpg);
176 } else {
177 err = mpg123.mpg123_plain_strerror(result);
178 }
179 return err;
180 }
181
182 /* we're gonna override mpg123's I/O with these wrappers for RWops */
183 static ssize_t rwops_read(void* p, void* dst, size_t n)
184 {
185 return (ssize_t)SDL_RWread((SDL_RWops*)p, dst, 1, n);
186 }
187
188 static off_t rwops_seek(void* p, off_t offset, int whence)
189 {
190 return (off_t)SDL_RWseek((SDL_RWops*)p, (Sint64)offset, whence);
191 }
192
193 static void rwops_cleanup(void* p)
194 {
195 (void)p;
196 /* do nothing, we will free the file later */
197 }
198
199
200 static int MPG123_Open(const SDL_AudioSpec *spec)
201 {
202 if (mpg123.mpg123_init() != MPG123_OK) {
203 Mix_SetError("mpg123_init() failed");
204 return -1;
205 }
206 return 0;
207 }
208
209 static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc)
210 {
211 MPG123_Music *music;
212 int result;
213 const long *rates;
214 size_t i, num_rates;
215
216 music = (MPG123_Music*)SDL_calloc(1, sizeof(*music));
217 if (!music) {
218 return NULL;
219 }
220 music->src = src;
221 music->volume = MIX_MAX_VOLUME;
222
223 /* Just assume 16-bit 2 channel audio for now */
224 music->buffer_size = music_spec.samples * sizeof(Sint16) * 2;
225 music->buffer = (unsigned char *)SDL_malloc(music->buffer_size);
226 if (!music->buffer) {
227 MPG123_Delete(music);
228 SDL_OutOfMemory();
229 return NULL;
230 }
231
232 music->handle = mpg123.mpg123_new(0, &result);
233 if (result != MPG123_OK) {
234 MPG123_Delete(music);
235 Mix_SetError("mpg123_new failed");
236 return NULL;
237 }
238
239 result = mpg123.mpg123_replace_reader_handle(
240 music->handle,
241 rwops_read, rwops_seek, rwops_cleanup
242 );
243 if (result != MPG123_OK) {
244 MPG123_Delete(music);
245 Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result));
246 return NULL;
247 }
248
249 result = mpg123.mpg123_format_none(music->handle);
250 if (result != MPG123_OK) {
251 MPG123_Delete(music);
252 Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result));
253 return NULL;
254 }
255
256 mpg123.mpg123_rates(&rates, &num_rates);
257 for (i = 0; i < num_rates; ++i) {
258 const int channels = (MPG123_MONO|MPG123_STEREO);
259 const int formats = (MPG123_ENC_SIGNED_8 |
260 MPG123_ENC_UNSIGNED_8 |
261 MPG123_ENC_SIGNED_16 |
262 MPG123_ENC_UNSIGNED_16 |
263 MPG123_ENC_SIGNED_32 |
264 MPG123_ENC_FLOAT_32);
265
266 mpg123.mpg123_format(music->handle, rates[i], channels, formats);
267 }
268
269 result = mpg123.mpg123_open_handle(music->handle, music->src);
270 if (result != MPG123_OK) {
271 MPG123_Delete(music);
272 Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result));
273 return NULL;
274 }
275
276 music->freesrc = freesrc;
277 return music;
278 }
279
280 static void MPG123_SetVolume(void *context, int volume)
281 {
282 MPG123_Music *music = (MPG123_Music *)context;
283 music->volume = volume;
284 }
285
286 static int MPG123_Play(void *context, int play_count)
287 {
288 MPG123_Music *music = (MPG123_Music *)context;
289 music->play_count = play_count;
290 return MPG123_Seek(music, 0.0);
291 }
292
293 /* read some mp3 stream data and convert it for output */
294 static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
295 {
296 MPG123_Music *music = (MPG123_Music *)context;
297 int filled, result;
298 size_t amount;
299 long rate;
300 int channels, encoding, format;
301
302 if (music->stream) {
303 filled = SDL_AudioStreamGet(music->stream, data, bytes);
304 if (filled != 0) {
305 return filled;
306 }
307 }
308
309 if (!music->play_count) {
310 /* All done */
311 *done = SDL_TRUE;
312 return 0;
313 }
314
315 result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount);
316 switch (result) {
317 case MPG123_OK:
318 if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) {
319 return -1;
320 }
321 break;
322
323 case MPG123_NEW_FORMAT:
324 result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
325 if (result != MPG123_OK) {
326 Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
327 return -1;
328 }
329 /*printf("MPG123 format: %s, channels = %d, rate = %ld\n", mpg123_format_str(encoding), channels, rate);*/
330
331 format = mpg123_format_to_sdl(encoding);
332 SDL_assert(format != -1);
333
334 music->stream = SDL_NewAudioStream(format, channels, (int)rate,
335 music_spec.format, music_spec.channels, music_spec.freq);
336 if (!music->stream) {
337 return -1;
338 }
339 break;
340
341 case MPG123_DONE:
342 if (music->play_count == 1) {
343 music->play_count = 0;
344 SDL_AudioStreamFlush(music->stream);
345 } else {
346 int play_count = -1;
347 if (music->play_count > 0) {
348 play_count = (music->play_count - 1);
349 }
350 if (MPG123_Play(music, play_count) < 0) {
351 return -1;
352 }
353 }
354 break;
355 default:
356 Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
357 return -1;
358 }
359 return 0;
360 }
361 static int MPG123_GetAudio(void *context, void *data, int bytes)
362 {
363 MPG123_Music *music = (MPG123_Music *)context;
364 return music_pcm_getaudio(context, data, bytes, music->volume, MPG123_GetSome);
365 }
366
367 static int MPG123_Seek(void *context, double secs)
368 {
369 MPG123_Music *music = (MPG123_Music *)context;
370 off_t offset = (off_t)(music_spec.freq * secs);
371
372 if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) {
373 return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset));
374 }
375 return 0;
376 }
377
378 static void MPG123_Delete(void *context)
379 {
380 MPG123_Music *music = (MPG123_Music *)context;
381
382 if (music->handle) {
383 mpg123.mpg123_close(music->handle);
384 mpg123.mpg123_delete(music->handle);
385 }
386 if (music->stream) {
387 SDL_FreeAudioStream(music->stream);
388 }
389 if (music->buffer) {
390 SDL_free(music->buffer);
391 }
392 if (music->freesrc) {
393 SDL_RWclose(music->src);
394 }
395 SDL_free(music);
396 }
397
398 static void MPG123_Close(void)
399 {
400 mpg123.mpg123_exit();
401 }
402
403 Mix_MusicInterface Mix_MusicInterface_MPG123 =
404 {
405 "MPG123",
406 MIX_MUSIC_MPG123,
407 MUS_MP3,
408 SDL_FALSE,
409 SDL_FALSE,
410
411 MPG123_Load,
412 MPG123_Open,
413 MPG123_CreateFromRW,
414 NULL, /* CreateFromFile */
415 MPG123_SetVolume,
416 MPG123_Play,
417 NULL, /* IsPlaying */
418 MPG123_GetAudio,
419 MPG123_Seek,
420 NULL, /* Pause */
421 NULL, /* Resume */
422 NULL, /* Stop */
423 MPG123_Delete,
424 MPG123_Close,
425 MPG123_Unload
426 };
427
428 #endif /* MUSIC_MP3_MPG123 */
429
430 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_mpg123.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with mpg123 */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MPG123;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-108
music_nativemidi.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MID_NATIVE
22
23 /* This file supports playing MIDI files with OS APIs */
24
25 #include "music_nativemidi.h"
26 #include "native_midi/native_midi.h"
27
28
29 static void *NATIVEMIDI_CreateFromRW(SDL_RWops *src, int freesrc)
30 {
31 NativeMidiSong *music = native_midi_loadsong_RW(src, freesrc);
32 if (!music) {
33 Mix_SetError("%s", native_midi_error());
34 }
35 return music;
36 }
37
38 static int NATIVEMIDI_Play(void *context, int play_count)
39 {
40 NativeMidiSong *music = (NativeMidiSong *)context;
41 int loops = play_count;
42 if (loops > 0) {
43 --loops;
44 }
45 native_midi_start(music, loops);
46 return 0;
47 }
48
49 static void NATIVEMIDI_SetVolume(void *context, int volume)
50 {
51 native_midi_setvolume(volume);
52 }
53
54 static SDL_bool NATIVEMIDI_IsPlaying(void *context)
55 {
56 return native_midi_active() ? SDL_TRUE : SDL_FALSE;
57 }
58
59 static void NATIVEMIDI_Pause(void *context)
60 {
61 native_midi_pause();
62 }
63
64 static void NATIVEMIDI_Resume(void *context)
65 {
66 native_midi_resume();
67 }
68
69 static void NATIVEMIDI_Stop(void *context)
70 {
71 native_midi_stop();
72 }
73
74 static void NATIVEMIDI_Delete(void *context)
75 {
76 NativeMidiSong *music = (NativeMidiSong *)context;
77 native_midi_freesong(music);
78 }
79
80 Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI =
81 {
82 "NATIVEMIDI",
83 MIX_MUSIC_NATIVEMIDI,
84 MUS_MID,
85 SDL_FALSE,
86 SDL_FALSE,
87
88 NULL, /* Load */
89 NULL, /* Open */
90 NATIVEMIDI_CreateFromRW,
91 NULL, /* CreateFromFile */
92 NATIVEMIDI_SetVolume,
93 NATIVEMIDI_Play,
94 NATIVEMIDI_IsPlaying,
95 NULL, /* GetAudio */
96 NULL, /* Seek */
97 NATIVEMIDI_Pause,
98 NATIVEMIDI_Resume,
99 NATIVEMIDI_Stop,
100 NATIVEMIDI_Delete,
101 NULL, /* Close */
102 NULL, /* Unload */
103 };
104
105 #endif /* MUSIC_MID_NATIVE */
106
107 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_nativemidi.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with OS APIs */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-457
music_ogg.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_OGG
22
23 /* This file supports Ogg Vorbis music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_ogg.h"
28
29 #define OV_EXCLUDE_STATIC_CALLBACKS
30 #if defined(OGG_HEADER)
31 #include OGG_HEADER
32 #elif defined(OGG_USE_TREMOR)
33 #include <tremor/ivorbisfile.h>
34 #else
35 #include <vorbis/vorbisfile.h>
36 #endif
37
38 typedef struct {
39 int loaded;
40 void *handle;
41 int (*ov_clear)(OggVorbis_File *vf);
42 vorbis_info *(*ov_info)(OggVorbis_File *vf,int link);
43 vorbis_comment *(*ov_comment)(OggVorbis_File *vf,int link);
44 int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks);
45 ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i);
46 #ifdef OGG_USE_TREMOR
47 long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream);
48 #else
49 long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream);
50 #endif
51 #ifdef OGG_USE_TREMOR
52 int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos);
53 #else
54 int (*ov_time_seek)(OggVorbis_File *vf,double pos);
55 #endif
56 int (*ov_pcm_seek)(OggVorbis_File *vf, ogg_int64_t pos);
57 ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf);
58 } vorbis_loader;
59
60 static vorbis_loader vorbis = {
61 0, NULL
62 };
63
64 #ifdef OGG_DYNAMIC
65 #define FUNCTION_LOADER(FUNC, SIG) \
66 vorbis.FUNC = (SIG) SDL_LoadFunction(vorbis.handle, #FUNC); \
67 if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; }
68 #else
69 #define FUNCTION_LOADER(FUNC, SIG) \
70 vorbis.FUNC = FUNC;
71 #endif
72
73 static int OGG_Load(void)
74 {
75 if (vorbis.loaded == 0) {
76 #ifdef OGG_DYNAMIC
77 vorbis.handle = SDL_LoadObject(OGG_DYNAMIC);
78 if (vorbis.handle == NULL) {
79 return -1;
80 }
81 #elif defined(__MACOSX__)
82 extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import));
83 if (ov_open_callbacks == NULL)
84 {
85 /* Missing weakly linked framework */
86 Mix_SetError("Missing Vorbis.framework");
87 return -1;
88 }
89 #endif
90 FUNCTION_LOADER(ov_clear, int (*)(OggVorbis_File *))
91 FUNCTION_LOADER(ov_info, vorbis_info *(*)(OggVorbis_File *,int))
92 FUNCTION_LOADER(ov_comment, vorbis_comment *(*)(OggVorbis_File *,int))
93 FUNCTION_LOADER(ov_open_callbacks, int (*)(void *, OggVorbis_File *, const char *, long, ov_callbacks))
94 FUNCTION_LOADER(ov_pcm_total, ogg_int64_t (*)(OggVorbis_File *,int))
95 #ifdef OGG_USE_TREMOR
96 FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int *))
97 FUNCTION_LOADER(ov_time_seek, long (*)(OggVorbis_File *,ogg_int64_t))
98 #else
99 FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int,int,int,int *))
100 FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,double))
101 #endif
102 FUNCTION_LOADER(ov_pcm_seek, int (*)(OggVorbis_File *,ogg_int64_t))
103 FUNCTION_LOADER(ov_pcm_tell, ogg_int64_t (*)(OggVorbis_File *))
104 }
105 ++vorbis.loaded;
106
107 return 0;
108 }
109
110 static void OGG_Unload(void)
111 {
112 if (vorbis.loaded == 0) {
113 return;
114 }
115 if (vorbis.loaded == 1) {
116 #ifdef OGG_DYNAMIC
117 SDL_UnloadObject(vorbis.handle);
118 #endif
119 }
120 --vorbis.loaded;
121 }
122
123
124 typedef struct {
125 SDL_RWops *src;
126 int freesrc;
127 int play_count;
128 int volume;
129 OggVorbis_File vf;
130 vorbis_info vi;
131 int section;
132 SDL_AudioStream *stream;
133 char *buffer;
134 int buffer_size;
135 int loop;
136 ogg_int64_t loop_start;
137 ogg_int64_t loop_end;
138 ogg_int64_t loop_len;
139 ogg_int64_t channels;
140 } OGG_music;
141
142
143 static int set_ov_error(const char *function, int error)
144 {
145 #define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break;
146 switch (error) {
147 HANDLE_ERROR_CASE(OV_FALSE);
148 HANDLE_ERROR_CASE(OV_EOF);
149 HANDLE_ERROR_CASE(OV_HOLE);
150 HANDLE_ERROR_CASE(OV_EREAD);
151 HANDLE_ERROR_CASE(OV_EFAULT);
152 HANDLE_ERROR_CASE(OV_EIMPL);
153 HANDLE_ERROR_CASE(OV_EINVAL);
154 HANDLE_ERROR_CASE(OV_ENOTVORBIS);
155 HANDLE_ERROR_CASE(OV_EBADHEADER);
156 HANDLE_ERROR_CASE(OV_EVERSION);
157 HANDLE_ERROR_CASE(OV_ENOTAUDIO);
158 HANDLE_ERROR_CASE(OV_EBADPACKET);
159 HANDLE_ERROR_CASE(OV_EBADLINK);
160 HANDLE_ERROR_CASE(OV_ENOSEEK);
161 default:
162 Mix_SetError("%s: unknown error %d\n", function, error);
163 break;
164 }
165 return -1;
166 }
167
168 static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
169 {
170 return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb);
171 }
172
173 static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
174 {
175 return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence);
176 }
177
178 static long sdl_tell_func(void *datasource)
179 {
180 return (long)SDL_RWtell((SDL_RWops*)datasource);
181 }
182
183 static int OGG_Seek(void *context, double time);
184 static void OGG_Delete(void *context);
185
186 static int OGG_UpdateSection(OGG_music *music)
187 {
188 vorbis_info *vi;
189
190 vi = vorbis.ov_info(&music->vf, -1);
191 if (!vi) {
192 Mix_SetError("ov_info returned NULL");
193 return -1;
194 }
195
196 if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) {
197 return 0;
198 }
199 SDL_memcpy(&music->vi, vi, sizeof(*vi));
200
201 if (music->buffer) {
202 SDL_free(music->buffer);
203 music->buffer = NULL;
204 }
205
206 if (music->stream) {
207 SDL_FreeAudioStream(music->stream);
208 music->stream = NULL;
209 }
210
211 music->stream = SDL_NewAudioStream(AUDIO_S16, vi->channels, (int)vi->rate,
212 music_spec.format, music_spec.channels, music_spec.freq);
213 if (!music->stream) {
214 return -1;
215 }
216
217 music->buffer_size = music_spec.samples * sizeof(Sint16) * vi->channels;
218 music->buffer = (char *)SDL_malloc(music->buffer_size);
219 if (!music->buffer) {
220 return -1;
221 }
222 return 0;
223 }
224
225 /* Load an OGG stream from an SDL_RWops object */
226 static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
227 {
228 OGG_music *music;
229 ov_callbacks callbacks;
230 vorbis_comment *vc;
231 int isLoopLength = 0, i;
232 ogg_int64_t fullLength;
233
234 music = (OGG_music *)SDL_calloc(1, sizeof *music);
235 if (!music) {
236 SDL_OutOfMemory();
237 return NULL;
238 }
239 music->src = src;
240 music->volume = MIX_MAX_VOLUME;
241 music->section = -1;
242 music->loop = -1;
243 music->loop_start = -1;
244 music->loop_end = 0;
245 music->loop_len = 0;
246
247 SDL_zero(callbacks);
248 callbacks.read_func = sdl_read_func;
249 callbacks.seek_func = sdl_seek_func;
250 callbacks.tell_func = sdl_tell_func;
251
252 if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) {
253 SDL_SetError("Not an Ogg Vorbis audio stream");
254 SDL_free(music);
255 return NULL;
256 }
257
258 if (OGG_UpdateSection(music) < 0) {
259 OGG_Delete(music);
260 return NULL;
261 }
262
263 vc = vorbis.ov_comment(&music->vf, -1);
264 for (i = 0; i < vc->comments; i++) {
265 char *param = SDL_strdup(vc->user_comments[i]);
266 char *argument = param;
267 char *value = SDL_strchr(param, '=');
268 if (value == NULL) {
269 value = param + SDL_strlen(param);
270 } else {
271 *(value++) = '\0';
272 }
273
274 if (SDL_strcasecmp(argument, "LOOPSTART") == 0)
275 music->loop_start = SDL_strtoull(value, NULL, 0);
276 else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) {
277 music->loop_len = SDL_strtoull(value, NULL, 0);
278 isLoopLength = 1;
279 } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
280 isLoopLength = 0;
281 music->loop_end = SDL_strtoull(value, NULL, 0);
282 }
283 SDL_free(param);
284 }
285
286 if (isLoopLength == 1) {
287 music->loop_end = music->loop_start + music->loop_len;
288 } else {
289 music->loop_len = music->loop_end - music->loop_start;
290 }
291
292 fullLength = vorbis.ov_pcm_total(&music->vf, -1);
293 if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
294 ((music->loop_start < music->loop_end) || (music->loop_end == 0)) &&
295 (music->loop_start < fullLength) &&
296 (music->loop_end <= fullLength)) {
297 if (music->loop_start < 0) music->loop_start = 0;
298 if (music->loop_end == 0) music->loop_end = fullLength;
299 music->loop = 1;
300 }
301
302 music->freesrc = freesrc;
303 return music;
304 }
305
306 /* Set the volume for an OGG stream */
307 static void OGG_SetVolume(void *context, int volume)
308 {
309 OGG_music *music = (OGG_music *)context;
310 music->volume = volume;
311 }
312
313 /* Start playback of a given OGG stream */
314 static int OGG_Play(void *context, int play_count)
315 {
316 OGG_music *music = (OGG_music *)context;
317 music->play_count = play_count;
318 return OGG_Seek(music, 0.0);
319 }
320
321 /* Play some of a stream previously started with OGG_play() */
322 static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
323 {
324 OGG_music *music = (OGG_music *)context;
325 SDL_bool looped = SDL_FALSE;
326 int filled, amount, result;
327 int section;
328 ogg_int64_t pcmPos;
329
330 filled = SDL_AudioStreamGet(music->stream, data, bytes);
331 if (filled != 0) {
332 return filled;
333 }
334
335 if (!music->play_count) {
336 /* All done */
337 *done = SDL_TRUE;
338 return 0;
339 }
340
341 section = music->section;
342 #ifdef OGG_USE_TREMOR
343 amount = vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, &section);
344 #else
345 amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, 0, 2, 1, &section);
346 #endif
347 if (amount < 0) {
348 set_ov_error("ov_read", amount);
349 return -1;
350 }
351
352 if (section != music->section) {
353 music->section = section;
354 if (OGG_UpdateSection(music) < 0) {
355 return -1;
356 }
357 }
358
359 pcmPos = vorbis.ov_pcm_tell(&music->vf);
360 if ((music->loop == 1) && (pcmPos >= music->loop_end)) {
361 amount -= (int)((pcmPos - music->loop_end) * music->channels) * sizeof(Sint16);
362 result = vorbis.ov_pcm_seek(&music->vf, music->loop_start);
363 if (result < 0) {
364 set_ov_error("ov_pcm_seek", result);
365 return -1;
366 }
367 looped = SDL_TRUE;
368 }
369
370 if (amount > 0) {
371 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
372 return -1;
373 }
374 } else if (!looped) {
375 if (music->play_count == 1) {
376 music->play_count = 0;
377 SDL_AudioStreamFlush(music->stream);
378 } else {
379 int play_count = -1;
380 if (music->play_count > 0) {
381 play_count = (music->play_count - 1);
382 }
383 if (OGG_Play(music, play_count) < 0) {
384 return -1;
385 }
386 }
387 }
388 return 0;
389 }
390 static int OGG_GetAudio(void *context, void *data, int bytes)
391 {
392 OGG_music *music = (OGG_music *)context;
393 return music_pcm_getaudio(context, data, bytes, music->volume, OGG_GetSome);
394 }
395
396 /* Jump (seek) to a given position (time is in seconds) */
397 static int OGG_Seek(void *context, double time)
398 {
399 OGG_music *music = (OGG_music *)context;
400 int result;
401 #ifdef OGG_USE_TREMOR
402 result = vorbis.ov_time_seek(&music->vf, (ogg_int64_t)(time * 1000.0));
403 #else
404 result = vorbis.ov_time_seek(&music->vf, time);
405 #endif
406 if (result < 0) {
407 return set_ov_error("ov_time_seek", result);
408 }
409 return 0;
410 }
411
412 /* Close the given OGG stream */
413 static void OGG_Delete(void *context)
414 {
415 OGG_music *music = (OGG_music *)context;
416 vorbis.ov_clear(&music->vf);
417 if (music->stream) {
418 SDL_FreeAudioStream(music->stream);
419 }
420 if (music->buffer) {
421 SDL_free(music->buffer);
422 }
423 if (music->freesrc) {
424 SDL_RWclose(music->src);
425 }
426 SDL_free(music);
427 }
428
429 Mix_MusicInterface Mix_MusicInterface_OGG =
430 {
431 "OGG",
432 MIX_MUSIC_OGG,
433 MUS_OGG,
434 SDL_FALSE,
435 SDL_FALSE,
436
437 OGG_Load,
438 NULL, /* Open */
439 OGG_CreateFromRW,
440 NULL, /* CreateFromFile */
441 OGG_SetVolume,
442 OGG_Play,
443 NULL, /* IsPlaying */
444 OGG_GetAudio,
445 OGG_Seek,
446 NULL, /* Pause */
447 NULL, /* Resume */
448 NULL, /* Stop */
449 OGG_Delete,
450 NULL, /* Close */
451 OGG_Unload,
452 };
453
454 #endif /* MUSIC_OGG */
455
456 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_ogg.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports Ogg Vorbis music streams */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_OGG;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-373
music_opus.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_OPUS
22
23 /* This file supports Ogg Opus music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_opus.h"
28
29 #if defined(OPUS_HEADER)
30 #include OPUS_HEADER
31 #else
32 #include <opus/opusfile.h>
33 #endif
34
35 typedef struct {
36 int loaded;
37 void *handle;
38 OggOpusFile *(*op_open_callbacks)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *);
39 void (*op_free)(OggOpusFile *);
40 const OpusHead *(*op_head)(const OggOpusFile *,int);
41 int (*op_seekable)(const OggOpusFile *);
42 int (*op_read)(OggOpusFile *, opus_int16 *,int,int *);
43 int (*op_pcm_seek)(OggOpusFile *,ogg_int64_t);
44 } opus_loader;
45
46 static opus_loader opus = {
47 0, NULL
48 };
49
50 #ifdef OPUS_DYNAMIC
51 #define FUNCTION_LOADER(FUNC, SIG) \
52 opus.FUNC = (SIG) SDL_LoadFunction(opus.handle, #FUNC); \
53 if (opus.FUNC == NULL) { SDL_UnloadObject(opus.handle); return -1; }
54 #else
55 #define FUNCTION_LOADER(FUNC, SIG) \
56 opus.FUNC = FUNC;
57 #endif
58
59 static int OPUS_Load(void)
60 {
61 if (opus.loaded == 0) {
62 #ifdef OPUS_DYNAMIC
63 opus.handle = SDL_LoadObject(OPUS_DYNAMIC);
64 if (opus.handle == NULL) {
65 return -1;
66 }
67 #elif defined(__MACOSX__)
68 extern OggOpusFile *op_open_callbacks(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *) __attribute__((weak_import));
69 if (op_open_callbacks == NULL) {
70 /* Missing weakly linked framework */
71 Mix_SetError("Missing OpusFile.framework");
72 return -1;
73 }
74 #endif
75 FUNCTION_LOADER(op_open_callbacks, OggOpusFile *(*)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *))
76 FUNCTION_LOADER(op_free, void (*)(OggOpusFile *))
77 FUNCTION_LOADER(op_head, const OpusHead *(*)(const OggOpusFile *,int))
78 FUNCTION_LOADER(op_seekable, int (*)(const OggOpusFile *))
79 FUNCTION_LOADER(op_read, int (*)(OggOpusFile *, opus_int16 *,int,int *))
80 FUNCTION_LOADER(op_pcm_seek, int (*)(OggOpusFile *,ogg_int64_t))
81 }
82 ++opus.loaded;
83
84 return 0;
85 }
86
87 static void OPUS_Unload(void)
88 {
89 if (opus.loaded == 0) {
90 return;
91 }
92 if (opus.loaded == 1) {
93 #ifdef OPUS_DYNAMIC
94 SDL_UnloadObject(opus.handle);
95 #endif
96 }
97 --opus.loaded;
98 }
99
100
101 typedef struct {
102 SDL_RWops *src;
103 int freesrc;
104 int play_count;
105 int volume;
106 OggOpusFile *of;
107 const OpusHead *op_info;
108 int section;
109 SDL_AudioStream *stream;
110 char *buffer;
111 int buffer_size;
112 } OPUS_music;
113
114
115 static int set_op_error(const char *function, int error)
116 {
117 #define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break;
118 switch (error) {
119 HANDLE_ERROR_CASE(OP_FALSE);
120 HANDLE_ERROR_CASE(OP_EOF);
121 HANDLE_ERROR_CASE(OP_HOLE);
122 HANDLE_ERROR_CASE(OP_EREAD);
123 HANDLE_ERROR_CASE(OP_EFAULT);
124 HANDLE_ERROR_CASE(OP_EIMPL);
125 HANDLE_ERROR_CASE(OP_EINVAL);
126 HANDLE_ERROR_CASE(OP_ENOTFORMAT);
127 HANDLE_ERROR_CASE(OP_EBADHEADER);
128 HANDLE_ERROR_CASE(OP_EVERSION);
129 HANDLE_ERROR_CASE(OP_ENOTAUDIO);
130 HANDLE_ERROR_CASE(OP_EBADPACKET);
131 HANDLE_ERROR_CASE(OP_EBADLINK);
132 HANDLE_ERROR_CASE(OP_ENOSEEK);
133 HANDLE_ERROR_CASE(OP_EBADTIMESTAMP);
134 default:
135 Mix_SetError("%s: unknown error %d\n", function, error);
136 break;
137 }
138 return -1;
139 }
140
141 static int sdl_read_func(void *datasource, unsigned char *ptr, int size)
142 {
143 return (int)SDL_RWread((SDL_RWops*)datasource, ptr, 1, size);
144 }
145
146 static int sdl_seek_func(void *datasource, opus_int64 offset, int whence)
147 {
148 return (SDL_RWseek((SDL_RWops*)datasource, offset, whence) < 0)? -1 : 0;
149 }
150
151 static opus_int64 sdl_tell_func(void *datasource)
152 {
153 return SDL_RWtell((SDL_RWops*)datasource);
154 }
155
156 static int OPUS_Seek(void*, double);
157 static void OPUS_Delete(void*);
158
159 static int OPUS_UpdateSection(OPUS_music *music)
160 {
161 const OpusHead *op_info;
162
163 op_info = opus.op_head(music->of, -1);
164 if (!op_info) {
165 Mix_SetError("op_head returned NULL");
166 return -1;
167 }
168
169 if (music->op_info && op_info->channel_count == music->op_info->channel_count) {
170 return 0;
171 }
172 music->op_info = op_info;
173
174 if (music->buffer) {
175 SDL_free(music->buffer);
176 music->buffer = NULL;
177 }
178
179 if (music->stream) {
180 SDL_FreeAudioStream(music->stream);
181 music->stream = NULL;
182 }
183
184 music->stream = SDL_NewAudioStream(AUDIO_S16, op_info->channel_count, 48000,
185 music_spec.format, music_spec.channels, music_spec.freq);
186 if (!music->stream) {
187 return -1;
188 }
189
190 music->buffer_size = music_spec.samples * sizeof(opus_int16) * op_info->channel_count;
191 music->buffer = (char *)SDL_malloc(music->buffer_size);
192 if (!music->buffer) {
193 return -1;
194 }
195 return 0;
196 }
197
198 /* Load an Opus stream from an SDL_RWops object */
199 static void *OPUS_CreateFromRW(SDL_RWops *src, int freesrc)
200 {
201 OPUS_music *music;
202 OpusFileCallbacks callbacks;
203 int err = 0;
204
205 music = (OPUS_music *)SDL_calloc(1, sizeof *music);
206 if (!music) {
207 SDL_OutOfMemory();
208 return NULL;
209 }
210 music->src = src;
211 music->volume = MIX_MAX_VOLUME;
212 music->section = -1;
213
214 SDL_zero(callbacks);
215 callbacks.read = sdl_read_func;
216 callbacks.seek = sdl_seek_func;
217 callbacks.tell = sdl_tell_func;
218
219 music->of = opus.op_open_callbacks(src, &callbacks, NULL, 0, &err);
220 if (music->of == NULL) {
221 /* set_op_error("op_open_callbacks", err);*/
222 SDL_SetError("Not an Opus audio stream");
223 SDL_free(music);
224 return NULL;
225 }
226
227 if (!opus.op_seekable(music->of)) {
228 OPUS_Delete(music);
229 Mix_SetError("Opus stream not seekable");
230 return NULL;
231 }
232
233 if (OPUS_UpdateSection(music) < 0) {
234 OPUS_Delete(music);
235 return NULL;
236 }
237
238 music->freesrc = freesrc;
239 return music;
240 }
241
242 /* Set the volume for an Opus stream */
243 static void OPUS_SetVolume(void *context, int volume)
244 {
245 OPUS_music *music = (OPUS_music *)context;
246 music->volume = volume;
247 }
248
249 /* Start playback of a given Opus stream */
250 static int OPUS_Play(void *context, int play_count)
251 {
252 OPUS_music *music = (OPUS_music *)context;
253 music->play_count = play_count;
254 return OPUS_Seek(music, 0.0);
255 }
256
257 /* Play some of a stream previously started with OPUS_Play() */
258 static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done)
259 {
260 OPUS_music *music = (OPUS_music *)context;
261 int filled, samples, section;
262
263 filled = SDL_AudioStreamGet(music->stream, data, bytes);
264 if (filled != 0) {
265 return filled;
266 }
267
268 if (!music->play_count) {
269 /* All done */
270 *done = SDL_TRUE;
271 return 0;
272 }
273
274 section = music->section;
275 samples = opus.op_read(music->of, (opus_int16 *)music->buffer, music->buffer_size / sizeof(opus_int16), &section);
276 if (samples < 0) {
277 set_op_error("op_read", samples);
278 return -1;
279 }
280
281 if (section != music->section) {
282 music->section = section;
283 if (OPUS_UpdateSection(music) < 0) {
284 return -1;
285 }
286 }
287
288 if (samples > 0) {
289 filled = samples * music->op_info->channel_count * 2;
290 if (SDL_AudioStreamPut(music->stream, music->buffer, filled) < 0) {
291 return -1;
292 }
293 } else {
294 if (music->play_count == 1) {
295 music->play_count = 0;
296 SDL_AudioStreamFlush(music->stream);
297 } else {
298 int play_count = -1;
299 if (music->play_count > 0) {
300 play_count = (music->play_count - 1);
301 }
302 if (OPUS_Play(music, play_count) < 0) {
303 return -1;
304 }
305 }
306 }
307 return 0;
308 }
309
310 static int OPUS_GetAudio(void *context, void *data, int bytes)
311 {
312 OPUS_music *music = (OPUS_music *)context;
313 return music_pcm_getaudio(context, data, bytes, music->volume, OPUS_GetSome);
314 }
315
316 /* Jump (seek) to a given position (time is in seconds) */
317 static int OPUS_Seek(void *context, double time)
318 {
319 OPUS_music *music = (OPUS_music *)context;
320 int result;
321 result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000));
322 if (result < 0) {
323 return set_op_error("op_pcm_seek", result);
324 }
325 return 0;
326 }
327
328 /* Close the given Opus stream */
329 static void OPUS_Delete(void *context)
330 {
331 OPUS_music *music = (OPUS_music *)context;
332 opus.op_free(music->of);
333 if (music->stream) {
334 SDL_FreeAudioStream(music->stream);
335 }
336 if (music->buffer) {
337 SDL_free(music->buffer);
338 }
339 if (music->freesrc) {
340 SDL_RWclose(music->src);
341 }
342 SDL_free(music);
343 }
344
345 Mix_MusicInterface Mix_MusicInterface_Opus =
346 {
347 "OPUS",
348 MIX_MUSIC_OPUS,
349 MUS_OPUS,
350 SDL_FALSE,
351 SDL_FALSE,
352
353 OPUS_Load,
354 NULL, /* Open */
355 OPUS_CreateFromRW,
356 NULL, /* CreateFromFile */
357 OPUS_SetVolume,
358 OPUS_Play,
359 NULL, /* IsPlaying */
360 OPUS_GetAudio,
361 OPUS_Seek,
362 NULL, /* Pause */
363 NULL, /* Resume */
364 NULL, /* Stop */
365 OPUS_Delete,
366 NULL, /* Close */
367 OPUS_Unload,
368 };
369
370 #endif /* MUSIC_OPUS */
371
372 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_opus.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports Ogg Opus music streams */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_Opus;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-220
music_timidity.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with timidity */
22
23 #ifdef MUSIC_MID_TIMIDITY
24
25 #include "music_timidity.h"
26
27 #include "timidity/timidity.h"
28
29
30 typedef struct
31 {
32 int play_count;
33 MidiSong *song;
34 SDL_AudioStream *stream;
35 void *buffer;
36 Sint32 buffer_size;
37 } TIMIDITY_Music;
38
39
40 static int TIMIDITY_Seek(void *context, double position);
41 static void TIMIDITY_Delete(void *context);
42
43 static int TIMIDITY_Open(const SDL_AudioSpec *spec)
44 {
45 return Timidity_Init();
46 }
47
48 static void TIMIDITY_Close(void)
49 {
50 Timidity_Exit();
51 }
52
53 void *TIMIDITY_CreateFromRW(SDL_RWops *src, int freesrc)
54 {
55 TIMIDITY_Music *music;
56 SDL_AudioSpec spec;
57 SDL_bool need_stream = SDL_FALSE;
58
59 music = (TIMIDITY_Music *)SDL_calloc(1, sizeof(*music));
60 if (!music) {
61 SDL_OutOfMemory();
62 return NULL;
63 }
64
65 SDL_memcpy(&spec, &music_spec, sizeof(spec));
66 if (spec.channels > 2) {
67 need_stream = SDL_TRUE;
68 spec.channels = 2;
69 }
70 music->song = Timidity_LoadSong(src, &spec);
71 if (!music->song) {
72 TIMIDITY_Delete(music);
73 return NULL;
74 }
75
76 if (need_stream) {
77 music->stream = SDL_NewAudioStream(spec.format, spec.channels, spec.freq,
78 music_spec.format, music_spec.channels, music_spec.freq);
79 if (!music->stream) {
80 TIMIDITY_Delete(music);
81 return NULL;
82 }
83
84 music->buffer_size = spec.samples * (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels;
85 music->buffer = SDL_malloc(music->buffer_size);
86 if (!music->buffer) {
87 SDL_OutOfMemory();
88 TIMIDITY_Delete(music);
89 return NULL;
90 }
91 }
92
93 if (freesrc) {
94 SDL_RWclose(src);
95 }
96 return music;
97 }
98
99 static void TIMIDITY_SetVolume(void *context, int volume)
100 {
101 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
102 Timidity_SetVolume(music->song, volume);
103 }
104
105 static int TIMIDITY_Play(void *context, int play_count)
106 {
107 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
108 music->play_count = play_count;
109 Timidity_Start(music->song);
110 return TIMIDITY_Seek(music, 0.0);
111 }
112
113 static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done)
114 {
115 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
116 int filled, amount, expected;
117
118 if (music->stream) {
119 filled = SDL_AudioStreamGet(music->stream, data, bytes);
120 if (filled != 0) {
121 return filled;
122 }
123 }
124
125 if (!music->play_count) {
126 /* All done */
127 *done = SDL_TRUE;
128 return 0;
129 }
130
131 if (music->stream) {
132 expected = music->buffer_size;
133 amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size);
134 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
135 return -1;
136 }
137 } else {
138 expected = bytes;
139 amount = Timidity_PlaySome(music->song, data, bytes);
140 }
141
142 if (amount < expected) {
143 if (music->play_count == 1) {
144 /* We didn't consume anything and we're done */
145 music->play_count = 0;
146 } else {
147 int play_count = -1;
148 if (music->play_count > 0) {
149 play_count = (music->play_count - 1);
150 }
151 if (TIMIDITY_Play(music, play_count) < 0) {
152 return -1;
153 }
154 }
155 }
156 if (music->stream) {
157 /* We'll pick it up from the stream next time around */
158 return 0;
159 } else {
160 /* We wrote output data */
161 return amount;
162 }
163 }
164 static int TIMIDITY_GetAudio(void *context, void *data, int bytes)
165 {
166 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, TIMIDITY_GetSome);
167 }
168
169 static int TIMIDITY_Seek(void *context, double position)
170 {
171 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
172 Timidity_Seek(music->song, (Uint32)(position * 1000));
173 return 0;
174 }
175
176 static void TIMIDITY_Delete(void *context)
177 {
178 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
179
180 if (music->song) {
181 Timidity_FreeSong(music->song);
182 }
183 if (music->stream) {
184 SDL_FreeAudioStream(music->stream);
185 }
186 if (music->buffer) {
187 SDL_free(music->buffer);
188 }
189 SDL_free(music);
190 }
191
192 Mix_MusicInterface Mix_MusicInterface_TIMIDITY =
193 {
194 "TIMIDITY",
195 MIX_MUSIC_TIMIDITY,
196 MUS_MID,
197 SDL_FALSE,
198 SDL_FALSE,
199
200 NULL, /* Load */
201 TIMIDITY_Open,
202 TIMIDITY_CreateFromRW,
203 NULL, /* CreateFromFile */
204 TIMIDITY_SetVolume,
205 TIMIDITY_Play,
206 NULL, /* IsPlaying */
207 TIMIDITY_GetAudio,
208 TIMIDITY_Seek,
209 NULL, /* Pause */
210 NULL, /* Resume */
211 NULL, /* Stop */
212 TIMIDITY_Delete,
213 TIMIDITY_Close,
214 NULL, /* Unload */
215 };
216
217 #endif /* MUSIC_MID_TIMIDITY */
218
219 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_timidity.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with timidity */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-638
music_wav.c less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_WAV
22
23 /* This file supports streaming WAV files */
24
25 #include "music_wav.h"
26
27
28 typedef struct {
29 SDL_bool active;
30 Uint32 start;
31 Uint32 stop;
32 Uint32 initial_play_count;
33 Uint32 current_play_count;
34 } WAVLoopPoint;
35
36 typedef struct {
37 SDL_RWops *src;
38 SDL_bool freesrc;
39 SDL_AudioSpec spec;
40 int volume;
41 int play_count;
42 Sint64 start;
43 Sint64 stop;
44 Uint8 *buffer;
45 SDL_AudioStream *stream;
46 int numloops;
47 WAVLoopPoint *loops;
48 } WAV_Music;
49
50 /*
51 Taken with permission from SDL_wave.h, part of the SDL library,
52 available at: http://www.libsdl.org/
53 and placed under the same license as this mixer library.
54 */
55
56 /* WAVE files are little-endian */
57
58 /*******************************************/
59 /* Define values for Microsoft WAVE format */
60 /*******************************************/
61 #define RIFF 0x46464952 /* "RIFF" */
62 #define WAVE 0x45564157 /* "WAVE" */
63 #define FMT 0x20746D66 /* "fmt " */
64 #define DATA 0x61746164 /* "data" */
65 #define SMPL 0x6c706d73 /* "smpl" */
66 #define PCM_CODE 1
67 #define ADPCM_CODE 2
68 #define WAVE_MONO 1
69 #define WAVE_STEREO 2
70
71 typedef struct {
72 /* Not saved in the chunk we read:
73 Uint32 chunkID;
74 Uint32 chunkLen;
75 */
76 Uint16 encoding;
77 Uint16 channels; /* 1 = mono, 2 = stereo */
78 Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
79 Uint32 byterate; /* Average bytes per second */
80 Uint16 blockalign; /* Bytes per sample block */
81 Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
82 } WaveFMT;
83
84 typedef struct {
85 Uint32 identifier;
86 Uint32 type;
87 Uint32 start;
88 Uint32 end;
89 Uint32 fraction;
90 Uint32 play_count;
91 } SampleLoop;
92
93 typedef struct {
94 /* Not saved in the chunk we read:
95 Uint32 chunkID;
96 Uint32 chunkLen;
97 */
98 Uint32 manufacturer;
99 Uint32 product;
100 Uint32 sample_period;
101 Uint32 MIDI_unity_note;
102 Uint32 MIDI_pitch_fraction;
103 Uint32 SMTPE_format;
104 Uint32 SMTPE_offset;
105 Uint32 sample_loops;
106 Uint32 sampler_data;
107 SampleLoop loops[1];
108 } SamplerChunk;
109
110 /*********************************************/
111 /* Define values for AIFF (IFF audio) format */
112 /*********************************************/
113 #define FORM 0x4d524f46 /* "FORM" */
114 #define AIFF 0x46464941 /* "AIFF" */
115 #define SSND 0x444e5353 /* "SSND" */
116 #define COMM 0x4d4d4f43 /* "COMM" */
117
118
119 /* Function to load the WAV/AIFF stream */
120 static SDL_bool LoadWAVMusic(WAV_Music *wave);
121 static SDL_bool LoadAIFFMusic(WAV_Music *wave);
122
123 static void WAV_Delete(void *context);
124
125 /* Load a WAV stream from the given RWops object */
126 static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc)
127 {
128 WAV_Music *music;
129 Uint32 magic;
130 SDL_bool loaded = SDL_FALSE;
131
132 music = (WAV_Music *)SDL_calloc(1, sizeof(*music));
133 if (!music) {
134 SDL_OutOfMemory();
135 return NULL;
136 }
137 music->src = src;
138 music->volume = MIX_MAX_VOLUME;
139
140 magic = SDL_ReadLE32(src);
141 if (magic == RIFF || magic == WAVE) {
142 loaded = LoadWAVMusic(music);
143 } else if (magic == FORM) {
144 loaded = LoadAIFFMusic(music);
145 } else {
146 Mix_SetError("Unknown WAVE format");
147 }
148 if (!loaded) {
149 SDL_free(music);
150 return NULL;
151 }
152 music->buffer = (Uint8*)SDL_malloc(music->spec.size);
153 if (!music->buffer) {
154 WAV_Delete(music);
155 return NULL;
156 }
157 music->stream = SDL_NewAudioStream(
158 music->spec.format, music->spec.channels, music->spec.freq,
159 music_spec.format, music_spec.channels, music_spec.freq);
160 if (!music->stream) {
161 WAV_Delete(music);
162 return NULL;
163 }
164
165 music->freesrc = freesrc;
166 return music;
167 }
168
169 static void WAV_SetVolume(void *context, int volume)
170 {
171 WAV_Music *music = (WAV_Music *)context;
172 music->volume = volume;
173 }
174
175 /* Start playback of a given WAV stream */
176 static int WAV_Play(void *context, int play_count)
177 {
178 WAV_Music *music = (WAV_Music *)context;
179 int i;
180 for (i = 0; i < music->numloops; ++i) {
181 WAVLoopPoint *loop = &music->loops[i];
182 loop->active = SDL_TRUE;
183 loop->current_play_count = loop->initial_play_count;
184 }
185 music->play_count = play_count;
186 if (SDL_RWseek(music->src, music->start, RW_SEEK_SET) < 0) {
187 return -1;
188 }
189 return 0;
190 }
191
192 /* Play some of a stream previously started with WAV_Play() */
193 static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done)
194 {
195 WAV_Music *music = (WAV_Music *)context;
196 Sint64 pos, stop;
197 WAVLoopPoint *loop;
198 Sint64 loop_start;
199 Sint64 loop_stop;
200 SDL_bool looped = SDL_FALSE;
201 int i;
202 int filled, amount, result;
203
204 filled = SDL_AudioStreamGet(music->stream, data, bytes);
205 if (filled != 0) {
206 return filled;
207 }
208
209 if (!music->play_count) {
210 /* All done */
211 *done = SDL_TRUE;
212 return 0;
213 }
214
215 pos = SDL_RWtell(music->src);
216 stop = music->stop;
217 loop = NULL;
218 for (i = 0; i < music->numloops; ++i) {
219 loop = &music->loops[i];
220 if (loop->active) {
221 const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels;
222 loop_start = music->start + loop->start * bytes_per_sample;
223 loop_stop = music->start + (loop->stop + 1) * bytes_per_sample;
224 if (pos >= loop_start && pos < loop_stop)
225 {
226 stop = loop_stop;
227 break;
228 }
229 }
230 loop = NULL;
231 }
232
233 amount = music->spec.size;
234 if ((stop - pos) < amount) {
235 amount = (int)(stop - pos);
236 }
237 amount = (int)SDL_RWread(music->src, music->buffer, 1, amount);
238 if (amount > 0) {
239 result = SDL_AudioStreamPut(music->stream, music->buffer, amount);
240 if (result < 0) {
241 return -1;
242 }
243 } else {
244 /* We might be looping, continue */
245 }
246
247 if (loop && SDL_RWtell(music->src) >= stop) {
248 if (loop->current_play_count == 1) {
249 loop->active = SDL_FALSE;
250 } else {
251 if (loop->current_play_count > 0) {
252 --loop->current_play_count;
253 }
254 SDL_RWseek(music->src, loop_start, RW_SEEK_SET);
255 looped = SDL_TRUE;
256 }
257 }
258
259 if (!looped && SDL_RWtell(music->src) >= music->stop) {
260 if (music->play_count == 1) {
261 music->play_count = 0;
262 SDL_AudioStreamFlush(music->stream);
263 } else {
264 int play_count = -1;
265 if (music->play_count > 0) {
266 play_count = (music->play_count - 1);
267 }
268 if (WAV_Play(music, play_count) < 0) {
269 return -1;
270 }
271 }
272 }
273
274 /* We'll get called again in the case where we looped or have more data */
275 return 0;
276 }
277
278 static int WAV_GetAudio(void *context, void *data, int bytes)
279 {
280 WAV_Music *music = (WAV_Music *)context;
281 return music_pcm_getaudio(context, data, bytes, music->volume, WAV_GetSome);
282 }
283
284 /* Close the given WAV stream */
285 static void WAV_Delete(void *context)
286 {
287 WAV_Music *music = (WAV_Music *)context;
288
289 /* Clean up associated data */
290 if (music->loops) {
291 SDL_free(music->loops);
292 }
293 if (music->stream) {
294 SDL_FreeAudioStream(music->stream);
295 }
296 if (music->buffer) {
297 SDL_free(music->buffer);
298 }
299 if (music->freesrc) {
300 SDL_RWclose(music->src);
301 }
302 SDL_free(music);
303 }
304
305 static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length)
306 {
307 SDL_AudioSpec *spec = &wave->spec;
308 WaveFMT *format;
309 Uint8 *data;
310 SDL_bool loaded = SDL_FALSE;
311
312 if (chunk_length < sizeof(*format)) {
313 Mix_SetError("Wave format chunk too small");
314 return SDL_FALSE;
315 }
316
317 data = (Uint8 *)SDL_malloc(chunk_length);
318 if (!data) {
319 Mix_SetError("Out of memory");
320 return SDL_FALSE;
321 }
322 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
323 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
324 return SDL_FALSE;
325 }
326 format = (WaveFMT *)data;
327
328 /* Decode the audio data format */
329 switch (SDL_SwapLE16(format->encoding)) {
330 case PCM_CODE:
331 /* We can understand this */
332 break;
333 default:
334 Mix_SetError("Unknown WAVE data format");
335 goto done;
336 }
337 spec->freq = SDL_SwapLE32(format->frequency);
338 switch (SDL_SwapLE16(format->bitspersample)) {
339 case 8:
340 spec->format = AUDIO_U8;
341 break;
342 case 16:
343 spec->format = AUDIO_S16;
344 break;
345 default:
346 Mix_SetError("Unknown PCM data format");
347 goto done;
348 }
349 spec->channels = (Uint8) SDL_SwapLE16(format->channels);
350 spec->samples = 4096; /* Good default buffer size */
351 /* SDL_CalculateAudioSpec */
352 spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
353 spec->size *= spec->channels;
354 spec->size *= spec->samples;
355
356 loaded = SDL_TRUE;
357
358 done:
359 SDL_free(data);
360 return loaded;
361 }
362
363 static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length)
364 {
365 wave->start = SDL_RWtell(wave->src);
366 wave->stop = wave->start + chunk_length;
367 SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR);
368 return SDL_TRUE;
369 }
370
371 static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop)
372 {
373 WAVLoopPoint *loop;
374 WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1)*sizeof(*wave->loops));
375 if (!loops) {
376 Mix_SetError("Out of memory");
377 return SDL_FALSE;
378 }
379
380 loop = &loops[ wave->numloops ];
381 loop->start = start;
382 loop->stop = stop;
383 loop->initial_play_count = play_count;
384 loop->current_play_count = play_count;
385
386 wave->loops = loops;
387 ++wave->numloops;
388 return SDL_TRUE;
389 }
390
391 static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length)
392 {
393 SamplerChunk *chunk;
394 Uint8 *data;
395 Uint32 i;
396 SDL_bool loaded = SDL_FALSE;
397
398 data = (Uint8 *)SDL_malloc(chunk_length);
399 if (!data) {
400 Mix_SetError("Out of memory");
401 return SDL_FALSE;
402 }
403 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
404 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
405 return SDL_FALSE;
406 }
407 chunk = (SamplerChunk *)data;
408
409 for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) {
410 const Uint32 LOOP_TYPE_FORWARD = 0;
411 Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type);
412 if (loop_type == LOOP_TYPE_FORWARD) {
413 AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end));
414 }
415 }
416
417 loaded = SDL_TRUE;
418 SDL_free(data);
419 return loaded;
420 }
421
422 static SDL_bool LoadWAVMusic(WAV_Music *wave)
423 {
424 SDL_RWops *src = wave->src;
425 Uint32 chunk_type;
426 Uint32 chunk_length;
427 SDL_bool found_FMT = SDL_FALSE;
428 SDL_bool found_DATA = SDL_FALSE;
429
430 /* WAV magic header */
431 Uint32 wavelen;
432 Uint32 WAVEmagic;
433
434 /* Check the magic header */
435 wavelen = SDL_ReadLE32(src);
436 WAVEmagic = SDL_ReadLE32(src);
437
438 /* Read the chunks */
439 for (; ;) {
440 chunk_type = SDL_ReadLE32(src);
441 chunk_length = SDL_ReadLE32(src);
442
443 if (chunk_length == 0)
444 break;
445
446 switch (chunk_type)
447 {
448 case FMT:
449 found_FMT = SDL_TRUE;
450 if (!ParseFMT(wave, chunk_length))
451 return SDL_FALSE;
452 break;
453 case DATA:
454 found_DATA = SDL_TRUE;
455 if (!ParseDATA(wave, chunk_length))
456 return SDL_FALSE;
457 break;
458 case SMPL:
459 if (!ParseSMPL(wave, chunk_length))
460 return SDL_FALSE;
461 break;
462 default:
463 SDL_RWseek(src, chunk_length, RW_SEEK_CUR);
464 break;
465 }
466 }
467
468 if (!found_FMT) {
469 Mix_SetError("Bad WAV file (no FMT chunk)");
470 return SDL_FALSE;
471 }
472
473 if (!found_DATA) {
474 Mix_SetError("Bad WAV file (no DATA chunk)");
475 return SDL_FALSE;
476 }
477
478 return SDL_TRUE;
479 }
480
481 /* I couldn't get SANE_to_double() to work, so I stole this from libsndfile.
482 * I don't pretend to fully understand it.
483 */
484
485 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
486 {
487 /* Negative number? */
488 if (sanebuf[0] & 0x80)
489 return 0;
490
491 /* Less than 1? */
492 if (sanebuf[0] <= 0x3F)
493 return 1;
494
495 /* Way too big? */
496 if (sanebuf[0] > 0x40)
497 return 0x4000000;
498
499 /* Still too big? */
500 if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)
501 return 800000000;
502
503 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) |
504 (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
505 }
506
507 static SDL_bool LoadAIFFMusic(WAV_Music *wave)
508 {
509 SDL_RWops *src = wave->src;
510 SDL_AudioSpec *spec = &wave->spec;
511 SDL_bool found_SSND = SDL_FALSE;
512 SDL_bool found_COMM = SDL_FALSE;
513
514 Uint32 chunk_type;
515 Uint32 chunk_length;
516 Sint64 next_chunk;
517
518 /* AIFF magic header */
519 Uint32 AIFFmagic;
520 /* SSND chunk */
521 Uint32 offset;
522 Uint32 blocksize;
523 /* COMM format chunk */
524 Uint16 channels = 0;
525 Uint32 numsamples = 0;
526 Uint16 samplesize = 0;
527 Uint8 sane_freq[10];
528 Uint32 frequency = 0;
529
530 /* Check the magic header */
531 chunk_length = SDL_ReadBE32(src);
532 AIFFmagic = SDL_ReadLE32(src);
533 if (AIFFmagic != AIFF) {
534 Mix_SetError("Unrecognized file type (not AIFF)");
535 return SDL_FALSE;
536 }
537
538 /* From what I understand of the specification, chunks may appear in
539 * any order, and we should just ignore unknown ones.
540 *
541 * TODO: Better sanity-checking. E.g. what happens if the AIFF file
542 * contains compressed sound data?
543 */
544 do {
545 chunk_type = SDL_ReadLE32(src);
546 chunk_length = SDL_ReadBE32(src);
547 next_chunk = SDL_RWtell(src) + chunk_length;
548
549 /* Paranoia to avoid infinite loops */
550 if (chunk_length == 0)
551 break;
552
553 switch (chunk_type) {
554 case SSND:
555 found_SSND = SDL_TRUE;
556 offset = SDL_ReadBE32(src);
557 blocksize = SDL_ReadBE32(src);
558 wave->start = SDL_RWtell(src) + offset;
559 break;
560
561 case COMM:
562 found_COMM = SDL_TRUE;
563
564 /* Read the audio data format chunk */
565 channels = SDL_ReadBE16(src);
566 numsamples = SDL_ReadBE32(src);
567 samplesize = SDL_ReadBE16(src);
568 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
569 frequency = SANE_to_Uint32(sane_freq);
570 break;
571
572 default:
573 break;
574 }
575 } while ((!found_SSND || !found_COMM)
576 && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1);
577
578 if (!found_SSND) {
579 Mix_SetError("Bad AIFF file (no SSND chunk)");
580 return SDL_FALSE;
581 }
582
583 if (!found_COMM) {
584 Mix_SetError("Bad AIFF file (no COMM chunk)");
585 return SDL_FALSE;
586 }
587
588 wave->stop = wave->start + channels * numsamples * (samplesize / 8);
589
590 /* Decode the audio data format */
591 SDL_memset(spec, 0, (sizeof *spec));
592 spec->freq = frequency;
593 switch (samplesize) {
594 case 8:
595 spec->format = AUDIO_S8;
596 break;
597 case 16:
598 spec->format = AUDIO_S16MSB;
599 break;
600 default:
601 Mix_SetError("Unknown samplesize in data format");
602 return SDL_FALSE;
603 }
604 spec->channels = (Uint8) channels;
605 spec->samples = 4096; /* Good default buffer size */
606
607 return SDL_TRUE;
608 }
609
610 Mix_MusicInterface Mix_MusicInterface_WAV =
611 {
612 "WAVE",
613 MIX_MUSIC_WAVE,
614 MUS_WAV,
615 SDL_FALSE,
616 SDL_FALSE,
617
618 NULL, /* Load */
619 NULL, /* Open */
620 WAV_CreateFromRW,
621 NULL, /* CreateFromFile */
622 WAV_SetVolume,
623 WAV_Play,
624 NULL, /* IsPlaying */
625 WAV_GetAudio,
626 NULL, /* Seek */
627 NULL, /* Pause */
628 NULL, /* Resume */
629 NULL, /* Stop */
630 WAV_Delete,
631 NULL, /* Close */
632 NULL, /* Unload */
633 };
634
635 #endif /* MUSIC_WAV */
636
637 /* vi: set ts=4 sw=4 expandtab: */
+0
-28
music_wav.h less more
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports streaming WAV files */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_WAV;
26
27 /* vi: set ts=4 sw=4 expandtab: */
+0
-40
native_midi/native_midi.h less more
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef _NATIVE_MIDI_H_
22 #define _NATIVE_MIDI_H_
23
24 #include "SDL_rwops.h"
25
26 typedef struct _NativeMidiSong NativeMidiSong;
27
28 int native_midi_detect(void);
29 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc);
30 void native_midi_freesong(NativeMidiSong *song);
31 void native_midi_start(NativeMidiSong *song, int loops);
32 void native_midi_pause(void);
33 void native_midi_resume(void);
34 void native_midi_stop(void);
35 int native_midi_active(void);
36 void native_midi_setvolume(int volume);
37 const char *native_midi_error(void);
38
39 #endif /* _NATIVE_MIDI_H_ */
+0
-414
native_midi/native_midi_common.c less more
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21
22 #include "native_midi_common.h"
23
24 #include "../SDL_mixer.h"
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <limits.h>
29
30 /* The constant 'MThd' */
31 #define MIDI_MAGIC 0x4d546864
32
33 /* A single midi track as read from the midi file */
34 typedef struct
35 {
36 Uint8 *data; /* MIDI message stream */
37 int len; /* length of the track data */
38 } MIDITrack;
39
40 /* A midi file, stripped down to the absolute minimum - divison & track data */
41 typedef struct
42 {
43 int division; /* number of pulses per quarter note (ppqn) */
44 int nTracks; /* number of tracks */
45 MIDITrack *track; /* tracks */
46 } MIDIFile;
47
48
49 /* Some macros that help us stay endianess-independant */
50 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
51 #define BE_SHORT(x) (x)
52 #define BE_LONG(x) (x)
53 #else
54 #define BE_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
55 #define BE_LONG(x) ((((x)&0x0000FF)<<24) | \
56 (((x)&0x00FF00)<<8) | \
57 (((x)&0xFF0000)>>8) | \
58 (((x)>>24)&0xFF))
59 #endif
60
61
62
63 /* Get Variable Length Quantity */
64 static int GetVLQ(MIDITrack *track, int *currentPos)
65 {
66 int l = 0;
67 Uint8 c;
68 while(1)
69 {
70 c = track->data[*currentPos];
71 (*currentPos)++;
72 l += (c & 0x7f);
73 if (!(c & 0x80))
74 return l;
75 l <<= 7;
76 }
77 }
78
79 /* Create a single MIDIEvent */
80 static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b)
81 {
82 MIDIEvent *newEvent;
83
84 newEvent = calloc(1, sizeof(MIDIEvent));
85
86 if (newEvent)
87 {
88 newEvent->time = time;
89 newEvent->status = event;
90 newEvent->data[0] = a;
91 newEvent->data[1] = b;
92 }
93 else
94 Mix_SetError("Out of memory");
95
96 return newEvent;
97 }
98
99 /* Convert a single midi track to a list of MIDIEvents */
100 static MIDIEvent *MIDITracktoStream(MIDITrack *track)
101 {
102 Uint32 atime = 0;
103 Uint32 len = 0;
104 Uint8 event,type,a,b;
105 Uint8 laststatus = 0;
106 Uint8 lastchan = 0;
107 int currentPos = 0;
108 int end = 0;
109 MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
110 MIDIEvent *currentEvent = head;
111
112 while (!end)
113 {
114 if (currentPos >= track->len)
115 break; /* End of data stream reached */
116
117 atime += GetVLQ(track, &currentPos);
118 event = track->data[currentPos++];
119
120 /* Handle SysEx seperatly */
121 if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX)
122 {
123 if (event == 0xFF)
124 {
125 type = track->data[currentPos];
126 currentPos++;
127 switch(type)
128 {
129 case 0x2f: /* End of data marker */
130 end = 1;
131 case 0x51: /* Tempo change */
132 /*
133 a=track->data[currentPos];
134 b=track->data[currentPos+1];
135 c=track->data[currentPos+2];
136 AddEvent(song, atime, MEVT_TEMPO, c, b, a);
137 */
138 break;
139 }
140 }
141 else
142 type = 0;
143
144 len = GetVLQ(track, &currentPos);
145
146 /* Create an event and attach the extra data, if any */
147 currentEvent->next = CreateEvent(atime, event, type, 0);
148 currentEvent = currentEvent->next;
149 if (NULL == currentEvent)
150 {
151 FreeMIDIEventList(head);
152 return NULL;
153 }
154 if (len)
155 {
156 currentEvent->extraLen = len;
157 currentEvent->extraData = malloc(len);
158 memcpy(currentEvent->extraData, &(track->data[currentPos]), len);
159 currentPos += len;
160 }
161 }
162 else
163 {
164 a = event;
165 if (a & 0x80) /* It's a status byte */
166 {
167 /* Extract channel and status information */
168 lastchan = a & 0x0F;
169 laststatus = (a>>4) & 0x0F;
170
171 /* Read the next byte which should always be a data byte */
172 a = track->data[currentPos++] & 0x7F;
173 }
174 switch(laststatus)
175 {
176 case MIDI_STATUS_NOTE_OFF:
177 case MIDI_STATUS_NOTE_ON: /* Note on */
178 case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */
179 case MIDI_STATUS_CONTROLLER: /* Control change */
180 case MIDI_STATUS_PITCH_WHEEL: /* Pitch wheel */
181 b = track->data[currentPos++] & 0x7F;
182 currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b);
183 currentEvent = currentEvent->next;
184 if (NULL == currentEvent)
185 {
186 FreeMIDIEventList(head);
187 return NULL;
188 }
189 break;
190
191 case MIDI_STATUS_PROG_CHANGE: /* Program change */
192 case MIDI_STATUS_PRESSURE: /* Channel pressure */
193 a &= 0x7f;
194 currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0);
195 currentEvent = currentEvent->next;
196 if (NULL == currentEvent)
197 {
198 FreeMIDIEventList(head);
199 return NULL;
200 }
201 break;
202
203 default: /* Sysex already handled above */
204 break;
205 }
206 }
207 }
208
209 currentEvent = head->next;
210 free(head); /* release the dummy head event */
211 return currentEvent;
212 }
213
214 /*
215 * Convert a midi song, consisting of up to 32 tracks, to a list of MIDIEvents.
216 * To do so, first convert the tracks seperatly, then interweave the resulting
217 * MIDIEvent-Lists to one big list.
218 */
219 static MIDIEvent *MIDItoStream(MIDIFile *mididata)
220 {
221 MIDIEvent **track;
222 MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
223 MIDIEvent *currentEvent = head;
224 int trackID;
225
226 if (NULL == head)
227 return NULL;
228
229 track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
230 if (NULL == track)
231 {
232 free(head);
233 return NULL;
234 }
235
236 /* First, convert all tracks to MIDIEvent lists */
237 for (trackID = 0; trackID < mididata->nTracks; trackID++)
238 track[trackID] = MIDITracktoStream(&mididata->track[trackID]);
239
240 /* Now, merge the lists. */
241 /* TODO */
242 while(1)
243 {
244 Uint32 lowestTime = INT_MAX;
245 int currentTrackID = -1;
246
247 /* Find the next event */
248 for (trackID = 0; trackID < mididata->nTracks; trackID++)
249 {
250 if (track[trackID] && (track[trackID]->time < lowestTime))
251 {
252 currentTrackID = trackID;
253 lowestTime = track[currentTrackID]->time;
254 }
255 }
256
257 /* Check if we processes all events */
258 if (currentTrackID == -1)
259 break;
260
261 currentEvent->next = track[currentTrackID];
262 track[currentTrackID] = track[currentTrackID]->next;
263
264 currentEvent = currentEvent->next;
265
266
267 lowestTime = 0;
268 }
269
270 /* Make sure the list is properly terminated */
271 currentEvent->next = 0;
272
273 currentEvent = head->next;
274 free(track);
275 free(head); /* release the dummy head event */
276 return currentEvent;
277 }
278
279 static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
280 {
281 int i = 0;
282 Uint32 ID;
283 Uint32 size;
284 Uint16 format;
285 Uint16 tracks;
286 Uint16 division;
287
288 if (!mididata)
289 return 0;
290 if (!src)
291 return 0;
292
293 /* Make sure this is really a MIDI file */
294 SDL_RWread(src, &ID, 1, 4);
295 if (BE_LONG(ID) != MIDI_MAGIC)
296 return 0;
297
298 /* Header size must be 6 */
299 SDL_RWread(src, &size, 1, 4);
300 size = BE_LONG(size);
301 if (size != 6)
302 return 0;
303
304 /* We only support format 0 and 1, but not 2 */
305 SDL_RWread(src, &format, 1, 2);
306 format = BE_SHORT(format);
307 if (format != 0 && format != 1)
308 return 0;
309
310 SDL_RWread(src, &tracks, 1, 2);
311 tracks = BE_SHORT(tracks);
312 mididata->nTracks = tracks;
313
314 /* Allocate tracks */
315 mididata->track = (MIDITrack*) calloc(1, sizeof(MIDITrack) * mididata->nTracks);
316 if (NULL == mididata->track)
317 {
318 Mix_SetError("Out of memory");
319 goto bail;
320 }
321
322 /* Retrieve the PPQN value, needed for playback */
323 SDL_RWread(src, &division, 1, 2);
324 mididata->division = BE_SHORT(division);
325
326
327 for (i=0; i<tracks; i++)
328 {
329 SDL_RWread(src, &ID, 1, 4); /* We might want to verify this is MTrk... */
330 SDL_RWread(src, &size, 1, 4);
331 size = BE_LONG(size);
332 mididata->track[i].len = size;
333 mididata->track[i].data = malloc(size);
334 if (NULL == mididata->track[i].data)
335 {
336 Mix_SetError("Out of memory");
337 goto bail;
338 }
339 SDL_RWread(src, mididata->track[i].data, 1, size);
340 }
341 return 1;
342
343 bail:
344 for(;i >= 0; i--)
345 {
346 if (mididata->track[i].data)
347 free(mididata->track[i].data);
348 }
349
350 return 0;
351 }
352
353 MIDIEvent *CreateMIDIEventList(SDL_RWops *src, Uint16 *division)
354 {
355 MIDIFile *mididata = NULL;
356 MIDIEvent *eventList;
357 int trackID;
358
359 mididata = calloc(1, sizeof(MIDIFile));
360 if (!mididata)
361 return NULL;
362
363 /* Open the file */
364 if ( src != NULL )
365 {
366 /* Read in the data */
367 if ( ! ReadMIDIFile(mididata, src))
368 {
369 free(mididata);
370 return NULL;
371 }
372 }
373 else
374 {
375 free(mididata);
376 return NULL;
377 }
378
379 if (division)
380 *division = mididata->division;
381
382 eventList = MIDItoStream(mididata);
383 if (eventList == NULL)
384 {
385 free(mididata);
386 return NULL;
387 }
388 for(trackID = 0; trackID < mididata->nTracks; trackID++)
389 {
390 if (mididata->track[trackID].data)
391 free(mididata->track[trackID].data);
392 }
393 free(mididata->track);
394 free(mididata);
395
396 return eventList;
397 }
398
399 void FreeMIDIEventList(MIDIEvent *head)
400 {
401 MIDIEvent *cur, *next;
402
403 cur = head;
404
405 while (cur)
406 {
407 next = cur->next;
408 if (cur->extraData)
409 free (cur->extraData);
410 free (cur);
411 cur = next;
412 }
413 }
+0
-63
native_midi/native_midi_common.h less more
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef _NATIVE_MIDI_COMMON_H_
22 #define _NATIVE_MIDI_COMMON_H_
23
24 #include "SDL.h"
25
26 /* Midi Status Bytes */
27 #define MIDI_STATUS_NOTE_OFF 0x8
28 #define MIDI_STATUS_NOTE_ON 0x9
29 #define MIDI_STATUS_AFTERTOUCH 0xA
30 #define MIDI_STATUS_CONTROLLER 0xB
31 #define MIDI_STATUS_PROG_CHANGE 0xC
32 #define MIDI_STATUS_PRESSURE 0xD
33 #define MIDI_STATUS_PITCH_WHEEL 0xE
34 #define MIDI_STATUS_SYSEX 0xF
35
36 /* We store the midi events in a linked list; this way it is
37 easy to shuffle the tracks together later on; and we are
38 flexible in the size of each elemnt.
39 */
40 typedef struct MIDIEvent
41 {
42 Uint32 time; /* Time at which this midi events occurs */
43 Uint8 status; /* Status byte */
44 Uint8 data[2]; /* 1 or 2 bytes additional data for most events */
45
46 Uint32 extraLen; /* For some SysEx events, we need additional storage */
47 Uint8 *extraData;
48
49 struct MIDIEvent *next;
50 } MIDIEvent;
51
52
53 /* Load a midifile to memory, converting it to a list of MIDIEvents.
54 This function returns a linked lists of MIDIEvents, 0 if an error occured.
55 */
56 MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division);
57
58 /* Release a MIDIEvent list after usage. */
59 void FreeMIDIEventList(MIDIEvent *head);
60
61
62 #endif /* _NATIVE_MIDI_COMMON_H_ */
+0
-295
native_midi/native_midi_haiku.cpp less more
0 /*
1 native_midi_haiku: Native Midi support on Haiku for the SDL_mixer library
2 Copyright (C) 2010 Egor Suvorov <egor_suvorov@mail.ru>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 #ifdef __HAIKU__
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <MidiStore.h>
27 #include <MidiDefs.h>
28 #include <MidiSynthFile.h>
29 #include <algorithm>
30 #include <assert.h>
31 extern "C" {
32 #include "native_midi.h"
33 #include "native_midi_common.h"
34 }
35
36 bool compareMIDIEvent(const MIDIEvent &a, const MIDIEvent &b)
37 {
38 return a.time < b.time;
39 }
40
41 class MidiEventsStore : public BMidi
42 {
43 public:
44 MidiEventsStore()
45 {
46 fPlaying = false;
47 fLoops = 0;
48 }
49 virtual status_t Import(SDL_RWops *src)
50 {
51 fEvs = CreateMIDIEventList(src, &fDivision);
52 if (!fEvs) {
53 return B_BAD_MIDI_DATA;
54 }
55 fTotal = 0;
56 for (MIDIEvent *x = fEvs; x; x = x->next) fTotal++;
57 fPos = fTotal;
58
59 sort_events();
60 return B_OK;
61 }
62 virtual void Run()
63 {
64 fPlaying = true;
65 fPos = 0;
66 MIDIEvent *ev = fEvs;
67
68 uint32 startTime = B_NOW;
69 while (KeepRunning())
70 {
71 if (!ev) {
72 if (fLoops && fEvs) {
73 if (fLoops > 0) --fLoops;
74 fPos = 0;
75 ev = fEvs;
76 } else
77 break;
78 }
79 SprayEvent(ev, ev->time + startTime);
80 ev = ev->next;
81 fPos++;
82 }
83 fPos = fTotal;
84 fPlaying = false;
85 }
86 virtual ~MidiEventsStore()
87 {
88 if (!fEvs) return;
89 FreeMIDIEventList(fEvs);
90 fEvs = 0;
91 }
92
93 bool IsPlaying()
94 {
95 return fPlaying;
96 }
97
98 void SetLoops(int loops)
99 {
100 fLoops = loops;
101 }
102
103 protected:
104 MIDIEvent *fEvs;
105 Uint16 fDivision;
106
107 int fPos, fTotal;
108 int fLoops;
109 bool fPlaying;
110
111 void SprayEvent(MIDIEvent *ev, uint32 time)
112 {
113 switch (ev->status & 0xF0)
114 {
115 case B_NOTE_OFF:
116 SprayNoteOff((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
117 break;
118 case B_NOTE_ON:
119 SprayNoteOn((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
120 break;
121 case B_KEY_PRESSURE:
122 SprayKeyPressure((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
123 break;
124 case B_CONTROL_CHANGE:
125 SprayControlChange((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
126 break;
127 case B_PROGRAM_CHANGE:
128 SprayProgramChange((ev->status & 0x0F) + 1, ev->data[0], time);
129 break;
130 case B_CHANNEL_PRESSURE:
131 SprayChannelPressure((ev->status & 0x0F) + 1, ev->data[0], time);
132 break;
133 case B_PITCH_BEND:
134 SprayPitchBend((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
135 break;
136 case 0xF:
137 switch (ev->status)
138 {
139 case B_SYS_EX_START:
140 SpraySystemExclusive(ev->extraData, ev->extraLen, time);
141 break;
142 case B_MIDI_TIME_CODE:
143 case B_SONG_POSITION:
144 case B_SONG_SELECT:
145 case B_CABLE_MESSAGE:
146 case B_TUNE_REQUEST:
147 case B_SYS_EX_END:
148 SpraySystemCommon(ev->status, ev->data[0], ev->data[1], time);
149 break;
150 case B_TIMING_CLOCK:
151 case B_START:
152 case B_STOP:
153 case B_CONTINUE:
154 case B_ACTIVE_SENSING:
155 SpraySystemRealTime(ev->status, time);
156 break;
157 case B_SYSTEM_RESET:
158 if (ev->data[0] == 0x51 && ev->data[1] == 0x03)
159 {
160 assert(ev->extraLen == 3);
161 int val = (ev->extraData[0] << 16) | (ev->extraData[1] << 8) | ev->extraData[2];
162 int tempo = 60000000 / val;
163 SprayTempoChange(tempo, time);
164 }
165 else
166 {
167 SpraySystemRealTime(ev->status, time);
168 }
169 }
170 break;
171 }
172 }
173
174 void sort_events()
175 {
176 MIDIEvent *items = new MIDIEvent[fTotal];
177 MIDIEvent *x = fEvs;
178 for (int i = 0; i < fTotal; i++)
179 {
180 memcpy(items + i, x, sizeof(MIDIEvent));
181 x = x->next;
182 }
183 std::sort(items, items + fTotal, compareMIDIEvent);
184
185 x = fEvs;
186 for (int i = 0; i < fTotal; i++)
187 {
188 MIDIEvent *ne = x->next;
189 memcpy(x, items + i, sizeof(MIDIEvent));
190 x->next = ne;
191 x = ne;
192 }
193
194 for (x = fEvs; x && x->next; x = x->next)
195 assert(x->time <= x->next->time);
196
197 delete[] items;
198 }
199 };
200
201 BMidiSynth synth;
202 struct _NativeMidiSong {
203 MidiEventsStore *store;
204 } *currentSong = NULL;
205
206 char lasterr[1024];
207
208 int native_midi_detect(void)
209 {
210 status_t res = synth.EnableInput(true, false);
211 return res == B_OK;
212 }
213
214 void native_midi_setvolume(int volume)
215 {
216 if (volume < 0) volume = 0;
217 if (volume > 128) volume = 128;
218 synth.SetVolume(volume / 128.0);
219 }
220
221 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
222 {
223 NativeMidiSong *song = new NativeMidiSong;
224 song->store = new MidiEventsStore;
225 status_t res = song->store->Import(src);
226
227 if (res != B_OK)
228 {
229 snprintf(lasterr, sizeof lasterr, "Cannot Import() midi file: status_t=%d", res);
230 delete song->store;
231 delete song;
232 return NULL;
233 }
234 else
235 {
236 if (freesrc) {
237 SDL_RWclose(src);
238 }
239 }
240 return song;
241 }
242
243 void native_midi_freesong(NativeMidiSong *song)
244 {
245 if (song == NULL) return;
246 song->store->Stop();
247 song->store->Disconnect(&synth);
248 if (currentSong == song)
249 {
250 currentSong = NULL;
251 }
252 delete song->store;
253 delete song; song = 0;
254 }
255
256 void native_midi_start(NativeMidiSong *song, int loops)
257 {
258 native_midi_stop();
259 song->store->Connect(&synth);
260 song->store->SetLoops(loops);
261 song->store->Start();
262 currentSong = song;
263 }
264
265 void native_midi_pause(void)
266 {
267 }
268
269 void native_midi_resume(void)
270 {
271 }
272
273 void native_midi_stop(void)
274 {
275 if (currentSong == NULL) return;
276 currentSong->store->Stop();
277 currentSong->store->Disconnect(&synth);
278 while (currentSong->store->IsPlaying())
279 usleep(1000);
280 currentSong = NULL;
281 }
282
283 int native_midi_active(void)
284 {
285 if (currentSong == NULL) return 0;
286 return currentSong->store->IsPlaying();
287 }
288
289 const char* native_midi_error(void)
290 {
291 return lasterr;
292 }
293
294 #endif /* __HAIKU__ */
+0
-649
native_midi/native_midi_mac.c less more
0 /*
1 native_midi_mac: Native Midi support on MacOS for the SDL_mixer library
2 Copyright (C) 2001 Max Horn <max@quendi.de>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21 #include "SDL_endian.h"
22 #include "../mixer.h"
23
24 #if __MACOS__ /*|| __MACOSX__ */
25
26 #include "native_midi.h"
27 #include "native_midi_common.h"
28
29 #if __MACOSX__
30 #include <QuickTime/QuickTimeMusic.h>
31 #else
32 #include <QuickTimeMusic.h>
33 #endif
34
35 #include <assert.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39
40 /* Native Midi song */
41 struct _NativeMidiSong
42 {
43 Uint32 *tuneSequence;
44 Uint32 *tuneHeader;
45 };
46
47 enum
48 {
49 /* number of (32-bit) long words in a note request event */
50 kNoteRequestEventLength = ((sizeof(NoteRequest)/sizeof(long)) + 2),
51
52 /* number of (32-bit) long words in a marker event */
53 kMarkerEventLength = 1,
54
55 /* number of (32-bit) long words in a general event, minus its data */
56 kGeneralEventLength = 2
57 };
58
59 #define ERROR_BUF_SIZE 256
60 #define BUFFER_INCREMENT 5000
61
62 #define REST_IF_NECESSARY() do {\
63 int timeDiff = eventPos->time - lastEventTime; \
64 if(timeDiff) \
65 { \
66 timeDiff = (int)(timeDiff*tick); \
67 qtma_StuffRestEvent(*tunePos, timeDiff); \
68 tunePos++; \
69 lastEventTime = eventPos->time; \
70 } \
71 } while(0)
72
73
74 static Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts);
75 static Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts);
76
77 /* The global TunePlayer instance */
78 static TunePlayer gTunePlayer = NULL;
79 static int gInstaceCount = 0;
80 static Uint32 *gCurrentTuneSequence = NULL;
81 static char gErrorBuffer[ERROR_BUF_SIZE] = "";
82
83
84 /* Check whether QuickTime is available */
85 int native_midi_detect(void)
86 {
87 /* TODO */
88 return 1;
89 }
90
91 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
92 {
93 NativeMidiSong *song = NULL;
94 MIDIEvent *evntlist = NULL;
95 int part_to_inst[32];
96 int part_poly_max[32];
97 int numParts = 0;
98 Uint16 ppqn;
99
100 /* Init the arrays */
101 memset(part_poly_max,0,sizeof(part_poly_max));
102 memset(part_to_inst,-1,sizeof(part_to_inst));
103
104 /* Attempt to load the midi file */
105 evntlist = CreateMIDIEventList(src, &ppqn);
106 if (!evntlist)
107 goto bail;
108
109 /* Allocate memory for the song struct */
110 song = malloc(sizeof(NativeMidiSong));
111 if (!song)
112 goto bail;
113
114 /* Build a tune sequence from the event list */
115 song->tuneSequence = BuildTuneSequence(evntlist, ppqn, part_poly_max, part_to_inst, &numParts);
116 if(!song->tuneSequence)
117 goto bail;
118
119 /* Now build a tune header from the data we collect above, create
120 all parts as needed and assign them the correct instrument.
121 */
122 song->tuneHeader = BuildTuneHeader(part_poly_max, part_to_inst, numParts);
123 if(!song->tuneHeader)
124 goto bail;
125
126 /* Increment the instance count */
127 gInstaceCount++;
128 if (gTunePlayer == NULL)
129 gTunePlayer = OpenDefaultComponent(kTunePlayerComponentType, 0);
130
131 /* Finally, free the event list */
132 FreeMIDIEventList(evntlist);
133
134 if (freerw) {
135 SDL_RWclose(rw);
136 }
137 return song;
138
139 bail:
140 if (evntlist)
141 FreeMIDIEventList(evntlist);
142
143 if (song)
144 {
145 if(song->tuneSequence)
146 free(song->tuneSequence);
147
148 if(song->tuneHeader)
149 DisposePtr((Ptr)song->tuneHeader);
150
151 free(song);
152 }
153 return NULL;
154 }
155
156 void native_midi_freesong(NativeMidiSong *song)
157 {
158 if(!song || !song->tuneSequence)
159 return;
160
161 /* If this is the currently playing song, stop it now */
162 if (song->tuneSequence == gCurrentTuneSequence)
163 native_midi_stop();
164
165 /* Finally, free the data storage */
166 free(song->tuneSequence);
167 DisposePtr((Ptr)song->tuneHeader);
168 free(song);
169
170 /* Increment the instance count */
171 gInstaceCount--;
172 if ((gTunePlayer != NULL) && (gInstaceCount == 0))
173 {
174 CloseComponent(gTunePlayer);
175 gTunePlayer = NULL;
176 }
177 }
178
179 void native_midi_start(NativeMidiSong *song, int loops)
180 {
181 UInt32 queueFlags = 0;
182 ComponentResult tpError;
183
184 assert (gTunePlayer != NULL);
185
186 /* FIXME: is this code even used anymore? */
187 assert (loops == 0);
188
189 SDL_PauseAudio(1);
190 Mix_UnlockAudio();
191
192 /* First, stop the currently playing music */
193 native_midi_stop();
194
195 /* Set up the queue flags */
196 queueFlags = kTuneStartNow;
197
198 /* Set the time scale (units per second), we want milliseconds */
199 tpError = TuneSetTimeScale(gTunePlayer, 1000);
200 if (tpError != noErr)
201 {
202 strncpy (gErrorBuffer, "MIDI error during TuneSetTimeScale", ERROR_BUF_SIZE);
203 goto done;
204 }
205
206 /* Set the header, to tell what instruments are used */
207 tpError = TuneSetHeader(gTunePlayer, (UInt32 *)song->tuneHeader);
208 if (tpError != noErr)
209 {
210 strncpy (gErrorBuffer, "MIDI error during TuneSetHeader", ERROR_BUF_SIZE);
211 goto done;
212 }
213
214 /* Have it allocate whatever resources are needed */
215 tpError = TunePreroll(gTunePlayer);
216 if (tpError != noErr)
217 {
218 strncpy (gErrorBuffer, "MIDI error during TunePreroll", ERROR_BUF_SIZE);
219 goto done;
220 }
221
222 /* We want to play at normal volume */
223 tpError = TuneSetVolume(gTunePlayer, 0x00010000);
224 if (tpError != noErr)
225 {
226 strncpy (gErrorBuffer, "MIDI error during TuneSetVolume", ERROR_BUF_SIZE);
227 goto done;
228 }
229
230 /* Finally, start playing the full song */
231 gCurrentTuneSequence = song->tuneSequence;
232 tpError = TuneQueue(gTunePlayer, (UInt32 *)song->tuneSequence, 0x00010000, 0, 0xFFFFFFFF, queueFlags, NULL, 0);
233 if (tpError != noErr)
234 {
235 strncpy (gErrorBuffer, "MIDI error during TuneQueue", ERROR_BUF_SIZE);
236 goto done;
237 }
238
239 done:
240 Mix_LockAudio();
241 SDL_PauseAudio(0);
242 }
243
244 void native_midi_pause(void)
245 {
246 }
247
248 void native_midi_resume(void)
249 {
250 }
251
252 void native_midi_stop(void)
253 {
254 if (gTunePlayer == NULL)
255 return;
256
257 /* Stop music */
258 TuneStop(gTunePlayer, 0);
259
260 /* Deallocate all instruments */
261 TuneUnroll(gTunePlayer);
262 }
263
264 int native_midi_active(void)
265 {
266 if (gTunePlayer != NULL)
267 {
268 TuneStatus ts;
269
270 TuneGetStatus(gTunePlayer,&ts);
271 return ts.queueTime != 0;
272 }
273 else
274 return 0;
275 }
276
277 void native_midi_setvolume(int volume)
278 {
279 if (gTunePlayer == NULL)
280 return;
281
282 /* QTMA olume may range from 0.0 to 1.0 (in 16.16 fixed point encoding) */
283 TuneSetVolume(gTunePlayer, (0x00010000 * volume)/SDL_MIX_MAXVOLUME);
284 }
285
286 const char *native_midi_error(void)
287 {
288 return gErrorBuffer;
289 }
290
291 Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts)
292 {
293 int part_poly[32];
294 int channel_to_part[16];
295
296 int channel_pan[16];
297 int channel_vol[16];
298 int channel_pitch_bend[16];
299
300 int lastEventTime = 0;
301 int tempo = 500000;
302 double Ippqn = 1.0 / (1000*ppqn);
303 double tick = tempo * Ippqn;
304 MIDIEvent *eventPos = evntlist;
305 MIDIEvent *noteOffPos;
306 Uint32 *tunePos, *endPos;
307 Uint32 *tuneSequence;
308 size_t tuneSize;
309
310 /* allocate space for the tune header */
311 tuneSize = 5000;
312 tuneSequence = (Uint32 *)malloc(tuneSize * sizeof(Uint32));
313 if (tuneSequence == NULL)
314 return NULL;
315
316 /* Set starting position in our tune memory */
317 tunePos = tuneSequence;
318 endPos = tuneSequence + tuneSize;
319
320 /* Initialise the arrays */
321 memset(part_poly,0,sizeof(part_poly));
322
323 memset(channel_to_part,-1,sizeof(channel_to_part));
324 memset(channel_pan,-1,sizeof(channel_pan));
325 memset(channel_vol,-1,sizeof(channel_vol));
326 memset(channel_pitch_bend,-1,sizeof(channel_pitch_bend));
327
328 *numParts = 0;
329
330 /*
331 * Now the major work - iterate over all GM events,
332 * and turn them into QuickTime Music format.
333 * At the same time, calculate the max. polyphony for each part,
334 * and also the part->instrument mapping.
335 */
336 while(eventPos)
337 {
338 int status = (eventPos->status&0xF0)>>4;
339 int channel = eventPos->status&0x0F;
340 int part = channel_to_part[channel];
341 int velocity, pitch;
342 int value, controller;
343 int bend;
344 int newInst;
345
346 /* Check if we are running low on space... */
347 if((tunePos+16) > endPos)
348 {
349 /* Resize our data storage. */
350 Uint32 *oldTuneSequence = tuneSequence;
351
352 tuneSize += BUFFER_INCREMENT;
353 tuneSequence = (Uint32 *)realloc(tuneSequence, tuneSize * sizeof(Uint32));
354 if(oldTuneSequence != tuneSequence)
355 tunePos += tuneSequence - oldTuneSequence;
356 endPos = tuneSequence + tuneSize;
357 }
358
359 switch (status)
360 {
361 case MIDI_STATUS_NOTE_OFF:
362 assert(part>=0 && part<=31);
363
364 /* Keep track of the polyphony of the current part */
365 part_poly[part]--;
366 break;
367 case MIDI_STATUS_NOTE_ON:
368 if (part < 0)
369 {
370 /* If no part is specified yet, we default to the first instrument, which
371 is piano (or the first drum kit if we are on the drum channel)
372 */
373 int newInst;
374
375 if (channel == 9)
376 newInst = kFirstDrumkit + 1; /* the first drum kit is the "no drum" kit! */
377 else
378 newInst = kFirstGMInstrument;
379 part = channel_to_part[channel] = *numParts;
380 part_to_inst[(*numParts)++] = newInst;
381 }
382 /* TODO - add support for more than 32 parts using eXtended QTMA events */
383 assert(part<=31);
384
385 /* Decode pitch & velocity */
386 pitch = eventPos->data[0];
387 velocity = eventPos->data[1];
388
389 if (velocity == 0)
390 {
391 /* was a NOTE OFF in disguise, so we decrement the polyphony */
392 part_poly[part]--;
393 }
394 else
395 {
396 /* Keep track of the polyphony of the current part */
397 int foo = ++part_poly[part];
398 if (part_poly_max[part] < foo)
399 part_poly_max[part] = foo;
400
401 /* Now scan forward to find the matching NOTE OFF event */
402 for(noteOffPos = eventPos; noteOffPos; noteOffPos = noteOffPos->next)
403 {
404 if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_OFF
405 && channel == (eventPos->status&0x0F)
406 && pitch == noteOffPos->data[0])
407 break;
408 /* NOTE ON with velocity == 0 is the same as a NOTE OFF */
409 if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_ON
410 && channel == (eventPos->status&0x0F)
411 && pitch == noteOffPos->data[0]
412 && 0 == noteOffPos->data[1])
413 break;
414 }
415
416 /* Did we find a note off? Should always be the case, but who knows... */
417 if (noteOffPos)
418 {
419 /* We found a NOTE OFF, now calculate the note duration */
420 int duration = (int)((noteOffPos->time - eventPos->time)*tick);
421
422 REST_IF_NECESSARY();
423 /* Now we need to check if we get along with a normal Note Event, or if we need an extended one... */
424 if (duration < 2048 && pitch>=32 && pitch<=95 && velocity>=0 && velocity<=127)
425 {
426 qtma_StuffNoteEvent(*tunePos, part, pitch, velocity, duration);
427 tunePos++;
428 }
429 else
430 {
431 qtma_StuffXNoteEvent(*tunePos, *(tunePos+1), part, pitch, velocity, duration);
432 tunePos+=2;
433 }
434 }
435 }
436 break;
437 case MIDI_STATUS_AFTERTOUCH:
438 /* NYI - use kControllerAfterTouch. But how are the parameters to be mapped? */
439 break;
440 case MIDI_STATUS_CONTROLLER:
441 controller = eventPos->data[0];
442 value = eventPos->data[1];
443
444 switch(controller)
445 {
446 case 0: /* bank change - igore for now */
447 break;
448 case kControllerVolume:
449 if(channel_vol[channel] != value<<8)
450 {
451 channel_vol[channel] = value<<8;
452 if(part>=0 && part<=31)
453 {
454 REST_IF_NECESSARY();
455 qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]);
456 tunePos++;
457 }
458 }
459 break;
460 case kControllerPan:
461 if(channel_pan[channel] != (value << 1) + 256)
462 {
463 channel_pan[channel] = (value << 1) + 256;
464 if(part>=0 && part<=31)
465 {
466 REST_IF_NECESSARY();
467 qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]);
468 tunePos++;
469 }
470 }
471 break;
472 default:
473 /* No other controllers implemented yet */;
474 break;
475 }
476
477 break;
478 case MIDI_STATUS_PROG_CHANGE:
479 /* Instrument changed */
480 newInst = eventPos->data[0];
481
482 /* Channel 9 (the 10th channel) is different, it indicates a drum kit */
483 if (channel == 9)
484 newInst += kFirstDrumkit;
485 else
486 newInst += kFirstGMInstrument;
487 /* Only if the instrument for this channel *really* changed, add a new part. */
488 if(newInst != part_to_inst[part])
489 {
490 /* TODO maybe make use of kGeneralEventPartChange here,
491 to help QT reuse note channels?
492 */
493 part = channel_to_part[channel] = *numParts;
494 part_to_inst[(*numParts)++] = newInst;
495
496 if(channel_vol[channel] >= 0)
497 {
498 REST_IF_NECESSARY();
499 qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]);
500 tunePos++;
501 }
502 if(channel_pan[channel] >= 0)
503 {
504 REST_IF_NECESSARY();
505 qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]);
506 tunePos++;
507 }
508 if(channel_pitch_bend[channel] >= 0)
509 {
510 REST_IF_NECESSARY();
511 qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, channel_pitch_bend[channel]);
512 tunePos++;
513 }
514 }
515 break;
516 case MIDI_STATUS_PRESSURE:
517 /* NYI */
518 break;
519 case MIDI_STATUS_PITCH_WHEEL:
520 /* In the midi spec, 0x2000 = center, 0x0000 = - 2 semitones, 0x3FFF = +2 semitones
521 but for QTMA, we specify it as a 8.8 fixed point of semitones
522 TODO: detect "pitch bend range changes" & honor them!
523 */
524 bend = (eventPos->data[0] & 0x7f) | ((eventPos->data[1] & 0x7f) << 7);
525
526 /* "Center" the bend */
527 bend -= 0x2000;
528
529 /* Move it to our format: */
530 bend <<= 4;
531
532 /* If it turns out the pitch bend didn't change, stop here */
533 if(channel_pitch_bend[channel] == bend)
534 break;
535
536 channel_pitch_bend[channel] = bend;
537 if(part>=0 && part<=31)
538 {
539 /* Stuff a control event */
540 REST_IF_NECESSARY();
541 qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, bend);
542 tunePos++;
543 }
544 break;
545 case MIDI_STATUS_SYSEX:
546 if (eventPos->status == 0xFF && eventPos->data[0] == 0x51) /* Tempo change */
547 {
548 tempo = (eventPos->extraData[0] << 16) +
549 (eventPos->extraData[1] << 8) +
550 eventPos->extraData[2];
551
552 tick = tempo * Ippqn;
553 }
554 break;
555 }
556
557 /* on to the next event */
558 eventPos = eventPos->next;
559 }
560
561 /* Finally, place an end marker */
562 *tunePos = kEndMarkerValue;
563
564 return tuneSequence;
565 }
566
567 Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts)
568 {
569 Uint32 *myHeader;
570 Uint32 *myPos1, *myPos2; /* pointers to the head and tail long words of a music event */
571 NoteRequest *myNoteRequest;
572 NoteAllocator myNoteAllocator; /* for the NAStuffToneDescription call */
573 ComponentResult myErr = noErr;
574 int part;
575
576 myHeader = NULL;
577 myNoteAllocator = NULL;
578
579 /*
580 * Open up the Note Allocator
581 */
582 myNoteAllocator = OpenDefaultComponent(kNoteAllocatorComponentType,0);
583 if (myNoteAllocator == NULL)
584 goto bail;
585
586 /*
587 * Allocate space for the tune header
588 */
589 myHeader = (Uint32 *)
590 NewPtrClear((numParts * kNoteRequestEventLength + kMarkerEventLength) * sizeof(Uint32));
591 if (myHeader == NULL)
592 goto bail;
593
594 myPos1 = myHeader;
595
596 /*
597 * Loop over all parts
598 */
599 for(part = 0; part < numParts; ++part)
600 {
601 /*
602 * Stuff request for the instrument with the given polyphony
603 */
604 myPos2 = myPos1 + (kNoteRequestEventLength - 1); /* last longword of general event */
605 qtma_StuffGeneralEvent(*myPos1, *myPos2, part, kGeneralEventNoteRequest, kNoteRequestEventLength);
606 myNoteRequest = (NoteRequest *)(myPos1 + 1);
607 myNoteRequest->info.flags = 0;
608 /* I'm told by the Apple people that the Quicktime types were poorly designed and it was
609 * too late to change them. On little endian, the BigEndian(Short|Fixed) types are structs
610 * while on big endian they are primitive types. Furthermore, Quicktime failed to
611 * provide setter and getter functions. To get this to work, we need to case the
612 * code for the two possible situations.
613 * My assumption is that the right-side value was always expected to be BigEndian
614 * as it was written way before the Universal Binary transition. So in the little endian
615 * case, OSSwap is used.
616 */
617 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
618 myNoteRequest->info.polyphony.bigEndianValue = OSSwapHostToBigInt16(part_poly_max[part]);
619 myNoteRequest->info.typicalPolyphony.bigEndianValue = OSSwapHostToBigInt32(0x00010000);
620 #else
621 myNoteRequest->info.polyphony = part_poly_max[part];
622 myNoteRequest->info.typicalPolyphony = 0x00010000;
623 #endif
624 myErr = NAStuffToneDescription(myNoteAllocator,part_to_inst[part],&myNoteRequest->tone);
625 if (myErr != noErr)
626 goto bail;
627
628 /* move pointer to beginning of next event */
629 myPos1 += kNoteRequestEventLength;
630 }
631
632 *myPos1 = kEndMarkerValue; /* end of sequence marker */
633
634
635 bail:
636 if(myNoteAllocator)
637 CloseComponent(myNoteAllocator);
638
639 /* if we encountered an error, dispose of the storage we allocated and return NULL */
640 if (myErr != noErr) {
641 DisposePtr((Ptr)myHeader);
642 myHeader = NULL;
643 }
644
645 return myHeader;
646 }
647
648 #endif /* MacOS native MIDI support */
+0
-347
native_midi/native_midi_macosx.c less more
0 /*
1 native_midi_macosx: Native Midi support on Mac OS X for the SDL_mixer library
2 Copyright (C) 2009 Ryan C. Gordon <icculus@icculus.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This is Mac OS X only, using Core MIDI.
22 Mac OS 9 support via QuickTime is in native_midi_mac.c */
23
24 #include "SDL_config.h"
25
26 #if __MACOSX__
27
28 #include <CoreServices/CoreServices.h> /* ComponentDescription */
29 #include <AudioUnit/AudioUnit.h>
30 #include <AudioToolbox/AudioToolbox.h>
31 #include <AvailabilityMacros.h>
32
33 #include "SDL_endian.h"
34 #include "../SDL_mixer.h"
35 #include "../mixer.h"
36 #include "native_midi.h"
37
38 /* Native Midi song */
39 struct _NativeMidiSong
40 {
41 MusicPlayer player;
42 MusicSequence sequence;
43 MusicTimeStamp endTime;
44 AudioUnit audiounit;
45 int loops;
46 };
47
48 static NativeMidiSong *currentsong = NULL;
49 static int latched_volume = MIX_MAX_VOLUME;
50
51 static OSStatus
52 GetSequenceLength(MusicSequence sequence, MusicTimeStamp *_sequenceLength)
53 {
54 // http://lists.apple.com/archives/Coreaudio-api/2003/Jul/msg00370.html
55 // figure out sequence length
56 UInt32 ntracks, i;
57 MusicTimeStamp sequenceLength = 0;
58 OSStatus err;
59
60 err = MusicSequenceGetTrackCount(sequence, &ntracks);
61 if (err != noErr)
62 return err;
63
64 for (i = 0; i < ntracks; ++i)
65 {
66 MusicTrack track;
67 MusicTimeStamp tracklen = 0;
68 UInt32 tracklenlen = sizeof (tracklen);
69
70 err = MusicSequenceGetIndTrack(sequence, i, &track);
71 if (err != noErr)
72 return err;
73
74 err = MusicTrackGetProperty(track, kSequenceTrackProperty_TrackLength,
75 &tracklen, &tracklenlen);
76 if (err != noErr)
77 return err;
78
79 if (sequenceLength < tracklen)
80 sequenceLength = tracklen;
81 }
82
83 *_sequenceLength = sequenceLength;
84
85 return noErr;
86 }
87
88
89 /* we're looking for the sequence output audiounit. */
90 static OSStatus
91 GetSequenceAudioUnit(MusicSequence sequence, AudioUnit *aunit)
92 {
93 AUGraph graph;
94 UInt32 nodecount, i;
95 OSStatus err;
96
97 err = MusicSequenceGetAUGraph(sequence, &graph);
98 if (err != noErr)
99 return err;
100
101 err = AUGraphGetNodeCount(graph, &nodecount);
102 if (err != noErr)
103 return err;
104
105 for (i = 0; i < nodecount; i++) {
106 AUNode node;
107
108 if (AUGraphGetIndNode(graph, i, &node) != noErr)
109 continue; /* better luck next time. */
110
111 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 /* this is deprecated, but works back to 10.0 */
112 {
113 struct ComponentDescription desc;
114 UInt32 classdatasize = 0;
115 void *classdata = NULL;
116 err = AUGraphGetNodeInfo(graph, node, &desc, &classdatasize,
117 &classdata, aunit);
118 if (err != noErr)
119 continue;
120 else if (desc.componentType != kAudioUnitType_Output)
121 continue;
122 else if (desc.componentSubType != kAudioUnitSubType_DefaultOutput)
123 continue;
124 }
125 #else /* not deprecated, but requires 10.5 or later */
126 {
127 # if !defined(AUDIO_UNIT_VERSION) || ((AUDIO_UNIT_VERSION + 0) < 1060)
128 /* AUGraphAddNode () is changed to take an AudioComponentDescription*
129 * desc parameter instead of a ComponentDescription* in the 10.6 SDK.
130 * AudioComponentDescription is in 10.6 or newer, but it is actually
131 * the same as struct ComponentDescription with 20 bytes of size and
132 * the same offsets of all members, therefore, is binary compatible. */
133 # define AudioComponentDescription ComponentDescription
134 # endif
135 AudioComponentDescription desc;
136 if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr)
137 continue;
138 else if (desc.componentType != kAudioUnitType_Output)
139 continue;
140 else if (desc.componentSubType != kAudioUnitSubType_DefaultOutput)
141 continue;
142 }
143 #endif
144
145 return noErr; /* found it! */
146 }
147
148 return kAUGraphErr_NodeNotFound;
149 }
150
151
152 int native_midi_detect(void)
153 {
154 return 1; /* always available. */
155 }
156
157 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
158 {
159 NativeMidiSong *retval = NULL;
160 void *buf = NULL;
161 Sint64 len = 0;
162 CFDataRef data = NULL;
163
164 if (SDL_RWseek(src, 0, RW_SEEK_END) < 0)
165 goto fail;
166 len = SDL_RWtell(src);
167 if (len < 0)
168 goto fail;
169 if (SDL_RWseek(src, 0, RW_SEEK_SET) < 0)
170 goto fail;
171
172 buf = malloc(len);
173 if (buf == NULL)
174 goto fail;
175
176 if (SDL_RWread(src, buf, len, 1) != 1)
177 goto fail;
178
179 retval = malloc(sizeof(NativeMidiSong));
180 if (retval == NULL)
181 goto fail;
182
183 memset(retval, '\0', sizeof (*retval));
184
185 if (NewMusicPlayer(&retval->player) != noErr)
186 goto fail;
187 if (NewMusicSequence(&retval->sequence) != noErr)
188 goto fail;
189
190 data = CFDataCreate(NULL, (const UInt8 *) buf, len);
191 if (data == NULL)
192 goto fail;
193
194 free(buf);
195 buf = NULL;
196
197 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
198 /* MusicSequenceLoadSMFData() (avail. in 10.2, no 64 bit) is
199 * equivalent to calling MusicSequenceLoadSMFDataWithFlags()
200 * with a flags value of 0 (avail. in 10.3, avail. 64 bit).
201 * So, we use MusicSequenceLoadSMFData() for powerpc versions
202 * but the *WithFlags() on intel which require 10.4 anyway. */
203 # if defined(__ppc__) || defined(__POWERPC__)
204 if (MusicSequenceLoadSMFData(song->sequence, data) != noErr)
205 goto fail;
206 # else
207 if (MusicSequenceLoadSMFDataWithFlags(retval->sequence, data, 0) != noErr)
208 goto fail;
209 # endif
210 #else /* MusicSequenceFileLoadData() requires 10.5 or later. */
211 if (MusicSequenceFileLoadData(retval->sequence, data, 0, 0) != noErr)
212 goto fail;
213 #endif
214
215 CFRelease(data);
216 data = NULL;
217
218 if (GetSequenceLength(retval->sequence, &retval->endTime) != noErr)
219 goto fail;
220
221 if (MusicPlayerSetSequence(retval->player, retval->sequence) != noErr)
222 goto fail;
223
224 if (freesrc)
225 SDL_RWclose(src);
226
227 return retval;
228
229 fail:
230 if (retval) {
231 if (retval->sequence)
232 DisposeMusicSequence(retval->sequence);
233 if (retval->player)
234 DisposeMusicPlayer(retval->player);
235 free(retval);
236 }
237
238 if (data)
239 CFRelease(data);
240
241 if (buf)
242 free(buf);
243
244 return NULL;
245 }
246
247 void native_midi_freesong(NativeMidiSong *song)
248 {
249 if (song != NULL) {
250 if (currentsong == song)
251 currentsong = NULL;
252 MusicPlayerStop(song->player);
253 DisposeMusicSequence(song->sequence);
254 DisposeMusicPlayer(song->player);
255 free(song);
256 }
257 }
258
259 void native_midi_start(NativeMidiSong *song, int loops)
260 {
261 int vol;
262
263 if (song == NULL)
264 return;
265
266 SDL_PauseAudio(1);
267 Mix_UnlockAudio();
268
269 if (currentsong)
270 MusicPlayerStop(currentsong->player);
271
272 currentsong = song;
273 currentsong->loops = loops;
274
275 MusicPlayerPreroll(song->player);
276 MusicPlayerSetTime(song->player, 0);
277 MusicPlayerStart(song->player);
278
279 GetSequenceAudioUnit(song->sequence, &song->audiounit);
280
281 vol = latched_volume;
282 latched_volume++; /* just make this not match. */
283 native_midi_setvolume(vol);
284
285 Mix_LockAudio();
286 SDL_PauseAudio(0);
287 }
288
289 void native_midi_pause(void)
290 {
291 }
292
293 void native_midi_resume(void)
294 {
295 }
296
297 void native_midi_stop(void)
298 {
299 if (currentsong) {
300 SDL_PauseAudio(1);
301 Mix_UnlockAudio();
302 MusicPlayerStop(currentsong->player);
303 currentsong = NULL;
304 Mix_LockAudio();
305 SDL_PauseAudio(0);
306 }
307 }
308
309 int native_midi_active(void)
310 {
311 MusicTimeStamp currentTime = 0;
312 if (currentsong == NULL)
313 return 0;
314
315 MusicPlayerGetTime(currentsong->player, &currentTime);
316 if ((currentTime < currentsong->endTime) ||
317 (currentTime >= kMusicTimeStamp_EndOfTrack)) {
318 return 1;
319 } else if (currentsong->loops) {
320 --currentsong->loops;
321 MusicPlayerSetTime(currentsong->player, 0);
322 return 1;
323 }
324 return 0;
325 }
326
327 void native_midi_setvolume(int volume)
328 {
329 if (latched_volume == volume)
330 return;
331
332 latched_volume = volume;
333 if ((currentsong) && (currentsong->audiounit)) {
334 const float floatvol = ((float) volume) / ((float) MIX_MAX_VOLUME);
335 AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume,
336 kAudioUnitScope_Global, 0, floatvol, 0);
337 }
338 }
339
340 const char *native_midi_error(void)
341 {
342 return ""; /* !!! FIXME */
343 }
344
345 #endif /* Mac OS X native MIDI support */
346
+0
-321
native_midi/native_midi_win32.c less more
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 /* everything below is currently one very big bad hack ;) Proff */
23
24 #if __WIN32__
25 #define WIN32_LEAN_AND_MEAN
26 #include <windows.h>
27 #include <windowsx.h>
28 #include <mmsystem.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <limits.h>
32 #include "native_midi.h"
33 #include "native_midi_common.h"
34
35 struct _NativeMidiSong {
36 int MusicLoaded;
37 int MusicPlaying;
38 int Loops;
39 int CurrentHdr;
40 MIDIHDR MidiStreamHdr[2];
41 MIDIEVENT *NewEvents;
42 Uint16 ppqn;
43 int Size;
44 int NewPos;
45 };
46
47 static UINT MidiDevice=MIDI_MAPPER;
48 static HMIDISTRM hMidiStream;
49 static NativeMidiSong *currentsong;
50
51 static int BlockOut(NativeMidiSong *song)
52 {
53 MMRESULT err;
54 int BlockSize;
55 MIDIHDR *hdr;
56
57 if ((song->MusicLoaded) && (song->NewEvents))
58 {
59 // proff 12/8/98: Added for safety
60 song->CurrentHdr = !song->CurrentHdr;
61 hdr = &song->MidiStreamHdr[song->CurrentHdr];
62 midiOutUnprepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR));
63 if (song->NewPos>=song->Size)
64 return 0;
65 BlockSize=(song->Size-song->NewPos);
66 if (BlockSize<=0)
67 return 0;
68 if (BlockSize>36000)
69 BlockSize=36000;
70 hdr->lpData=(void *)((unsigned char *)song->NewEvents+song->NewPos);
71 song->NewPos+=BlockSize;
72 hdr->dwBufferLength=BlockSize;
73 hdr->dwBytesRecorded=BlockSize;
74 hdr->dwFlags=0;
75 hdr->dwOffset=0;
76 err=midiOutPrepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR));
77 if (err!=MMSYSERR_NOERROR)
78 return 0;
79 err=midiStreamOut(hMidiStream,hdr,sizeof(MIDIHDR));
80 return 0;
81 }
82 return 1;
83 }
84
85 static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist)
86 {
87 int eventcount;
88 MIDIEvent *event;
89 MIDIEVENT *newevent;
90
91 eventcount=0;
92 event=evntlist;
93 while (event)
94 {
95 eventcount++;
96 event=event->next;
97 }
98 song->NewEvents=malloc(eventcount*3*sizeof(DWORD));
99 if (!song->NewEvents)
100 return;
101 memset(song->NewEvents,0,(eventcount*3*sizeof(DWORD)));
102
103 eventcount=0;
104 event=evntlist;
105 newevent=song->NewEvents;
106 while (event)
107 {
108 int status = (event->status&0xF0)>>4;
109 switch (status)
110 {
111 case MIDI_STATUS_NOTE_OFF:
112 case MIDI_STATUS_NOTE_ON:
113 case MIDI_STATUS_AFTERTOUCH:
114 case MIDI_STATUS_CONTROLLER:
115 case MIDI_STATUS_PROG_CHANGE:
116 case MIDI_STATUS_PRESSURE:
117 case MIDI_STATUS_PITCH_WHEEL:
118 newevent->dwDeltaTime=event->time;
119 newevent->dwEvent=(event->status|0x80)|(event->data[0]<<8)|(event->data[1]<<16)|(MEVT_SHORTMSG<<24);
120 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
121 eventcount++;
122 break;
123
124 case MIDI_STATUS_SYSEX:
125 if (event->status == 0xFF && event->data[0] == 0x51) /* Tempo change */
126 {
127 int tempo = (event->extraData[0] << 16) |
128 (event->extraData[1] << 8) |
129 event->extraData[2];
130 newevent->dwDeltaTime=event->time;
131 newevent->dwEvent=(MEVT_TEMPO<<24) | tempo;
132 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
133 eventcount++;
134 }
135 break;
136 }
137
138 event=event->next;
139 }
140
141 song->Size=eventcount*3*sizeof(DWORD);
142
143 {
144 int time;
145 int temptime;
146
147 song->NewPos=0;
148 time=0;
149 newevent=song->NewEvents;
150 while (song->NewPos<song->Size)
151 {
152 temptime=newevent->dwDeltaTime;
153 newevent->dwDeltaTime-=time;
154 time=temptime;
155 if ((song->NewPos+12)>=song->Size)
156 newevent->dwEvent |= MEVT_F_CALLBACK;
157 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
158 song->NewPos+=12;
159 }
160 }
161 song->NewPos=0;
162 song->MusicLoaded=1;
163 }
164
165 void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance,
166 DWORD_PTR dwParam1, DWORD_PTR dwParam2 )
167 {
168 switch( uMsg )
169 {
170 case MOM_DONE:
171 if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)&currentsong->MidiStreamHdr[currentsong->CurrentHdr]))
172 BlockOut(currentsong);
173 break;
174 case MOM_POSITIONCB:
175 if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)&currentsong->MidiStreamHdr[currentsong->CurrentHdr])) {
176 if (currentsong->Loops) {
177 if (currentsong->Loops > 0)
178 --currentsong->Loops;
179 currentsong->NewPos=0;
180 BlockOut(currentsong);
181 } else {
182 currentsong->MusicPlaying=0;
183 }
184 }
185 break;
186 default:
187 break;
188 }
189 }
190
191 int native_midi_detect(void)
192 {
193 MMRESULT merr;
194 HMIDISTRM MidiStream;
195
196 merr=midiStreamOpen(&MidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION);
197 if (merr!=MMSYSERR_NOERROR)
198 return 0;
199 midiStreamClose(MidiStream);
200 return 1;
201 }
202
203 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
204 {
205 NativeMidiSong *newsong;
206 MIDIEvent *evntlist = NULL;
207
208 newsong=malloc(sizeof(NativeMidiSong));
209 if (!newsong) {
210 return NULL;
211 }
212 memset(newsong,0,sizeof(NativeMidiSong));
213
214 /* Attempt to load the midi file */
215 evntlist = CreateMIDIEventList(src, &newsong->ppqn);
216 if (!evntlist)
217 {
218 free(newsong);
219 return NULL;
220 }
221
222 MIDItoStream(newsong, evntlist);
223
224 FreeMIDIEventList(evntlist);
225
226 if (freesrc) {
227 SDL_RWclose(src);
228 }
229 return newsong;
230 }
231
232 void native_midi_freesong(NativeMidiSong *song)
233 {
234 if (hMidiStream)
235 {
236 midiStreamStop(hMidiStream);
237 midiStreamClose(hMidiStream);
238 }
239 if (song)
240 {
241 if (song->NewEvents)
242 free(song->NewEvents);
243 free(song);
244 }
245 }
246
247 void native_midi_start(NativeMidiSong *song, int loops)
248 {
249 MMRESULT merr;
250 MIDIPROPTIMEDIV mptd;
251
252 native_midi_stop();
253 if (!hMidiStream)
254 {
255 merr=midiStreamOpen(&hMidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION);
256 if (merr!=MMSYSERR_NOERROR)
257 {
258 hMidiStream = NULL; // should I do midiStreamClose(hMidiStream) before?
259 return;
260 }
261 //midiStreamStop(hMidiStream);
262 currentsong=song;
263 currentsong->NewPos=0;
264 currentsong->MusicPlaying=1;
265 currentsong->Loops=loops;
266 mptd.cbStruct=sizeof(MIDIPROPTIMEDIV);
267 mptd.dwTimeDiv=currentsong->ppqn;
268 merr=midiStreamProperty(hMidiStream,(LPBYTE)&mptd,MIDIPROP_SET | MIDIPROP_TIMEDIV);
269 BlockOut(song);
270 merr=midiStreamRestart(hMidiStream);
271 }
272 }
273
274 void native_midi_pause(void)
275 {
276 if (!hMidiStream)
277 return;
278 midiStreamPause(hMidiStream);
279 }
280
281 void native_midi_resume(void)
282 {
283 if (!hMidiStream)
284 return;
285 midiStreamRestart(hMidiStream);
286 }
287
288 void native_midi_stop(void)
289 {
290 if (!hMidiStream)
291 return;
292 midiStreamStop(hMidiStream);
293 midiStreamClose(hMidiStream);
294 currentsong=NULL;
295 hMidiStream = NULL;
296 }
297
298 int native_midi_active(void)
299 {
300 return currentsong->MusicPlaying;
301 }
302
303 void native_midi_setvolume(int volume)
304 {
305 int calcVolume;
306 if (volume > 128)
307 volume = 128;
308 if (volume < 0)
309 volume = 0;
310 calcVolume = (65535 * volume / 128);
311
312 midiOutSetVolume((HMIDIOUT)hMidiStream, MAKELONG(calcVolume , calcVolume));
313 }
314
315 const char *native_midi_error(void)
316 {
317 return "";
318 }
319
320 #endif /* Windows native MIDI support */
00 /*
11 PLAYMUS: A test application for the SDL mixer library.
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2121 /* Quiet windows compiler warnings */
2222 #define _CRT_SECURE_NO_WARNINGS
2323
24 /* $Id$ */
24 #include "SDL_stdinc.h"
2525
2626 #include <stdlib.h>
2727 #include <stdio.h>
6666 SDL_Log("Usage: %s [-i] [-l] [-8] [-f32] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] <musicfile>\n", argv0);
6767 }
6868
69 /*#define SEEK_TEST */
6970 void Menu(void)
7071 {
7172 char buf[10];
7475 fflush(stdin);
7576 if (scanf("%s",buf) == 1) {
7677 switch(buf[0]){
78 #if defined(SEEK_TEST)
79 case '0': Mix_SetMusicPosition(0); break;
80 case '1': Mix_SetMusicPosition(10);break;
81 case '2': Mix_SetMusicPosition(20);break;
82 case '3': Mix_SetMusicPosition(30);break;
83 case '4': Mix_SetMusicPosition(40);break;
84 #endif /* SEEK_TEST */
7785 case 'p': case 'P':
7886 Mix_PauseMusic();
7987 break;
116124 int interactive = 0;
117125 int rwops = 0;
118126 int i;
127 const char *typ;
128 const char *tag_title = NULL;
129 const char *tag_artist = NULL;
130 const char *tag_album = NULL;
131 const char *tag_copyright = NULL;
132 double loop_start, loop_end, loop_length, current_position;
133
134 (void) argc;
119135
120136 /* Initialize variables */
121 audio_rate = 22050;
122 audio_format = AUDIO_S16;
123 audio_channels = 2;
137 audio_rate = MIX_DEFAULT_FREQUENCY;
138 audio_format = MIX_DEFAULT_FORMAT;
139 audio_channels = MIX_DEFAULT_CHANNELS;
124140 audio_buffers = 4096;
125141
126142 /* Check command line usage */
214230 CleanUp(2);
215231 }
216232
233 switch (Mix_GetMusicType(music)) {
234 case MUS_CMD:
235 typ = "CMD";
236 break;
237 case MUS_WAV:
238 typ = "WAV";
239 break;
240 case MUS_MOD:
241 case MUS_MODPLUG_UNUSED:
242 typ = "MOD";
243 break;
244 case MUS_FLAC:
245 typ = "FLAC";
246 break;
247 case MUS_MID:
248 typ = "MIDI";
249 break;
250 case MUS_OGG:
251 typ = "OGG Vorbis";
252 break;
253 case MUS_MP3:
254 case MUS_MP3_MAD_UNUSED:
255 typ = "MP3";
256 break;
257 case MUS_OPUS:
258 typ = "OPUS";
259 break;
260 case MUS_NONE:
261 default:
262 typ = "NONE";
263 break;
264 }
265 SDL_Log("Detected music type: %s", typ);
266
267 tag_title = Mix_GetMusicTitleTag(music);
268 if (tag_title && SDL_strlen(tag_title) > 0) {
269 SDL_Log("Title: %s", tag_title);
270 }
271
272 tag_artist = Mix_GetMusicArtistTag(music);
273 if (tag_artist && SDL_strlen(tag_artist) > 0) {
274 SDL_Log("Artist: %s", tag_artist);
275 }
276
277 tag_album = Mix_GetMusicAlbumTag(music);
278 if (tag_album && SDL_strlen(tag_album) > 0) {
279 SDL_Log("Album: %s", tag_album);
280 }
281
282 tag_copyright = Mix_GetMusicCopyrightTag(music);
283 if (tag_copyright && SDL_strlen(tag_copyright) > 0) {
284 SDL_Log("Copyright: %s", tag_copyright);
285 }
286
287 loop_start = Mix_GetMusicLoopStartTime(music);
288 loop_end = Mix_GetMusicLoopEndTime(music);
289 loop_length = Mix_GetMusicLoopLengthTime(music);
290
217291 /* Play and then exit */
218 SDL_Log("Playing %s\n", argv[i]);
292 SDL_Log("Playing %s, duration %f\n", argv[i], Mix_MusicDuration(music));
293 if (loop_start > 0.0 && loop_end > 0.0 && loop_length > 0.0) {
294 SDL_Log("Loop points: start %g s, end %g s, length %g s\n", loop_start, loop_end, loop_length);
295 }
219296 Mix_FadeInMusic(music,looping,2000);
220297 while (!next_track && (Mix_PlayingMusic() || Mix_PausedMusic())) {
221298 if(interactive)
222299 Menu();
223 else
300 else {
301 current_position = Mix_GetMusicPosition(music);
302 if (current_position >= 0.0) {
303 printf("Position: %g seconds \r", current_position);
304 fflush(stdout);
305 }
224306 SDL_Delay(100);
307 }
225308 }
226309 Mix_FreeMusic(music);
227310 music = NULL;
00 /*
11 PLAYWAVE: A test application for the SDL mixer library.
2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
1818 3. This notice may not be removed or altered from any source distribution.
1919 */
2020
21 /* $Id$ */
21 #include "SDL_stdinc.h"
2222
2323 #include <stdlib.h>
2424 #include <stdio.h>
117117 static void test_versions(void)
118118 {
119119 SDL_version compiled;
120 const SDL_version *linked;
120 SDL_version linked;
121121
122122 SDL_VERSION(&compiled);
123 linked = SDL_Linked_Version();
124 output_versions("SDL", &compiled, linked);
123 SDL_GetVersion(&linked);
124 output_versions("SDL", &compiled, &linked);
125125
126126 SDL_MIXER_VERSION(&compiled);
127 linked = Mix_Linked_Version();
128 output_versions("SDL_mixer", &compiled, linked);
127 SDL_memcpy(&linked, Mix_Linked_Version(), sizeof(SDL_version));
128 output_versions("SDL_mixer", &compiled, &linked);
129129 }
130130 #endif
131131
136136 {
137137 Mix_Chunk *done_chunk = Mix_GetChunk(chan);
138138 SDL_Log("We were just alerted that Mixer channel #%d is done.\n", chan);
139 SDL_Log("Channel's chunk pointer is (%p).\n", done_chunk);
139 SDL_Log("Channel's chunk pointer is (%p).\n", (void*)done_chunk);
140140 SDL_Log(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
141141 channel_is_done = 1;
142142 }
159159 {
160160 static Uint8 leftvol = 128;
161161 static Uint8 rightvol = 128;
162 static Uint8 leftincr = -1;
163 static Uint8 rightincr = 1;
162 static Sint8 leftincr = -1;
163 static Sint8 rightincr = 1;
164164 static int panningok = 1;
165165 static Uint32 next_panning_update = 0;
166166
173173 }
174174
175175 if ((leftvol == 255) || (leftvol == 0)) {
176 if (leftvol == 255)
176 if (leftvol == 255) {
177177 SDL_Log("All the way in the left speaker.\n");
178 leftincr *= -1;
178 }
179 leftincr *= -1;
179180 }
180181
181182 if ((rightvol == 255) || (rightvol == 0)) {
182 if (rightvol == 255)
183 if (rightvol == 255) {
183184 SDL_Log("All the way in the right speaker.\n");
185 }
184186 rightincr *= -1;
185187 }
186188
196198 static void do_distance_update(void)
197199 {
198200 static Uint8 distance = 1;
199 static Uint8 distincr = 1;
201 static Sint8 distincr = 1;
200202 static int distanceok = 1;
201203 static Uint32 next_distance_update = 0;
202204
228230 {
229231 static Sint16 distance = 1;
230232 static Sint8 distincr = 1;
231 static Uint16 angle = 0;
233 static Sint16 angle = 0;
232234 static Sint8 angleincr = 1;
233235 static int positionok = 1;
234236 static Uint32 next_position_update = 0;
235237
236238 if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
237 positionok = Mix_SetPosition(0, angle, distance);
239 positionok = Mix_SetPosition(0, angle, (Uint8)distance);
238240 if (!positionok) {
239241 SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
240242 (int) angle, (int) distance);
252254 }
253255
254256 distance += distincr;
255
256257 if (distance < 0) {
257258 distance = 0;
258259 distincr = 3;
364365 int reverse_stereo = 0;
365366 int reverse_sample = 0;
366367
368 (void) argc;
369
367370 #ifdef HAVE_SETBUF
368371 setbuf(stdout, NULL); /* rcg06132001 for debugging purposes. */
369372 setbuf(stderr, NULL); /* rcg06192001 for debugging purposes, too. */
373376 /* Initialize variables */
374377 audio_rate = MIX_DEFAULT_FREQUENCY;
375378 audio_format = MIX_DEFAULT_FORMAT;
376 audio_channels = 2;
379 audio_channels = MIX_DEFAULT_CHANNELS;
377380
378381 /* Check command line usage */
379382 for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an AIFF file into a waveform.
21 It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadAIFF_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
26 8SVX file support added by Marc Le Douarain (mavati@club-internet.fr)
27 in december 2002.
28 */
29
30 #include "SDL_endian.h"
31 #include "SDL_mixer.h"
32 #include "load_aiff.h"
33
34 /*********************************************/
35 /* Define values for AIFF (IFF audio) format */
36 /*********************************************/
37 #define FORM 0x4d524f46 /* "FORM" */
38
39 #define AIFF 0x46464941 /* "AIFF" */
40 #define SSND 0x444e5353 /* "SSND" */
41 #define COMM 0x4d4d4f43 /* "COMM" */
42
43 #define _8SVX 0x58565338 /* "8SVX" */
44 #define VHDR 0x52444856 /* "VHDR" */
45 #define BODY 0x59444F42 /* "BODY" */
46
47 /* This function was taken from libsndfile. I don't pretend to fully
48 * understand it.
49 */
50
51 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
52 {
53 /* Is the frequency outside of what we can represent with Uint32? */
54 if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40)
55 || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C))
56 return 0;
57
58 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7)
59 | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
60 }
61
62 /* This function is based on SDL_LoadWAV_RW(). */
63
64 SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
65 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
66 {
67 int was_error;
68 int found_SSND;
69 int found_COMM;
70 int found_VHDR;
71 int found_BODY;
72 Sint64 start = 0;
73
74 Uint32 chunk_type;
75 Uint32 chunk_length;
76 Sint64 next_chunk;
77
78 /* AIFF magic header */
79 Uint32 FORMchunk;
80 Uint32 AIFFmagic;
81
82 /* SSND chunk */
83 Uint32 offset;
84 Uint32 blocksize;
85
86 /* COMM format chunk */
87 Uint16 channels = 0;
88 Uint32 numsamples = 0;
89 Uint16 samplesize = 0;
90 Uint8 sane_freq[10];
91 Uint32 frequency = 0;
92
93 /* Make sure we are passed a valid data source */
94 was_error = 0;
95 if (src == NULL) {
96 was_error = 1;
97 goto done;
98 }
99
100 FORMchunk = SDL_ReadLE32(src);
101 chunk_length = SDL_ReadBE32(src);
102 if (chunk_length == AIFF) { /* The FORMchunk has already been read */
103 AIFFmagic = chunk_length;
104 chunk_length = FORMchunk;
105 FORMchunk = FORM;
106 } else {
107 AIFFmagic = SDL_ReadLE32(src);
108 }
109 if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) {
110 SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)");
111 was_error = 1;
112 goto done;
113 }
114
115 /* TODO: Better santity-checking. */
116
117 found_SSND = 0;
118 found_COMM = 0;
119 found_VHDR = 0;
120 found_BODY = 0;
121
122 do {
123 chunk_type = SDL_ReadLE32(src);
124 chunk_length = SDL_ReadBE32(src);
125 next_chunk = SDL_RWtell(src) + chunk_length;
126 /* Paranoia to avoid infinite loops */
127 if (chunk_length == 0)
128 break;
129
130 switch (chunk_type) {
131 case SSND:
132 found_SSND = 1;
133 offset = SDL_ReadBE32(src);
134 blocksize = SDL_ReadBE32(src);
135 start = SDL_RWtell(src) + offset;
136 (void)blocksize; /* unused. */
137 break;
138
139 case COMM:
140 found_COMM = 1;
141 channels = SDL_ReadBE16(src);
142 numsamples = SDL_ReadBE32(src);
143 samplesize = SDL_ReadBE16(src);
144 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
145 frequency = SANE_to_Uint32(sane_freq);
146 if (frequency == 0) {
147 SDL_SetError("Bad AIFF sample frequency");
148 was_error = 1;
149 goto done;
150 }
151 break;
152
153 case VHDR:
154 found_VHDR = 1;
155 SDL_ReadBE32(src);
156 SDL_ReadBE32(src);
157 SDL_ReadBE32(src);
158 frequency = SDL_ReadBE16(src);
159 channels = 1;
160 samplesize = 8;
161 break;
162
163 case BODY:
164 found_BODY = 1;
165 numsamples = chunk_length;
166 start = SDL_RWtell(src);
167 break;
168
169 default:
170 break;
171 }
172 /* a 0 pad byte can be stored for any odd-length chunk */
173 if (chunk_length&1)
174 next_chunk++;
175 } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM))
176 || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY)))
177 && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1);
178
179 if ((AIFFmagic == AIFF) && !found_SSND) {
180 SDL_SetError("Bad AIFF (no SSND chunk)");
181 was_error = 1;
182 goto done;
183 }
184
185 if ((AIFFmagic == AIFF) && !found_COMM) {
186 SDL_SetError("Bad AIFF (no COMM chunk)");
187 was_error = 1;
188 goto done;
189 }
190
191 if ((AIFFmagic == _8SVX) && !found_VHDR) {
192 SDL_SetError("Bad 8SVX (no VHDR chunk)");
193 was_error = 1;
194 goto done;
195 }
196
197 if ((AIFFmagic == _8SVX) && !found_BODY) {
198 SDL_SetError("Bad 8SVX (no BODY chunk)");
199 was_error = 1;
200 goto done;
201 }
202
203 /* Decode the audio data format */
204 SDL_memset(spec, 0, sizeof(*spec));
205 spec->freq = frequency;
206 switch (samplesize) {
207 case 8:
208 spec->format = AUDIO_S8;
209 break;
210 case 16:
211 spec->format = AUDIO_S16MSB;
212 break;
213 default:
214 SDL_SetError("Unsupported AIFF samplesize");
215 was_error = 1;
216 goto done;
217 }
218 spec->channels = (Uint8) channels;
219 spec->samples = 4096; /* Good default buffer size */
220
221 *audio_len = channels * numsamples * (samplesize / 8);
222 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
223 if (*audio_buf == NULL) {
224 SDL_SetError("Out of memory");
225 return(NULL);
226 }
227 SDL_RWseek(src, start, RW_SEEK_SET);
228 if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
229 SDL_SetError("Unable to read audio data");
230 return(NULL);
231 }
232
233 /* Don't return a buffer that isn't a multiple of samplesize */
234 *audio_len &= ~((samplesize / 8) - 1);
235
236 done:
237 if (freesrc && src) {
238 SDL_RWclose(src);
239 }
240 if (was_error) {
241 spec = NULL;
242 }
243 return(spec);
244 }
245
246 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an AIFF file into a waveform.
21 It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadAIFF_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
26 */
27
28 /* Don't call this directly; use Mix_LoadWAV_RW() for now. */
29 SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
30 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
31
32 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode a Creative Labs VOC file into a
21 waveform. It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadVOC_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Ryan C. Gordon (icculus@icculus.org).
26
27 Heavily borrowed from sox v12.17.1's voc.c.
28 (http://www.freshmeat.net/projects/sox/)
29 */
30
31 #include "SDL_mixer.h"
32 #include "load_voc.h"
33
34 /* Private data for VOC file */
35 typedef struct vocstuff {
36 Uint32 rest; /* bytes remaining in current block */
37 Uint32 rate; /* rate code (byte) of this chunk */
38 int silent; /* sound or silence? */
39 Uint32 srate; /* rate code (byte) of silence */
40 Uint32 blockseek; /* start of current output block */
41 Uint32 samples; /* number of samples output */
42 Uint32 size; /* word length of data */
43 Uint8 channels; /* number of sound channels */
44 int has_extended; /* Has an extended block been read? */
45 } vs_t;
46
47 /* Size field */
48 /* SJB: note that the 1st 3 are sometimes used as sizeof(type) */
49 #define ST_SIZE_BYTE 1
50 #define ST_SIZE_8BIT 1
51 #define ST_SIZE_WORD 2
52 #define ST_SIZE_16BIT 2
53 #define ST_SIZE_DWORD 4
54 #define ST_SIZE_32BIT 4
55 #define ST_SIZE_FLOAT 5
56 #define ST_SIZE_DOUBLE 6
57 #define ST_SIZE_IEEE 7 /* IEEE 80-bit floats. */
58
59 /* Style field */
60 #define ST_ENCODING_UNSIGNED 1 /* unsigned linear: Sound Blaster */
61 #define ST_ENCODING_SIGN2 2 /* signed linear 2's comp: Mac */
62 #define ST_ENCODING_ULAW 3 /* U-law signed logs: US telephony, SPARC */
63 #define ST_ENCODING_ALAW 4 /* A-law signed logs: non-US telephony */
64 #define ST_ENCODING_ADPCM 5 /* Compressed PCM */
65 #define ST_ENCODING_IMA_ADPCM 6 /* Compressed PCM */
66 #define ST_ENCODING_GSM 7 /* GSM 6.10 33-byte frame lossy compression */
67
68 #define VOC_TERM 0
69 #define VOC_DATA 1
70 #define VOC_CONT 2
71 #define VOC_SILENCE 3
72 #define VOC_MARKER 4
73 #define VOC_TEXT 5
74 #define VOC_LOOP 6
75 #define VOC_LOOPEND 7
76 #define VOC_EXTENDED 8
77 #define VOC_DATA_16 9
78
79 #define VOC_BAD_RATE ~((Uint32)0)
80
81
82 static int voc_check_header(SDL_RWops *src)
83 {
84 /* VOC magic header */
85 Uint8 signature[20]; /* "Creative Voice File\032" */
86 Uint16 datablockofs;
87
88 SDL_RWseek(src, 0, RW_SEEK_SET);
89
90 if (SDL_RWread(src, signature, sizeof (signature), 1) != 1)
91 return(0);
92
93 if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) {
94 SDL_SetError("Unrecognized file type (not VOC)");
95 return(0);
96 }
97
98 /* get the offset where the first datablock is located */
99 if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1)
100 return(0);
101
102 datablockofs = SDL_SwapLE16(datablockofs);
103
104 if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
105 return(0);
106
107 return(1); /* success! */
108 } /* voc_check_header */
109
110
111 /* Read next block header, save info, leave position at start of data */
112 static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
113 {
114 Uint8 bits24[3];
115 Uint8 uc, block;
116 Uint32 sblen;
117 Uint16 new_rate_short;
118 Uint32 new_rate_long;
119 Uint8 trash[6];
120 Uint16 period;
121 unsigned int i;
122
123 v->silent = 0;
124 while (v->rest == 0)
125 {
126 if (SDL_RWread(src, &block, sizeof (block), 1) != 1)
127 return 1; /* assume that's the end of the file. */
128
129 if (block == VOC_TERM)
130 return 1;
131
132 if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
133 return 1; /* assume that's the end of the file. */
134
135 /* Size is an 24-bit value. Ugh. */
136 sblen = (Uint32)((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16));
137
138 switch(block)
139 {
140 case VOC_DATA:
141 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
142 return 0;
143
144 /* When DATA block preceeded by an EXTENDED */
145 /* block, the DATA blocks rate value is invalid */
146 if (!v->has_extended)
147 {
148 if (uc == 0)
149 {
150 SDL_SetError("VOC Sample rate is zero?");
151 return 0;
152 }
153
154 if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
155 {
156 SDL_SetError("VOC sample rate codes differ");
157 return 0;
158 }
159
160 v->rate = uc;
161 spec->freq = (Uint16)(1000000.0/(256 - v->rate));
162 v->channels = 1;
163 }
164
165 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
166 return 0;
167
168 if (uc != 0)
169 {
170 SDL_SetError("VOC decoder only interprets 8-bit data");
171 return 0;
172 }
173
174 v->has_extended = 0;
175 v->rest = sblen - 2;
176 v->size = ST_SIZE_BYTE;
177 return 1;
178
179 case VOC_DATA_16:
180 if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1)
181 return 0;
182 new_rate_long = SDL_SwapLE32(new_rate_long);
183 if (new_rate_long == 0)
184 {
185 SDL_SetError("VOC Sample rate is zero?");
186 return 0;
187 }
188 if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate))
189 {
190 SDL_SetError("VOC sample rate codes differ");
191 return 0;
192 }
193 v->rate = new_rate_long;
194 spec->freq = (int)new_rate_long;
195
196 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
197 return 0;
198
199 switch (uc)
200 {
201 case 8: v->size = ST_SIZE_BYTE; break;
202 case 16: v->size = ST_SIZE_WORD; break;
203 default:
204 SDL_SetError("VOC with unknown data size");
205 return 0;
206 }
207
208 if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1)
209 return 0;
210
211 if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6)
212 return 0;
213
214 v->rest = sblen - 12;
215 return 1;
216
217 case VOC_CONT:
218 v->rest = sblen;
219 return 1;
220
221 case VOC_SILENCE:
222 if (SDL_RWread(src, &period, sizeof (period), 1) != 1)
223 return 0;
224 period = SDL_SwapLE16(period);
225
226 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
227 return 0;
228 if (uc == 0)
229 {
230 SDL_SetError("VOC silence sample rate is zero");
231 return 0;
232 }
233
234 /*
235 * Some silence-packed files have gratuitously
236 * different sample rate codes in silence.
237 * Adjust period.
238 */
239 if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
240 period = (Uint16)((period * (256 - uc))/(256 - v->rate));
241 else
242 v->rate = uc;
243 v->rest = period;
244 v->silent = 1;
245 return 1;
246
247 case VOC_LOOP:
248 case VOC_LOOPEND:
249 for(i = 0; i < sblen; i++) /* skip repeat loops. */
250 {
251 if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1)
252 return 0;
253 }
254 break;
255
256 case VOC_EXTENDED:
257 /* An Extended block is followed by a data block */
258 /* Set this byte so we know to use the rate */
259 /* value from the extended block and not the */
260 /* data block. */
261 v->has_extended = 1;
262 if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1)
263 return 0;
264 new_rate_short = SDL_SwapLE16(new_rate_short);
265 if (new_rate_short == 0)
266 {
267 SDL_SetError("VOC sample rate is zero");
268 return 0;
269 }
270 if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate))
271 {
272 SDL_SetError("VOC sample rate codes differ");
273 return 0;
274 }
275 v->rate = new_rate_short;
276
277 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
278 return 0;
279
280 if (uc != 0)
281 {
282 SDL_SetError("VOC decoder only interprets 8-bit data");
283 return 0;
284 }
285
286 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
287 return 0;
288
289 if (uc)
290 spec->channels = 2; /* Stereo */
291 /* VOC_EXTENDED may be read before spec->channels inited: */
292 else spec->channels = 1;
293 /* Needed number of channels before finishing
294 compute for rate */
295 spec->freq = (256000000L/(65536L - v->rate))/spec->channels;
296 /* An extended block must be followed by a data */
297 /* block to be valid so loop back to top so it */
298 /* can be grabed. */
299 continue;
300
301 case VOC_MARKER:
302 if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2)
303 return 0;
304
305 /* fallthrough */
306
307 default: /* text block or other krapola. */
308 for(i = 0; i < sblen; i++)
309 {
310 if (SDL_RWread(src, &trash, sizeof (Uint8), 1) != 1)
311 return 0;
312 }
313
314 if (block == VOC_TEXT)
315 continue; /* get next block */
316 }
317 }
318
319 return 1;
320 }
321
322
323 static Uint32 voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec)
324 {
325 Uint32 done = 0;
326 Uint8 silence = 0x80;
327
328 if (v->rest == 0)
329 {
330 if (!voc_get_block(src, v, spec))
331 return 0;
332 }
333
334 if (v->rest == 0)
335 return 0;
336
337 if (v->silent)
338 {
339 if (v->size == ST_SIZE_WORD)
340 silence = 0x00;
341
342 /* Fill in silence */
343 SDL_memset(buf, silence, v->rest);
344 done = v->rest;
345 v->rest = 0;
346 }
347
348 else
349 {
350 done = (Uint32)SDL_RWread(src, buf, 1, v->rest);
351 v->rest -= done;
352 if (v->size == ST_SIZE_WORD)
353 {
354 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
355 Uint16 *samples = (Uint16 *)buf;
356 for (; v->rest > 0; v->rest -= 2)
357 {
358 *samples = SDL_SwapLE16(*samples);
359 samples++;
360 }
361 #endif
362 done >>= 1;
363 }
364 }
365
366 return done;
367 } /* voc_read */
368
369
370 /* don't call this directly; use Mix_LoadWAV_RW() for now. */
371 SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
372 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
373 {
374 vs_t v;
375 int was_error = 1;
376 int samplesize;
377 Uint8 *fillptr;
378 void *ptr;
379
380 if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */
381 goto done;
382
383 if (!voc_check_header(src))
384 goto done;
385
386 v.rate = VOC_BAD_RATE;
387 v.rest = 0;
388 v.has_extended = 0;
389 *audio_buf = NULL;
390 *audio_len = 0;
391 SDL_memset(spec, '\0', sizeof (SDL_AudioSpec));
392
393 if (!voc_get_block(src, &v, spec))
394 goto done;
395
396 if (v.rate == VOC_BAD_RATE) {
397 SDL_SetError("VOC data had no sound!");
398 goto done;
399 }
400
401 spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8);
402 if (spec->channels == 0)
403 spec->channels = v.channels;
404
405 *audio_len = v.rest;
406 *audio_buf = SDL_malloc(v.rest);
407 if (*audio_buf == NULL)
408 goto done;
409
410 fillptr = *audio_buf;
411
412 while (voc_read(src, &v, fillptr, spec))
413 {
414 if (!voc_get_block(src, &v, spec))
415 goto done;
416
417 *audio_len += v.rest;
418 ptr = SDL_realloc(*audio_buf, *audio_len);
419 if (ptr == NULL)
420 {
421 SDL_free(*audio_buf);
422 *audio_buf = NULL;
423 *audio_len = 0;
424 goto done;
425 }
426
427 *audio_buf = ptr;
428 fillptr = ((Uint8 *) ptr) + (*audio_len - v.rest);
429 }
430
431 spec->samples = (Uint16)(*audio_len / v.size);
432
433 was_error = 0; /* success, baby! */
434
435 /* Don't return a buffer that isn't a multiple of samplesize */
436 samplesize = ((spec->format & 0xFF)/8)*spec->channels;
437 *audio_len &= (Uint32) ~(samplesize-1);
438
439 done:
440 if (freesrc && src) {
441 SDL_RWclose(src);
442 }
443
444 if (was_error) {
445 spec = NULL;
446 }
447
448 return(spec);
449 } /* Mix_LoadVOC_RW */
450
451 /* end of load_voc.c ... */
452
453 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode a Creative Labs VOC file into a
21 waveform. It's pretty straightforward once you get going. The only
22 externally-callable function is Mix_LoadVOC_RW(), which is meant to
23 act as identically to SDL_LoadWAV_RW() as possible.
24
25 This file by Ryan C. Gordon (icculus@icculus.org).
26
27 Heavily borrowed from sox v12.17.1's voc.c.
28 (http://www.freshmeat.net/projects/sox/)
29 */
30
31 /* Don't call this directly; use Mix_LoadWAV_RW() for now. */
32 SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
33 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
34
35 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* Functions to discard MP3 tags -
22 * written by O.Sezer <sezero@users.sourceforge.net>, put into public domain.
23 */
24
25 #include "SDL_stdinc.h"
26 #include "SDL_error.h"
27 #include "SDL_rwops.h"
28
29 #include "mp3utils.h"
30
31 #if defined(MUSIC_MP3_MAD) || defined(MUSIC_MP3_MPG123)
32
33 /*********************** SDL_RW WITH BOOKKEEPING ************************/
34
35 int MP3_RWinit(struct mp3file_t *fil, SDL_RWops *src) {
36 /* Don't use SDL_RWsize() here -- see SDL bug #5509 */
37 fil->src = src;
38 fil->start = SDL_RWtell(src);
39 fil->length = SDL_RWseek(src, 0, RW_SEEK_END) - fil->start;
40 fil->pos = 0;
41 if (fil->start < 0 || fil->length < 0) {
42 return SDL_Error(SDL_EFSEEK);
43 }
44 SDL_RWseek(src, fil->start, RW_SEEK_SET);
45 return 0;
46 }
47
48 size_t MP3_RWread(struct mp3file_t *fil, void *ptr, size_t size, size_t maxnum) {
49 size_t remaining = (size_t)(fil->length - fil->pos);
50 size_t ret;
51 maxnum *= size;
52 if (maxnum > remaining) maxnum = remaining;
53 ret = SDL_RWread(fil->src, ptr, 1, maxnum);
54 fil->pos += (Sint64)ret;
55 return ret;
56 }
57
58 Sint64 MP3_RWseek(struct mp3file_t *fil, Sint64 offset, int whence) {
59 Sint64 ret;
60 switch (whence) {
61 case RW_SEEK_CUR:
62 offset += fil->pos;
63 break;
64 case RW_SEEK_END:
65 offset += fil->length;
66 break;
67 }
68 if (offset < 0) return -1;
69 if (offset > fil->length)
70 offset = fil->length;
71 ret = SDL_RWseek(fil->src, fil->start + offset, RW_SEEK_SET);
72 if (ret < 0) return ret;
73 fil->pos = offset;
74 return offset;
75 }
76
77
78 /*************************** TAG HANDLING: ******************************/
79
80 static SDL_INLINE SDL_bool is_id3v1(const unsigned char *data, long length) {
81 /* http://id3.org/ID3v1 : 3 bytes "TAG" identifier and 125 bytes tag data */
82 if (length < 128 || SDL_memcmp(data,"TAG",3) != 0) {
83 return SDL_FALSE;
84 }
85 return SDL_TRUE;
86 }
87 static SDL_bool is_id3v2(const unsigned char *data, size_t length) {
88 /* ID3v2 header is 10 bytes: http://id3.org/id3v2.4.0-structure */
89 /* bytes 0-2: "ID3" identifier */
90 if (length < 10 || SDL_memcmp(data,"ID3",3) != 0) {
91 return SDL_FALSE;
92 }
93 /* bytes 3-4: version num (major,revision), each byte always less than 0xff. */
94 if (data[3] == 0xff || data[4] == 0xff) {
95 return SDL_FALSE;
96 }
97 /* bytes 6-9 are the ID3v2 tag size: a 32 bit 'synchsafe' integer, i.e. the
98 * highest bit 7 in each byte zeroed. i.e.: 7 bit information in each byte ->
99 * effectively a 28 bit value. */
100 if (data[6] >= 0x80 || data[7] >= 0x80 || data[8] >= 0x80 || data[9] >= 0x80) {
101 return SDL_FALSE;
102 }
103 return SDL_TRUE;
104 }
105 static long get_id3v2_len(const unsigned char *data, long length) {
106 /* size is a 'synchsafe' integer (see above) */
107 long size = (long)((data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9]);
108 size += 10; /* header size */
109 /* ID3v2 header[5] is flags (bits 4-7 only, 0-3 are zero).
110 * bit 4 set: footer is present (a copy of the header but
111 * with "3DI" as ident.) */
112 if (data[5] & 0x10) {
113 size += 10; /* footer size */
114 }
115 /* optional padding (always zeroes) */
116 while (size < length && data[size] == 0) {
117 ++size;
118 }
119 return size;
120 }
121 static SDL_bool is_apetag(const unsigned char *data, size_t length) {
122 /* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification
123 * Header/footer is 32 bytes: bytes 0-7 ident, bytes 8-11 version,
124 * bytes 12-17 size. bytes 24-31 are reserved: must be all zeroes. */
125 Uint32 v;
126
127 if (length < 32 || SDL_memcmp(data,"APETAGEX",8) != 0) {
128 return SDL_FALSE;
129 }
130 v = (Uint32)((data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]); /* version */
131 if (v != 2000U && v != 1000U) {
132 return SDL_FALSE;
133 }
134 v = 0; /* reserved bits : */
135 if (SDL_memcmp(&data[24],&v,4) != 0 || SDL_memcmp(&data[28],&v,4) != 0) {
136 return SDL_FALSE;
137 }
138 return SDL_TRUE;
139 }
140 static long get_ape_len(const unsigned char *data) {
141 Uint32 flags, version;
142 long size = (long)((data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12]);
143 version = (Uint32)((data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]);
144 flags = (Uint32)((data[23]<<24) | (data[22]<<16) | (data[21]<<8) | data[20]);
145 if (version == 2000U && (flags & (1U<<31))) size += 32; /* header present. */
146 return size;
147 }
148 static SDL_INLINE int is_lyrics3tag(const unsigned char *data, long length) {
149 /* http://id3.org/Lyrics3
150 * http://id3.org/Lyrics3v2 */
151 if (length < 15) return 0;
152 if (SDL_memcmp(data+6,"LYRICS200",9) == 0) return 2; /* v2 */
153 if (SDL_memcmp(data+6,"LYRICSEND",9) == 0) return 1; /* v1 */
154 return 0;
155 }
156 static long get_lyrics3v1_len(struct mp3file_t *m) {
157 const char *p; long i, len;
158 char buf[5104];
159 /* needs manual search: http://id3.org/Lyrics3 */
160 if (m->length < 20) return -1;
161 len = (m->length > 5109)? 5109 : (long)m->length;
162 MP3_RWseek(m, -len, RW_SEEK_END);
163 MP3_RWread(m, buf, 1, (len -= 9)); /* exclude footer */
164 /* strstr() won't work here. */
165 for (i = len - 11, p = buf; i >= 0; --i, ++p) {
166 if (SDL_memcmp(p, "LYRICSBEGIN", 11) == 0)
167 break;
168 }
169 if (i < 0) return -1;
170 return len - (long)(p - buf) + 9 /* footer */;
171 }
172 static SDL_INLINE long get_lyrics3v2_len(const unsigned char *data, long length) {
173 /* 6 bytes before the end marker is size in decimal format -
174 * does not include the 9 bytes end marker and size field. */
175 if (length != 6) return 0;
176 return SDL_strtol((const char *)data, NULL, 10) + 15;
177 }
178 static SDL_INLINE SDL_bool verify_lyrics3v2(const unsigned char *data, long length) {
179 if (length < 11) return SDL_FALSE;
180 if (SDL_memcmp(data,"LYRICSBEGIN",11) == 0) return SDL_TRUE;
181 return SDL_FALSE;
182 }
183 #define MMTAG_PARANOID
184 static SDL_bool is_musicmatch(const unsigned char *data, long length) {
185 /* From docs/musicmatch.txt in id3lib: https://sourceforge.net/projects/id3lib/
186 Overall tag structure:
187
188 +-----------------------------+
189 | Header |
190 | (256 bytes, OPTIONAL) |
191 +-----------------------------+
192 | Image extension (4 bytes) |
193 +-----------------------------+
194 | Image binary |
195 | (var. length >= 4 bytes) |
196 +-----------------------------+
197 | Unused (4 bytes) |
198 +-----------------------------+
199 | Version info (256 bytes) |
200 +-----------------------------+
201 | Audio meta-data |
202 | (var. length >= 7868 bytes) |
203 +-----------------------------+
204 | Data offsets (20 bytes) |
205 +-----------------------------+
206 | Footer (48 bytes) |
207 +-----------------------------+
208 */
209 if (length < 48) return SDL_FALSE;
210 /* sig: 19 bytes company name + 13 bytes space */
211 if (SDL_memcmp(data,"Brava Software Inc. ",32) != 0) {
212 return SDL_FALSE;
213 }
214 /* 4 bytes version: x.xx */
215 if (!SDL_isdigit(data[32]) || data[33] != '.' ||
216 !SDL_isdigit(data[34]) ||!SDL_isdigit(data[35])) {
217 return SDL_FALSE;
218 }
219 #ifdef MMTAG_PARANOID
220 /* [36..47]: 12 bytes trailing space */
221 for (length = 36; length < 48; ++length) {
222 if (data[length] != ' ') return SDL_FALSE;
223 }
224 #endif
225 return SDL_TRUE;
226 }
227 static long get_musicmatch_len(struct mp3file_t *m) {
228 const Sint32 metasizes[4] = { 7868, 7936, 8004, 8132 };
229 const unsigned char syncstr[10] = {'1','8','2','7','3','6','4','5',0,0};
230 unsigned char buf[256];
231 Sint32 i, j, imgext_ofs, version_ofs;
232 long len;
233
234 MP3_RWseek(m, -68, RW_SEEK_END);
235 MP3_RWread(m, buf, 1, 20);
236 imgext_ofs = (Sint32)((buf[3] <<24) | (buf[2] <<16) | (buf[1] <<8) | buf[0] );
237 version_ofs = (Sint32)((buf[15]<<24) | (buf[14]<<16) | (buf[13]<<8) | buf[12]);
238 if (version_ofs <= imgext_ofs) return -1;
239 if (version_ofs <= 0 || imgext_ofs <= 0) return -1;
240 /* Try finding the version info section:
241 * Because metadata section comes after it, and because metadata section
242 * has different sizes across versions (format ver. <= 3.00: always 7868
243 * bytes), we can _not_ directly calculate using deltas from the offsets
244 * section. */
245 for (i = 0; i < 4; ++i) {
246 /* 48: footer, 20: offsets, 256: version info */
247 len = metasizes[i] + 48 + 20 + 256;
248 if (m->length < len) return -1;
249 MP3_RWseek(m, -len, RW_SEEK_END);
250 MP3_RWread(m, buf, 1, 256);
251 /* [0..9]: sync string, [30..255]: 0x20 */
252 #ifdef MMTAG_PARANOID
253 for (j = 30; j < 256; ++j) {
254 if (buf[j] != ' ') break;
255 }
256 if (j < 256) continue;
257 #endif
258 if (SDL_memcmp(buf, syncstr, 10) == 0) {
259 break;
260 }
261 }
262 if (i == 4) return -1; /* no luck. */
263 #ifdef MMTAG_PARANOID
264 /* unused section: (4 bytes of 0x00) */
265 MP3_RWseek(m, -(len + 4), RW_SEEK_END);
266 MP3_RWread(m, buf, 1, 4); j = 0;
267 if (SDL_memcmp(buf, &j, 4) != 0) return -1;
268 #endif
269 len += (version_ofs - imgext_ofs);
270 if (m->length < len) return -1;
271 MP3_RWseek(m, -len, RW_SEEK_END);
272 MP3_RWread(m, buf, 1, 8);
273 j = (Sint32)((buf[7] <<24) | (buf[6] <<16) | (buf[5] <<8) | buf[4]);
274 if (j < 0) return -1;
275 /* verify image size: */
276 /* without this, we may land at a wrong place. */
277 if (j + 12 != version_ofs - imgext_ofs) return -1;
278 /* try finding the optional header */
279 if (m->length < len + 256) return len;
280 MP3_RWseek(m, -(len + 256), RW_SEEK_END);
281 MP3_RWread(m, buf, 1, 256);
282 /* [0..9]: sync string, [30..255]: 0x20 */
283 if (SDL_memcmp(buf, syncstr, 10) != 0) {
284 return len;
285 }
286 #ifdef MMTAG_PARANOID
287 for (j = 30; j < 256; ++j) {
288 if (buf[j] != ' ') return len;
289 }
290 #endif
291 return len + 256; /* header is present. */
292 }
293
294 static int probe_id3v1(struct mp3file_t *fil, unsigned char *buf, int atend) {
295 if (fil->length >= 128) {
296 MP3_RWseek(fil, -128, RW_SEEK_END);
297 if (MP3_RWread(fil, buf, 1, 128) != 128)
298 return -1;
299 if (is_id3v1(buf, 128)) {
300 if (!atend) { /* possible false positive? */
301 if (is_musicmatch(buf + 128 - 48, 48) ||
302 is_apetag (buf + 128 - 32, 32) ||
303 is_lyrics3tag(buf + 128 - 15, 15)) {
304 return 0;
305 }
306 }
307 fil->length -= 128;
308 return 1;
309 /* FIXME: handle possible double-ID3v1 tags?? */
310 }
311 }
312 return 0;
313 }
314 static int probe_mmtag(struct mp3file_t *fil, unsigned char *buf) {
315 long len;
316 if (fil->length >= 68) {
317 MP3_RWseek(fil, -48, RW_SEEK_END);
318 if (MP3_RWread(fil, buf, 1, 48) != 48)
319 return -1;
320 if (is_musicmatch(buf, 48)) {
321 len = get_musicmatch_len(fil);
322 if (len < 0) return -1;
323 if (len >= fil->length) return -1;
324 fil->length -= len;
325 return 1;
326 }
327 }
328 return 0;
329 }
330 static int probe_apetag(struct mp3file_t *fil, unsigned char *buf) {
331 long len;
332 if (fil->length >= 32) {
333 MP3_RWseek(fil, -32, RW_SEEK_END);
334 if (MP3_RWread(fil, buf, 1, 32) != 32)
335 return -1;
336 if (is_apetag(buf, 32)) {
337 len = get_ape_len(buf);
338 if (len >= fil->length) return -1;
339 fil->length -= len;
340 return 1;
341 }
342 }
343 return 0;
344 }
345 static int probe_lyrics3(struct mp3file_t *fil, unsigned char *buf) {
346 long len;
347 if (fil->length >= 15) {
348 MP3_RWseek(fil, -15, RW_SEEK_END);
349 if (MP3_RWread(fil, buf, 1, 15) != 15)
350 return -1;
351 len = is_lyrics3tag(buf, 15);
352 if (len == 2) {
353 len = get_lyrics3v2_len(buf, 6);
354 if (len >= fil->length) return -1;
355 if (len < 15) return -1;
356 MP3_RWseek(fil, -len, RW_SEEK_END);
357 if (MP3_RWread(fil, buf, 1, 11) != 11)
358 return -1;
359 if (!verify_lyrics3v2(buf, 11)) return -1;
360 fil->length -= len;
361 return 1;
362 }
363 else if (len == 1) {
364 len = get_lyrics3v1_len(fil);
365 if (len < 0) return -1;
366 fil->length -= len;
367 return 1;
368 }
369 }
370 return 0;
371 }
372
373 int mp3_skiptags(struct mp3file_t *fil, SDL_bool keep_id3v2)
374 {
375 unsigned char buf[128];
376 long len; size_t readsize;
377 int c_id3, c_ape, c_lyr, c_mm;
378 int rc = -1;
379
380 /* MP3 standard has no metadata format, so everyone invented
381 * their own thing, even with extensions, until ID3v2 became
382 * dominant: Hence the impossible mess here.
383 *
384 * Note: I don't yet care about freaky broken mp3 files with
385 * double tags. -- O.S.
386 */
387
388 readsize = MP3_RWread(fil, buf, 1, 128);
389 if (!readsize) goto fail;
390
391 /* ID3v2 tag is at the start */
392 if (is_id3v2(buf, readsize)) {
393 len = get_id3v2_len(buf, (long)readsize);
394 if (len >= fil->length) goto fail;
395 if (!keep_id3v2) {
396 fil->start += len;
397 fil->length -= len;
398 }
399 }
400 /* APE tag _might_ be at the start (discouraged
401 * but not forbidden, either.) read the header. */
402 else if (is_apetag(buf, readsize)) {
403 len = get_ape_len(buf);
404 if (len >= fil->length) goto fail;
405 fil->start += len;
406 fil->length -= len;
407 }
408
409 /* it's not impossible that _old_ MusicMatch tag
410 * placing itself after ID3v1. */
411 if ((c_mm = probe_mmtag(fil, buf)) < 0) {
412 goto fail;
413 }
414 /* ID3v1 tag is at the end */
415 if ((c_id3 = probe_id3v1(fil, buf, !c_mm)) < 0) {
416 goto fail;
417 }
418 /* we do not know the order of ape or lyrics3
419 * or musicmatch tags, hence the loop here.. */
420 c_ape = 0;
421 c_lyr = 0;
422 for (;;) {
423 if (!c_lyr) {
424 /* care about mp3s with double Lyrics3 tags? */
425 if ((c_lyr = probe_lyrics3(fil, buf)) < 0)
426 goto fail;
427 if (c_lyr) continue;
428 }
429 if (!c_mm) {
430 if ((c_mm = probe_mmtag(fil, buf)) < 0)
431 goto fail;
432 if (c_mm) continue;
433 }
434 if (!c_ape) {
435 if ((c_ape = probe_apetag(fil, buf)) < 0)
436 goto fail;
437 if (c_ape) continue;
438 }
439 break;
440 } /* for (;;) */
441
442 rc = (fil->length > 0)? 0 : -1;
443 fail:
444 MP3_RWseek(fil, 0, RW_SEEK_SET);
445 return rc;
446 }
447 #endif /* MUSIC_MP3_??? */
448
449 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef MIX_MP3UTILS_H
22 #define MIX_MP3UTILS_H
23
24 struct mp3file_t {
25 SDL_RWops *src;
26 Sint64 start, length, pos;
27 };
28
29 extern int mp3_skiptags(struct mp3file_t *fil, SDL_bool keep_id3v2);
30 extern int MP3_RWinit(struct mp3file_t *fil, SDL_RWops *src);
31 extern size_t MP3_RWread(struct mp3file_t *fil, void *ptr, size_t size, size_t maxnum);
32 extern Sint64 MP3_RWseek(struct mp3file_t *fil, Sint64 offset, int whence);
33
34 #endif /* MIX_MP3UTILS_H */
35
36 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 /* This file supports an external command for playing music */
23
24 #ifdef MUSIC_CMD
25
26 #ifdef __APPLE__
27 #define _DARWIN_C_SOURCE
28 #endif
29
30 #include <sys/types.h>
31 #include <sys/wait.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 #include <string.h>
36 #include <signal.h>
37 #include <ctype.h>
38 #include <limits.h>
39 #if defined(__linux__) && defined(__arm__)
40 # include <linux/limits.h>
41 #endif
42
43 #include "music_cmd.h"
44
45
46 typedef struct {
47 char *file;
48 char *cmd;
49 pid_t pid;
50 int play_count;
51 } MusicCMD;
52
53
54 /* Load a music stream from the given file */
55 static void *MusicCMD_CreateFromFile(const char *file)
56 {
57 MusicCMD *music;
58
59 if (!music_cmd) {
60 Mix_SetError("You must call Mix_SetMusicCMD() first");
61 return NULL;
62 }
63
64 /* Allocate and fill the music structure */
65 music = (MusicCMD *)SDL_calloc(1, sizeof *music);
66 if (music == NULL) {
67 Mix_SetError("Out of memory");
68 return NULL;
69 }
70 music->file = SDL_strdup(file);
71 music->cmd = SDL_strdup(music_cmd);
72 music->pid = 0;
73
74 /* We're done */
75 return music;
76 }
77
78 /* Parse a command line buffer into arguments */
79 static int ParseCommandLine(char *cmdline, char **argv)
80 {
81 char *bufp;
82 int argc;
83
84 argc = 0;
85 for (bufp = cmdline; *bufp;) {
86 /* Skip leading whitespace */
87 while (isspace(*bufp)) {
88 ++bufp;
89 }
90 /* Skip over argument */
91 if (*bufp == '"') {
92 ++bufp;
93 if (*bufp) {
94 if (argv) {
95 argv[argc] = bufp;
96 }
97 ++argc;
98 }
99 /* Skip over word */
100 while (*bufp && (*bufp != '"')) {
101 ++bufp;
102 }
103 } else {
104 if (*bufp) {
105 if (argv) {
106 argv[argc] = bufp;
107 }
108 ++argc;
109 }
110 /* Skip over word */
111 while (*bufp && ! isspace(*bufp)) {
112 ++bufp;
113 }
114 }
115 if (*bufp) {
116 if (argv) {
117 *bufp = '\0';
118 }
119 ++bufp;
120 }
121 }
122 if (argv) {
123 argv[argc] = NULL;
124 }
125 return(argc);
126 }
127
128 static char **parse_args(char *command, char *last_arg)
129 {
130 int argc;
131 char **argv;
132
133 /* Parse the command line */
134 argc = ParseCommandLine(command, NULL);
135 if (last_arg) {
136 ++argc;
137 }
138 argv = (char **)SDL_malloc((argc+1)*(sizeof *argv));
139 if (argv == NULL) {
140 return(NULL);
141 }
142 argc = ParseCommandLine(command, argv);
143
144 /* Add last command line argument */
145 if (last_arg) {
146 argv[argc++] = last_arg;
147 }
148 argv[argc] = NULL;
149
150 /* We're ready! */
151 return(argv);
152 }
153
154 /* Start playback of a given music stream */
155 static int MusicCMD_Play(void *context, int play_count)
156 {
157 MusicCMD *music = (MusicCMD *)context;
158
159 music->play_count = play_count;
160 #ifdef HAVE_FORK
161 music->pid = fork();
162 #else
163 music->pid = vfork();
164 #endif
165 switch(music->pid) {
166 /* Failed fork() system call */
167 case -1:
168 Mix_SetError("fork() failed");
169 return -1;
170
171 /* Child process - executes here */
172 case 0: {
173 char **argv;
174
175 /* Unblock signals in case we're called from a thread */
176 {
177 sigset_t mask;
178 sigemptyset(&mask);
179 sigprocmask(SIG_SETMASK, &mask, NULL);
180 }
181
182 /* Execute the command */
183 argv = parse_args(music->cmd, music->file);
184 if (argv != NULL) {
185 execvp(argv[0], argv);
186
187 /* exec() failed */
188 perror(argv[0]);
189 }
190 _exit(-1);
191 }
192 break;
193
194 /* Parent process - executes here */
195 default:
196 break;
197 }
198 return 0;
199 }
200
201 /* Return non-zero if a stream is currently playing */
202 static SDL_bool MusicCMD_IsPlaying(void *context)
203 {
204 MusicCMD *music = (MusicCMD *)context;
205 int status;
206
207 if (music->pid > 0) {
208 waitpid(music->pid, &status, WNOHANG);
209 if (kill(music->pid, 0) == 0) {
210 return SDL_TRUE;
211 }
212
213 /* We might want to loop */
214 if (music->play_count != 1) {
215 int play_count = -1;
216 if (music->play_count > 0) {
217 play_count = (music->play_count - 1);
218 }
219 MusicCMD_Play(music, play_count);
220 return SDL_TRUE;
221 }
222 }
223 return SDL_FALSE;
224 }
225
226 /* Pause playback of a given music stream */
227 static void MusicCMD_Pause(void *context)
228 {
229 MusicCMD *music = (MusicCMD *)context;
230 if (music->pid > 0) {
231 kill(music->pid, SIGSTOP);
232 }
233 }
234
235 /* Resume playback of a given music stream */
236 static void MusicCMD_Resume(void *context)
237 {
238 MusicCMD *music = (MusicCMD *)context;
239 if (music->pid > 0) {
240 kill(music->pid, SIGCONT);
241 }
242 }
243
244 /* Stop playback of a stream previously started with MusicCMD_Start() */
245 static void MusicCMD_Stop(void *context)
246 {
247 MusicCMD *music = (MusicCMD *)context;
248 int status;
249
250 if (music->pid > 0) {
251 while (kill(music->pid, 0) == 0) {
252 kill(music->pid, SIGTERM);
253 sleep(1);
254 waitpid(music->pid, &status, WNOHANG);
255 }
256 music->pid = 0;
257 }
258 }
259
260 /* Close the given music stream */
261 void MusicCMD_Delete(void *context)
262 {
263 MusicCMD *music = (MusicCMD *)context;
264 SDL_free(music->file);
265 SDL_free(music);
266 }
267
268 Mix_MusicInterface Mix_MusicInterface_CMD =
269 {
270 "CMD",
271 MIX_MUSIC_CMD,
272 MUS_CMD,
273 SDL_FALSE,
274 SDL_FALSE,
275
276 NULL, /* Load */
277 NULL, /* Open */
278 NULL, /* CreateFromRW */
279 MusicCMD_CreateFromFile,
280 NULL, /* SetVolume */
281 NULL, /* GetVolume */
282 MusicCMD_Play,
283 MusicCMD_IsPlaying,
284 NULL, /* GetAudio */
285 NULL, /* Jump */
286 NULL, /* Seek */
287 NULL, /* Tell */
288 NULL, /* Duration */
289 NULL, /* LoopStart */
290 NULL, /* LoopEnd */
291 NULL, /* LoopLength */
292 NULL, /* GetMetaTag */
293 MusicCMD_Pause,
294 MusicCMD_Resume,
295 MusicCMD_Stop,
296 MusicCMD_Delete,
297 NULL, /* Close */
298 NULL /* Unload */
299 };
300
301 #endif /* MUSIC_CMD */
302
303 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports an external command for playing music */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_CMD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file is used to support SDL_LoadMUS playback of FLAC files.
21 ~ Austen Dicken (admin@cvpcs.org)
22 */
23
24 #ifdef MUSIC_FLAC
25
26 #include "SDL_loadso.h"
27 #include "SDL_assert.h"
28
29 #include "music_flac.h"
30 #include "utils.h"
31
32 #include <FLAC/stream_decoder.h>
33
34
35 typedef struct {
36 int loaded;
37 void *handle;
38 FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(void);
39 void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder);
40 FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)(
41 FLAC__StreamDecoder *decoder,
42 FLAC__StreamDecoderReadCallback read_callback,
43 FLAC__StreamDecoderSeekCallback seek_callback,
44 FLAC__StreamDecoderTellCallback tell_callback,
45 FLAC__StreamDecoderLengthCallback length_callback,
46 FLAC__StreamDecoderEofCallback eof_callback,
47 FLAC__StreamDecoderWriteCallback write_callback,
48 FLAC__StreamDecoderMetadataCallback metadata_callback,
49 FLAC__StreamDecoderErrorCallback error_callback,
50 void *client_data);
51 FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder);
52 FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder);
53 FLAC__bool (*FLAC__stream_decoder_process_single)(
54 FLAC__StreamDecoder *decoder);
55 FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)(
56 FLAC__StreamDecoder *decoder);
57 FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)(
58 FLAC__StreamDecoder *decoder);
59 FLAC__bool (*FLAC__stream_decoder_seek_absolute)(
60 FLAC__StreamDecoder *decoder,
61 FLAC__uint64 sample);
62 FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)(
63 const FLAC__StreamDecoder *decoder);
64 FLAC__uint64 (*FLAC__stream_decoder_get_total_samples)(
65 const FLAC__StreamDecoder *decoder);
66 FLAC__bool (*FLAC__stream_decoder_set_metadata_respond)(
67 FLAC__StreamDecoder *decoder,
68 FLAC__MetadataType type);
69 } flac_loader;
70
71 static flac_loader flac = {
72 0, NULL
73 };
74
75 #ifdef FLAC_DYNAMIC
76 #define FUNCTION_LOADER(FUNC, SIG) \
77 flac.FUNC = (SIG) SDL_LoadFunction(flac.handle, #FUNC); \
78 if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; }
79 #else
80 #define FUNCTION_LOADER(FUNC, SIG) \
81 flac.FUNC = FUNC;
82 #endif
83
84 static int FLAC_Load(void)
85 {
86 if (flac.loaded == 0) {
87 #ifdef FLAC_DYNAMIC
88 flac.handle = SDL_LoadObject(FLAC_DYNAMIC);
89 if (flac.handle == NULL) {
90 return -1;
91 }
92 #elif defined(__MACOSX__)
93 extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import));
94 if (FLAC__stream_decoder_new == NULL)
95 {
96 /* Missing weakly linked framework */
97 Mix_SetError("Missing FLAC.framework");
98 return -1;
99 }
100 #endif
101
102 FUNCTION_LOADER(FLAC__stream_decoder_new, FLAC__StreamDecoder *(*)(void))
103 FUNCTION_LOADER(FLAC__stream_decoder_delete, void (*)(FLAC__StreamDecoder *))
104 FUNCTION_LOADER(FLAC__stream_decoder_init_stream, FLAC__StreamDecoderInitStatus (*)(
105 FLAC__StreamDecoder *,
106 FLAC__StreamDecoderReadCallback,
107 FLAC__StreamDecoderSeekCallback,
108 FLAC__StreamDecoderTellCallback,
109 FLAC__StreamDecoderLengthCallback,
110 FLAC__StreamDecoderEofCallback,
111 FLAC__StreamDecoderWriteCallback,
112 FLAC__StreamDecoderMetadataCallback,
113 FLAC__StreamDecoderErrorCallback,
114 void *))
115 FUNCTION_LOADER(FLAC__stream_decoder_finish, FLAC__bool (*)(FLAC__StreamDecoder *))
116 FUNCTION_LOADER(FLAC__stream_decoder_flush, FLAC__bool (*)(FLAC__StreamDecoder *))
117 FUNCTION_LOADER(FLAC__stream_decoder_process_single, FLAC__bool (*)(FLAC__StreamDecoder *))
118 FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_metadata, FLAC__bool (*)(FLAC__StreamDecoder *))
119 FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_stream, FLAC__bool (*)(FLAC__StreamDecoder *))
120 FUNCTION_LOADER(FLAC__stream_decoder_seek_absolute, FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64))
121 FUNCTION_LOADER(FLAC__stream_decoder_get_state, FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder))
122 FUNCTION_LOADER(FLAC__stream_decoder_get_total_samples,
123 FLAC__uint64 (*)(const FLAC__StreamDecoder *))
124 FUNCTION_LOADER(FLAC__stream_decoder_set_metadata_respond,
125 FLAC__bool (*)(FLAC__StreamDecoder *,
126 FLAC__MetadataType))
127 }
128 ++flac.loaded;
129
130 return 0;
131 }
132
133 static void FLAC_Unload(void)
134 {
135 if (flac.loaded == 0) {
136 return;
137 }
138 if (flac.loaded == 1) {
139 #ifdef FLAC_DYNAMIC
140 SDL_UnloadObject(flac.handle);
141 #endif
142 }
143 --flac.loaded;
144 }
145
146
147 typedef struct {
148 int volume;
149 int play_count;
150 FLAC__StreamDecoder *flac_decoder;
151 unsigned sample_rate;
152 unsigned channels;
153 unsigned bits_per_sample;
154 SDL_RWops *src;
155 int freesrc;
156 SDL_AudioStream *stream;
157 int loop;
158 FLAC__int64 pcm_pos;
159 FLAC__int64 full_length;
160 SDL_bool loop_flag;
161 FLAC__int64 loop_start;
162 FLAC__int64 loop_end;
163 FLAC__int64 loop_len;
164 Mix_MusicMetaTags tags;
165 } FLAC_Music;
166
167
168 static int FLAC_Seek(void *context, double position);
169
170 static FLAC__StreamDecoderReadStatus flac_read_music_cb(
171 const FLAC__StreamDecoder *decoder,
172 FLAC__byte buffer[],
173 size_t *bytes,
174 void *client_data)
175 {
176 FLAC_Music *data = (FLAC_Music*)client_data;
177
178 (void)decoder;
179
180 /* make sure there is something to be reading */
181 if (*bytes > 0) {
182 *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes);
183
184 if (*bytes == 0) { /* error or no data was read (EOF) */
185 return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
186 } else { /* data was read, continue */
187 return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
188 }
189 } else {
190 return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
191 }
192 }
193
194 static FLAC__StreamDecoderSeekStatus flac_seek_music_cb(
195 const FLAC__StreamDecoder *decoder,
196 FLAC__uint64 absolute_byte_offset,
197 void *client_data)
198 {
199 FLAC_Music *data = (FLAC_Music*)client_data;
200
201 (void)decoder;
202
203 if (SDL_RWseek(data->src, (Sint64)absolute_byte_offset, RW_SEEK_SET) < 0) {
204 return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
205 } else {
206 return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
207 }
208 }
209
210 static FLAC__StreamDecoderTellStatus flac_tell_music_cb(
211 const FLAC__StreamDecoder *decoder,
212 FLAC__uint64 *absolute_byte_offset,
213 void *client_data)
214 {
215 FLAC_Music *data = (FLAC_Music*)client_data;
216
217 Sint64 pos = SDL_RWtell(data->src);
218
219 (void)decoder;
220
221 if (pos < 0) {
222 return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
223 } else {
224 *absolute_byte_offset = (FLAC__uint64)pos;
225 return FLAC__STREAM_DECODER_TELL_STATUS_OK;
226 }
227 }
228
229 static FLAC__StreamDecoderLengthStatus flac_length_music_cb(
230 const FLAC__StreamDecoder *decoder,
231 FLAC__uint64 *stream_length,
232 void *client_data)
233 {
234 FLAC_Music *data = (FLAC_Music*)client_data;
235
236 Sint64 pos = SDL_RWtell(data->src);
237 Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END);
238
239 (void)decoder;
240
241 if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) {
242 /* there was an error attempting to return the stream to the original
243 * position, or the length was invalid. */
244 return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
245 } else {
246 *stream_length = (FLAC__uint64)length;
247 return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
248 }
249 }
250
251 static FLAC__bool flac_eof_music_cb(
252 const FLAC__StreamDecoder *decoder,
253 void *client_data)
254 {
255 FLAC_Music *data = (FLAC_Music*)client_data;
256
257 Sint64 pos = SDL_RWtell(data->src);
258 Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END);
259
260 (void)decoder;
261
262 /* was the original position equal to the end (a.k.a. the seek didn't move)? */
263 if (pos == end) {
264 /* must be EOF */
265 return true;
266 } else {
267 /* not EOF, return to the original position */
268 SDL_RWseek(data->src, pos, RW_SEEK_SET);
269 return false;
270 }
271 }
272
273 static FLAC__StreamDecoderWriteStatus flac_write_music_cb(
274 const FLAC__StreamDecoder *decoder,
275 const FLAC__Frame *frame,
276 const FLAC__int32 *const buffer[],
277 void *client_data)
278 {
279 FLAC_Music *music = (FLAC_Music *)client_data;
280 Sint16 *data;
281 unsigned int i, j, channels;
282 int shift_amount = 0, amount;
283
284 (void)decoder;
285
286 if (!music->stream) {
287 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
288 }
289
290 switch (music->bits_per_sample) {
291 case 16:
292 shift_amount = 0;
293 break;
294 case 20:
295 shift_amount = 4;
296 break;
297 case 24:
298 shift_amount = 8;
299 break;
300 default:
301 SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample);
302 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
303 }
304
305 if (music->channels == 3) {
306 /* We'll just drop the center channel for now */
307 channels = 2;
308 } else {
309 channels = music->channels;
310 }
311
312 data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels));
313 if (!data) {
314 SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data)));
315 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
316 }
317 if (music->channels == 3) {
318 Sint16 *dst = data;
319 for (i = 0; i < frame->header.blocksize; ++i) {
320 Sint16 FL = (Sint16)(buffer[0][i] >> shift_amount);
321 Sint16 FR = (Sint16)(buffer[1][i] >> shift_amount);
322 Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f);
323 int sample;
324
325 sample = (FL + FCmix);
326 if (sample > SDL_MAX_SINT16) {
327 *dst = SDL_MAX_SINT16;
328 } else if (sample < SDL_MIN_SINT16) {
329 *dst = SDL_MIN_SINT16;
330 } else {
331 *dst = (Sint16)sample;
332 }
333 ++dst;
334
335 sample = (FR + FCmix);
336 if (sample > SDL_MAX_SINT16) {
337 *dst = SDL_MAX_SINT16;
338 } else if (sample < SDL_MIN_SINT16) {
339 *dst = SDL_MIN_SINT16;
340 } else {
341 *dst = (Sint16)sample;
342 }
343 ++dst;
344 }
345 } else {
346 for (i = 0; i < channels; ++i) {
347 Sint16 *dst = data + i;
348 for (j = 0; j < frame->header.blocksize; ++j) {
349 *dst = (Sint16)(buffer[i][j] >> shift_amount);
350 dst += channels;
351 }
352 }
353 }
354 amount = (int)(frame->header.blocksize * channels * sizeof(*data));
355 music->pcm_pos += (FLAC__int64) frame->header.blocksize;
356 if (music->loop && (music->play_count != 1) &&
357 (music->pcm_pos >= music->loop_end)) {
358 amount -= (music->pcm_pos - music->loop_end) * channels * (int)sizeof(*data);
359 music->loop_flag = SDL_TRUE;
360 }
361
362 SDL_AudioStreamPut(music->stream, data, amount);
363 SDL_stack_free(data);
364
365 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
366 }
367
368 static void flac_metadata_music_cb(
369 const FLAC__StreamDecoder *decoder,
370 const FLAC__StreamMetadata *metadata,
371 void *client_data)
372 {
373 FLAC_Music *music = (FLAC_Music *)client_data;
374 const FLAC__StreamMetadata_VorbisComment *vc;
375 int channels;
376 unsigned rate;
377 char *param, *argument, *value;
378 SDL_bool is_loop_length = SDL_FALSE;
379
380 (void)decoder;
381
382 if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
383 music->sample_rate = metadata->data.stream_info.sample_rate;
384 music->channels = metadata->data.stream_info.channels;
385 music->bits_per_sample = metadata->data.stream_info.bits_per_sample;
386 /*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/
387
388 /* SDL's channel mapping and FLAC channel mapping are the same,
389 except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC
390 */
391 if (music->channels == 3) {
392 channels = 2;
393 } else {
394 channels = (int)music->channels;
395 }
396
397 /* We check for NULL stream later when we get data */
398 SDL_assert(!music->stream);
399 music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)channels, (int)music->sample_rate,
400 music_spec.format, music_spec.channels, music_spec.freq);
401 } else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
402 FLAC__uint32 i;
403
404 vc = &metadata->data.vorbis_comment;
405 rate = music->sample_rate;
406
407 for (i = 0; i < vc->num_comments; ++i) {
408 param = SDL_strdup((const char *) vc->comments[i].entry);
409 argument = param;
410 value = SDL_strchr(param, '=');
411
412 if (value == NULL) {
413 value = param + SDL_strlen(param);
414 } else {
415 *(value++) = '\0';
416 }
417
418 /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from
419 * string if it is present at position 4. */
420 if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) {
421 SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4);
422 }
423
424 if (SDL_strcasecmp(argument, "LOOPSTART") == 0)
425 music->loop_start = _Mix_ParseTime(value, rate);
426 else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) {
427 music->loop_len = SDL_strtoll(value, NULL, 10);
428 is_loop_length = SDL_TRUE;
429 } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
430 music->loop_end = _Mix_ParseTime(value, rate);
431 is_loop_length = SDL_FALSE;
432 } else if (SDL_strcasecmp(argument, "TITLE") == 0) {
433 meta_tags_set(&music->tags, MIX_META_TITLE, value);
434 } else if (SDL_strcasecmp(argument, "ARTIST") == 0) {
435 meta_tags_set(&music->tags, MIX_META_ARTIST, value);
436 } else if (SDL_strcasecmp(argument, "ALBUM") == 0) {
437 meta_tags_set(&music->tags, MIX_META_ALBUM, value);
438 } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) {
439 meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value);
440 }
441 SDL_free(param);
442 }
443
444 if (is_loop_length) {
445 music->loop_end = music->loop_start + music->loop_len;
446 } else {
447 music->loop_len = music->loop_end - music->loop_start;
448 }
449
450 /* Ignore invalid loop tag */
451 if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) {
452 music->loop_start = 0;
453 music->loop_len = 0;
454 music->loop_end = 0;
455 }
456 }
457 }
458
459 static void flac_error_music_cb(
460 const FLAC__StreamDecoder *decoder,
461 FLAC__StreamDecoderErrorStatus status,
462 void *client_data)
463 {
464 (void)decoder;
465 (void)client_data;
466
467 /* print an SDL error based on the error status */
468 switch (status) {
469 case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
470 SDL_SetError("Error processing the FLAC file [LOST_SYNC].");
471 break;
472 case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
473 SDL_SetError("Error processing the FLAC file [BAD_HEADER].");
474 break;
475 case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
476 SDL_SetError("Error processing the FLAC file [CRC_MISMATCH].");
477 break;
478 case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM:
479 SDL_SetError("Error processing the FLAC file [UNPARSEABLE].");
480 break;
481 default:
482 SDL_SetError("Error processing the FLAC file [UNKNOWN].");
483 break;
484 }
485 }
486
487 /* Load an FLAC stream from an SDL_RWops object */
488 static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc)
489 {
490 FLAC_Music *music;
491 int init_stage = 0;
492 int was_error = 1;
493 FLAC__int64 full_length;
494
495 music = (FLAC_Music *)SDL_calloc(1, sizeof(*music));
496 if (!music) {
497 SDL_OutOfMemory();
498 return NULL;
499 }
500 music->src = src;
501 music->volume = MIX_MAX_VOLUME;
502
503 music->flac_decoder = flac.FLAC__stream_decoder_new();
504 if (music->flac_decoder) {
505 init_stage++; /* stage 1! */
506 flac.FLAC__stream_decoder_set_metadata_respond(music->flac_decoder,
507 FLAC__METADATA_TYPE_VORBIS_COMMENT);
508
509 if (flac.FLAC__stream_decoder_init_stream(
510 music->flac_decoder,
511 flac_read_music_cb, flac_seek_music_cb,
512 flac_tell_music_cb, flac_length_music_cb,
513 flac_eof_music_cb, flac_write_music_cb,
514 flac_metadata_music_cb, flac_error_music_cb,
515 music) == FLAC__STREAM_DECODER_INIT_STATUS_OK) {
516 init_stage++; /* stage 2! */
517
518 if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) {
519 was_error = 0;
520 } else {
521 SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed");
522 }
523 } else {
524 SDL_SetError("FLAC__stream_decoder_init_stream() failed");
525 }
526 } else {
527 SDL_SetError("FLAC__stream_decoder_new() failed");
528 }
529
530 if (was_error) {
531 switch (init_stage) {
532 case 2:
533 flac.FLAC__stream_decoder_finish(music->flac_decoder); /* fallthrough */
534 case 1:
535 flac.FLAC__stream_decoder_delete(music->flac_decoder); /* fallthrough */
536 case 0:
537 SDL_free(music);
538 break;
539 }
540 return NULL;
541 }
542
543 /* loop_start, loop_end and loop_len get set by metadata callback if tags
544 * are present in metadata.
545 */
546 full_length = (FLAC__int64) flac.FLAC__stream_decoder_get_total_samples(music->flac_decoder);
547 if ((music->loop_end > 0) && (music->loop_end <= full_length) &&
548 (music->loop_start < music->loop_end)) {
549 music->loop = 1;
550 }
551
552 music->full_length = full_length;
553 music->freesrc = freesrc;
554 return music;
555 }
556
557 static const char* FLAC_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
558 {
559 FLAC_Music *music = (FLAC_Music *)context;
560 return meta_tags_get(&music->tags, tag_type);
561 }
562
563
564 /* Set the volume for an FLAC stream */
565 static void FLAC_SetVolume(void *context, int volume)
566 {
567 FLAC_Music *music = (FLAC_Music *)context;
568 music->volume = volume;
569 }
570
571 /* Get the volume for an FLAC stream */
572 static int FLAC_GetVolume(void *context)
573 {
574 FLAC_Music *music = (FLAC_Music *)context;
575 return music->volume;
576 }
577
578 /* Start playback of a given FLAC stream */
579 static int FLAC_Play(void *context, int play_count)
580 {
581 FLAC_Music *music = (FLAC_Music *)context;
582 music->play_count = play_count;
583 return FLAC_Seek(music, 0.0);
584 }
585
586 /* Read some FLAC stream data and convert it for output */
587 static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
588 {
589 FLAC_Music *music = (FLAC_Music *)context;
590 int filled;
591
592 filled = SDL_AudioStreamGet(music->stream, data, bytes);
593 if (filled != 0) {
594 return filled;
595 }
596
597 if (!music->play_count) {
598 /* All done */
599 *done = SDL_TRUE;
600 return 0;
601 }
602
603 if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) {
604 SDL_SetError("FLAC__stream_decoder_process_single() failed");
605 return -1;
606 }
607
608 if (music->loop_flag) {
609 music->pcm_pos = music->loop_start;
610 if (flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)music->loop_start) ==
611 FLAC__STREAM_DECODER_SEEK_ERROR) {
612 SDL_SetError("FLAC__stream_decoder_seek_absolute() failed");
613 flac.FLAC__stream_decoder_flush(music->flac_decoder);
614 return -1;
615 } else {
616 int play_count = -1;
617 if (music->play_count > 0) {
618 play_count = (music->play_count - 1);
619 }
620 music->play_count = play_count;
621 music->loop_flag = SDL_FALSE;
622 }
623 }
624
625 if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) {
626 if (music->play_count == 1) {
627 music->play_count = 0;
628 SDL_AudioStreamFlush(music->stream);
629 } else {
630 int play_count = -1;
631 if (music->play_count > 0) {
632 play_count = (music->play_count - 1);
633 }
634 if (FLAC_Play(music, play_count) < 0) {
635 return -1;
636 }
637 }
638 }
639 return 0;
640 }
641
642 /* Play some of a stream previously started with FLAC_play() */
643 static int FLAC_GetAudio(void *context, void *data, int bytes)
644 {
645 FLAC_Music *music = (FLAC_Music *)context;
646 return music_pcm_getaudio(context, data, bytes, music->volume, FLAC_GetSome);
647 }
648
649 /* Jump (seek) to a given position (position is in seconds) */
650 static int FLAC_Seek(void *context, double position)
651 {
652 FLAC_Music *music = (FLAC_Music *)context;
653 FLAC__uint64 seek_sample = (FLAC__uint64) (music->sample_rate * position);
654
655 SDL_AudioStreamClear(music->stream);
656 music->pcm_pos = (FLAC__int64) seek_sample;
657 if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, seek_sample)) {
658 if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) {
659 flac.FLAC__stream_decoder_flush(music->flac_decoder);
660 }
661
662 SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
663 return -1;
664 }
665 return 0;
666 }
667
668 static double FLAC_Tell(void *context)
669 {
670 FLAC_Music *music = (FLAC_Music *)context;
671 return (double)music->pcm_pos / music->sample_rate;
672 }
673
674 /* Return music duration in seconds */
675 static double FLAC_Duration(void *context)
676 {
677 FLAC_Music *music = (FLAC_Music *)context;
678 return (double)music->full_length / music->sample_rate;
679 }
680
681 static double FLAC_LoopStart(void *music_p)
682 {
683 FLAC_Music *music = (FLAC_Music *)music_p;
684 if (music->loop > 0) {
685 return (double)music->loop_start / music->sample_rate;
686 }
687 return -1.0;
688 }
689
690 static double FLAC_LoopEnd(void *music_p)
691 {
692 FLAC_Music *music = (FLAC_Music *)music_p;
693 if (music->loop > 0) {
694 return (double)music->loop_end / music->sample_rate;
695 }
696 return -1.0;
697 }
698
699 static double FLAC_LoopLength(void *music_p)
700 {
701 FLAC_Music *music = (FLAC_Music *)music_p;
702 if (music->loop > 0) {
703 return (double)music->loop_len / music->sample_rate;
704 }
705 return -1.0;
706 }
707
708 /* Close the given FLAC_Music object */
709 static void FLAC_Delete(void *context)
710 {
711 FLAC_Music *music = (FLAC_Music *)context;
712 if (music) {
713 meta_tags_clear(&music->tags);
714 if (music->flac_decoder) {
715 flac.FLAC__stream_decoder_finish(music->flac_decoder);
716 flac.FLAC__stream_decoder_delete(music->flac_decoder);
717 }
718 if (music->stream) {
719 SDL_FreeAudioStream(music->stream);
720 }
721 if (music->freesrc) {
722 SDL_RWclose(music->src);
723 }
724 SDL_free(music);
725 }
726 }
727
728 Mix_MusicInterface Mix_MusicInterface_FLAC =
729 {
730 "FLAC",
731 MIX_MUSIC_FLAC,
732 MUS_FLAC,
733 SDL_FALSE,
734 SDL_FALSE,
735
736 FLAC_Load,
737 NULL, /* Open */
738 FLAC_CreateFromRW,
739 NULL, /* CreateFromFile */
740 FLAC_SetVolume,
741 FLAC_GetVolume,
742 FLAC_Play,
743 NULL, /* IsPlaying */
744 FLAC_GetAudio,
745 NULL, /* Jump */
746 FLAC_Seek,
747 FLAC_Tell,
748 FLAC_Duration,
749 FLAC_LoopStart,
750 FLAC_LoopEnd,
751 FLAC_LoopLength,
752 FLAC_GetMetaTag,/* GetMetaTag */
753 NULL, /* Pause */
754 NULL, /* Resume */
755 NULL, /* Stop */
756 FLAC_Delete,
757 NULL, /* Close */
758 FLAC_Unload
759 };
760
761 #endif /* MUSIC_FLAC */
762
763 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #include "music.h"
22
23 extern Mix_MusicInterface Mix_MusicInterface_FLAC;
24
25 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 James Le Cuirot
21 chewi@aura-online.co.uk
22 */
23
24 #ifdef MUSIC_MID_FLUIDSYNTH
25
26 #include "SDL_loadso.h"
27 #include "SDL_rwops.h"
28
29 #include "music_fluidsynth.h"
30
31 #include <fluidsynth.h>
32
33
34 typedef struct {
35 int loaded;
36 void *handle;
37
38 #if (FLUIDSYNTH_VERSION_MAJOR >= 2)
39 void (*delete_fluid_player)(fluid_player_t*);
40 void (*delete_fluid_synth)(fluid_synth_t*);
41 #else
42 int (*delete_fluid_player)(fluid_player_t*);
43 int (*delete_fluid_synth)(fluid_synth_t*);
44 #endif
45 void (*delete_fluid_settings)(fluid_settings_t*);
46 int (*fluid_player_add)(fluid_player_t*, const char*);
47 int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t);
48 int (*fluid_player_get_status)(fluid_player_t*);
49 int (*fluid_player_play)(fluid_player_t*);
50 int (*fluid_player_set_loop)(fluid_player_t*, int);
51 int (*fluid_player_stop)(fluid_player_t*);
52 int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double);
53 int (*fluid_settings_getnum)(fluid_settings_t*, const char*, double*);
54 fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*);
55 void (*fluid_synth_set_gain)(fluid_synth_t*, float);
56 int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int);
57 int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int);
58 int (*fluid_synth_write_float)(fluid_synth_t*, int, void*, int, int, void*, int, int);
59 fluid_player_t* (*new_fluid_player)(fluid_synth_t*);
60 fluid_settings_t* (*new_fluid_settings)(void);
61 fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*);
62 } fluidsynth_loader;
63
64 static fluidsynth_loader fluidsynth = {
65 0, NULL
66 };
67
68 #ifdef FLUIDSYNTH_DYNAMIC
69 #define FUNCTION_LOADER(FUNC, SIG) \
70 fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
71 if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
72 #else
73 #define FUNCTION_LOADER(FUNC, SIG) \
74 fluidsynth.FUNC = FUNC;
75 #endif
76
77 static int FLUIDSYNTH_Load()
78 {
79 if (fluidsynth.loaded == 0) {
80 #ifdef FLUIDSYNTH_DYNAMIC
81 fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
82 if (fluidsynth.handle == NULL) {
83 return -1;
84 }
85 #endif
86 #if (FLUIDSYNTH_VERSION_MAJOR >= 2)
87 FUNCTION_LOADER(delete_fluid_player, void (*)(fluid_player_t*))
88 FUNCTION_LOADER(delete_fluid_synth, void (*)(fluid_synth_t*))
89 #else
90 FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*))
91 FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*))
92 #endif
93 FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*))
94 FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*))
95 FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t))
96 FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*))
97 FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*))
98 FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int))
99 FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*))
100 FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double))
101 FUNCTION_LOADER(fluid_settings_getnum, int (*)(fluid_settings_t*, const char*, double*))
102 FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*))
103 FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float))
104 FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int))
105 FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int))
106 FUNCTION_LOADER(fluid_synth_write_float, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int))
107 FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*))
108 FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void))
109 FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*))
110 }
111 ++fluidsynth.loaded;
112
113 return 0;
114 }
115
116 static void FLUIDSYNTH_Unload()
117 {
118 if (fluidsynth.loaded == 0) {
119 return;
120 }
121 if (fluidsynth.loaded == 1) {
122 #ifdef FLUIDSYNTH_DYNAMIC
123 SDL_UnloadObject(fluidsynth.handle);
124 #endif
125 }
126 --fluidsynth.loaded;
127 }
128
129
130 typedef struct {
131 fluid_synth_t *synth;
132 fluid_settings_t *settings;
133 fluid_player_t *player;
134 int (*synth_write)(fluid_synth_t*, int, void*, int, int, void*, int, int);
135 SDL_AudioStream *stream;
136 void *buffer;
137 int buffer_size;
138 int volume;
139 } FLUIDSYNTH_Music;
140
141 static void FLUIDSYNTH_Delete(void *context);
142
143 static int SDLCALL fluidsynth_check_soundfont(const char *path, void *data)
144 {
145 SDL_RWops *rw = SDL_RWFromFile(path, "rb");
146
147 (void)data;
148 if (rw) {
149 SDL_RWclose(rw);
150 return 1;
151 } else {
152 Mix_SetError("Failed to access the SoundFont %s", path);
153 return 0;
154 }
155 }
156
157 static int SDLCALL fluidsynth_load_soundfont(const char *path, void *data)
158 {
159 /* If this fails, it's too late to try Timidity so pray that at least one works. */
160 fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1);
161 return 1;
162 }
163
164 static int FLUIDSYNTH_Open(const SDL_AudioSpec *spec)
165 {
166 (void)spec;
167 if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) {
168 return -1;
169 }
170 return 0;
171 }
172
173 static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data)
174 {
175 SDL_RWops *src = (SDL_RWops *)data;
176 FLUIDSYNTH_Music *music;
177 double samplerate; /* as set by the lib. */
178 const Uint8 channels = 2;
179 int src_format = AUDIO_S16SYS;
180 void *rw_mem;
181 size_t rw_size;
182 int ret;
183
184 if (!(music = SDL_calloc(1, sizeof(FLUIDSYNTH_Music)))) {
185 SDL_OutOfMemory();
186 return NULL;
187 }
188
189 music->volume = MIX_MAX_VOLUME;
190 music->buffer_size = music_spec.samples * sizeof(Sint16) * channels;
191 music->synth_write = fluidsynth.fluid_synth_write_s16;
192 if (music_spec.format & 0x0020) { /* 32 bit. */
193 src_format = AUDIO_F32SYS;
194 music->buffer_size <<= 1;
195 music->synth_write = fluidsynth.fluid_synth_write_float;
196 }
197
198 if (!(music->buffer = SDL_malloc((size_t)music->buffer_size))) {
199 SDL_OutOfMemory();
200 goto fail;
201 }
202
203 if (!(music->settings = fluidsynth.new_fluid_settings())) {
204 Mix_SetError("Failed to create FluidSynth settings");
205 goto fail;
206 }
207
208 fluidsynth.fluid_settings_setnum(music->settings, "synth.sample-rate", (double) music_spec.freq);
209 fluidsynth.fluid_settings_getnum(music->settings, "synth.sample-rate", &samplerate);
210
211 if (!(music->synth = fluidsynth.new_fluid_synth(music->settings))) {
212 Mix_SetError("Failed to create FluidSynth synthesizer");
213 goto fail;
214 }
215
216 if (!Mix_EachSoundFont(fluidsynth_load_soundfont, music->synth)) {
217 goto fail;
218 }
219
220 if (!(music->player = fluidsynth.new_fluid_player(music->synth))) {
221 Mix_SetError("Failed to create FluidSynth player");
222 goto fail;
223 }
224
225 rw_mem = SDL_LoadFile_RW(src, &rw_size, SDL_FALSE);
226 if (!rw_mem) {
227 SDL_OutOfMemory();
228 goto fail;
229 }
230
231 ret = fluidsynth.fluid_player_add_mem(music->player, rw_mem, rw_size);
232 SDL_free(rw_mem);
233 if (ret != FLUID_OK) {
234 Mix_SetError("FluidSynth failed to load in-memory song");
235 goto fail;
236 }
237
238 if (!(music->stream = SDL_NewAudioStream(src_format, channels, (int) samplerate,
239 music_spec.format, music_spec.channels, music_spec.freq))) {
240 goto fail;
241 }
242
243 return music;
244 fail:
245 FLUIDSYNTH_Delete(music);
246 return NULL;
247 }
248
249 static void *FLUIDSYNTH_CreateFromRW(SDL_RWops *src, int freesrc)
250 {
251 FLUIDSYNTH_Music *music;
252
253 music = FLUIDSYNTH_LoadMusic(src);
254 if (music && freesrc) {
255 SDL_RWclose(src);
256 }
257 return music;
258 }
259
260 static void FLUIDSYNTH_SetVolume(void *context, int volume)
261 {
262 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
263 /* FluidSynth's default is 0.2. Make 1.2 the maximum. */
264 music->volume = volume;
265 fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME));
266 }
267
268 static int FLUIDSYNTH_GetVolume(void *context)
269 {
270 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
271 return music->volume;
272 }
273
274 static int FLUIDSYNTH_Play(void *context, int play_count)
275 {
276 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
277 fluidsynth.fluid_player_set_loop(music->player, play_count);
278 fluidsynth.fluid_player_play(music->player);
279 return 0;
280 }
281
282 static SDL_bool FLUIDSYNTH_IsPlaying(void *context)
283 {
284 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
285 return fluidsynth.fluid_player_get_status(music->player) == FLUID_PLAYER_PLAYING ? SDL_TRUE : SDL_FALSE;
286 }
287
288 static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *done)
289 {
290 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
291 int filled;
292
293 (void)done;
294
295 filled = SDL_AudioStreamGet(music->stream, data, bytes);
296 if (filled != 0) {
297 return filled;
298 }
299
300 if (music->synth_write(music->synth, music_spec.samples, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) {
301 Mix_SetError("Error generating FluidSynth audio");
302 return -1;
303 }
304 if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) {
305 return -1;
306 }
307 return 0;
308 }
309 static int FLUIDSYNTH_GetAudio(void *context, void *data, int bytes)
310 {
311 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, FLUIDSYNTH_GetSome);
312 }
313
314 static void FLUIDSYNTH_Stop(void *context)
315 {
316 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
317 fluidsynth.fluid_player_stop(music->player);
318 }
319
320 static void FLUIDSYNTH_Delete(void *context)
321 {
322 FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
323
324 if (music->player) {
325 fluidsynth.delete_fluid_player(music->player);
326 }
327 if (music->synth) {
328 fluidsynth.delete_fluid_synth(music->synth);
329 }
330 if (music->settings) {
331 fluidsynth.delete_fluid_settings(music->settings);
332 }
333 if (music->stream) {
334 SDL_FreeAudioStream(music->stream);
335 }
336 if (music->buffer) {
337 SDL_free(music->buffer);
338 }
339 SDL_free(music);
340 }
341
342 Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH =
343 {
344 "FLUIDSYNTH",
345 MIX_MUSIC_FLUIDSYNTH,
346 MUS_MID,
347 SDL_FALSE,
348 SDL_FALSE,
349
350 FLUIDSYNTH_Load,
351 FLUIDSYNTH_Open,
352 FLUIDSYNTH_CreateFromRW,
353 NULL, /* CreateFromFile */
354 FLUIDSYNTH_SetVolume,
355 FLUIDSYNTH_GetVolume,
356 FLUIDSYNTH_Play,
357 FLUIDSYNTH_IsPlaying,
358 FLUIDSYNTH_GetAudio,
359 NULL, /* Jump */
360 NULL, /* Seek */
361 NULL, /* Tell */
362 NULL, /* Duration */
363 NULL, /* LoopStart */
364 NULL, /* LoopEnd */
365 NULL, /* LoopLength */
366 NULL, /* GetMetaTag */
367 NULL, /* Pause */
368 NULL, /* Resume */
369 FLUIDSYNTH_Stop,
370 FLUIDSYNTH_Delete,
371 NULL, /* Close */
372 FLUIDSYNTH_Unload
373 };
374
375 #endif /* MUSIC_MID_FLUIDSYNTH */
376
377 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 James Le Cuirot
21 chewi@aura-online.co.uk
22 */
23
24 /* This file supports playing MIDI files with FluidSynth */
25
26 #include "music.h"
27
28 extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH;
29
30 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MP3_MAD
22
23 #include "music_mad.h"
24 #include "mp3utils.h"
25
26 #include "mad.h"
27
28
29 /* NOTE: The dithering functions are GPL, which should be fine if your
30 application is GPL (which would need to be true if you enabled
31 libmad support in SDL_mixer). If you're using libmad under the
32 commercial license, you need to disable this code.
33 */
34 /************************ dithering functions ***************************/
35
36 #ifdef MUSIC_MP3_MAD_GPL_DITHERING
37
38 /* All dithering done here is taken from the GPL'ed xmms-mad plugin. */
39
40 /* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */
41 /* Any feedback is very welcome. For any question, comments, */
42 /* see http://www.math.keio.ac.jp/matumoto/emt.html or email */
43 /* matumoto@math.keio.ac.jp */
44
45 /* Period parameters */
46 #define MP3_DITH_N 624
47 #define MP3_DITH_M 397
48 #define MATRIX_A 0x9908b0df /* constant vector a */
49 #define UPPER_MASK 0x80000000 /* most significant w-r bits */
50 #define LOWER_MASK 0x7fffffff /* least significant r bits */
51
52 /* Tempering parameters */
53 #define TEMPERING_MASK_B 0x9d2c5680
54 #define TEMPERING_MASK_C 0xefc60000
55 #define TEMPERING_SHIFT_U(y) (y >> 11)
56 #define TEMPERING_SHIFT_S(y) (y << 7)
57 #define TEMPERING_SHIFT_T(y) (y << 15)
58 #define TEMPERING_SHIFT_L(y) (y >> 18)
59
60 static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */
61 static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */
62
63 /* initializing the array with a NONZERO seed */
64 static void sgenrand(unsigned long seed)
65 {
66 /* setting initial seeds to mt[MP3_DITH_N] using */
67 /* the generator Line 25 of Table 1 in */
68 /* [KNUTH 1981, The Art of Computer Programming */
69 /* Vol. 2 (2nd Ed.), pp102] */
70 mt[0]= seed & 0xffffffff;
71 for (mti=1; mti<MP3_DITH_N; mti++)
72 mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
73 }
74
75 static unsigned long genrand(void)
76 {
77 unsigned long y;
78 static unsigned long mag01[2]={0x0, MATRIX_A};
79 /* mag01[x] = x * MATRIX_A for x=0,1 */
80
81 if (mti >= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */
82 int kk;
83
84 if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */
85 sgenrand(4357); /* a default initial seed is used */
86
87 for (kk=0;kk<MP3_DITH_N-MP3_DITH_M;kk++) {
88 y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
89 mt[kk] = mt[kk+MP3_DITH_M] ^ (y >> 1) ^ mag01[y & 0x1];
90 }
91 for (;kk<MP3_DITH_N-1;kk++) {
92 y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
93 mt[kk] = mt[kk+(MP3_DITH_M-MP3_DITH_N)] ^ (y >> 1) ^ mag01[y & 0x1];
94 }
95 y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
96 mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1];
97
98 mti = 0;
99 }
100
101 y = mt[mti++];
102 y ^= TEMPERING_SHIFT_U(y);
103 y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
104 y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
105 y ^= TEMPERING_SHIFT_L(y);
106
107 return y;
108 }
109
110 static long triangular_dither_noise(int nbits) {
111 /* parameter nbits : the peak-to-peak amplitude desired (in bits)
112 * use with nbits set to 2 + nber of bits to be trimmed.
113 * (because triangular is made from two uniformly distributed processes,
114 * it starts at 2 bits peak-to-peak amplitude)
115 * see The Theory of Dithered Quantization by Robert Alexander Wannamaker
116 * for complete proof of why that's optimal
117 */
118 long v = (genrand()/2 - genrand()/2); /* in ]-2^31, 2^31[ */
119 long P = 1 << (32 - nbits); /* the power of 2 */
120 v /= P;
121 /* now v in ]-2^(nbits-1), 2^(nbits-1) [ */
122
123 return v;
124 }
125
126 #endif /* MUSIC_MP3_MAD_GPL_DITHERING */
127
128
129 #define MAD_INPUT_BUFFER_SIZE (5*8192)
130
131 enum {
132 MS_input_eof = 0x0001,
133 MS_input_error = 0x0001,
134 MS_decode_error = 0x0002,
135 MS_error_flags = 0x000f
136 };
137
138 typedef struct {
139 struct mp3file_t mp3file;
140 int play_count;
141 int freesrc;
142 struct mad_stream stream;
143 struct mad_frame frame;
144 struct mad_synth synth;
145 mad_timer_t next_frame_start;
146 int volume;
147 int status;
148 SDL_AudioStream *audiostream;
149 unsigned short last_nchannels;
150 unsigned int last_samplerate;
151
152 double total_length;
153 int sample_rate;
154 int sample_position;
155
156 unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
157 } MAD_Music;
158
159 static void read_update_buffer(struct mad_stream *stream, MAD_Music *music);
160
161 static double extract_length(struct mad_header *header, struct mad_stream *stream, Sint64 file_size)
162 {
163 int mpeg_version = 0;
164 int xing_offset = 0;
165 Uint32 samples_per_frame = 0;
166 Uint32 frames_count = 0;
167 unsigned char const *frames_count_raw;
168
169 /* There are two methods to compute duration:
170 * - Using Xing/Info/VBRI headers
171 * - Rely on filesize and first size of frame in condition of CRB
172 * https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#VBRHeaders
173 */
174
175 if (!stream->this_frame || !stream->next_frame ||
176 stream->next_frame <= stream->this_frame ||
177 (stream->next_frame - stream->this_frame) < 48) {
178 return -1.0; /* Too small buffer to get any necessary headers */
179 }
180
181 mpeg_version = (stream->this_frame[1] >> 3) & 0x03;
182
183 switch(mpeg_version) {
184 case 0x03: /* MPEG1 */
185 if (header->mode == MAD_MODE_SINGLE_CHANNEL) {
186 xing_offset = 4 + 17;
187 } else {
188 xing_offset = 4 + 32;
189 }
190 break;
191 default: /* MPEG2 and MPEG2.5 */
192 if (header->mode == MAD_MODE_SINGLE_CHANNEL) {
193 xing_offset = 4 + 17;
194 } else {
195 xing_offset = 4 + 9;
196 }
197 break;
198 }
199
200 switch(header->layer)
201 {
202 case MAD_LAYER_I:
203 samples_per_frame = 384;
204 break;
205 case MAD_LAYER_II:
206 samples_per_frame = 1152;
207 break;
208 case MAD_LAYER_III:
209 if (mpeg_version == 0x03) {
210 samples_per_frame = 1152;
211 } else {
212 samples_per_frame = 576;
213 }
214 break;
215 default:
216 return -1.0;
217 }
218
219 if (SDL_memcmp(stream->this_frame + xing_offset, "Xing", 4) == 0 ||
220 SDL_memcmp(stream->this_frame + xing_offset, "Info", 4) == 0) {
221 /* Xing header to get the count of frames for VBR */
222 frames_count_raw = stream->this_frame + xing_offset + 8;
223 frames_count = ((Uint32)frames_count_raw[0] << 24) +
224 ((Uint32)frames_count_raw[1] << 16) +
225 ((Uint32)frames_count_raw[2] << 8) +
226 ((Uint32)frames_count_raw[3]);
227 }
228 else if (SDL_memcmp(stream->this_frame + xing_offset, "VBRI", 4) == 0) {
229 /* VBRI header to get the count of frames for VBR */
230 frames_count_raw = stream->this_frame + xing_offset + 14;
231 frames_count = ((Uint32)frames_count_raw[0] << 24) +
232 ((Uint32)frames_count_raw[1] << 16) +
233 ((Uint32)frames_count_raw[2] << 8) +
234 ((Uint32)frames_count_raw[3]);
235 } else {
236 /* To get a count of frames for CBR, divide the file size with a size of one frame */
237 frames_count = (Uint32)(file_size / (stream->next_frame - stream->this_frame));
238 }
239
240 return (double)(frames_count * samples_per_frame) / header->samplerate;
241 }
242
243 static int calculate_total_time(MAD_Music *music)
244 {
245 mad_timer_t time = mad_timer_zero;
246 struct mad_header header;
247 struct mad_stream stream;
248 SDL_bool is_first_frame = SDL_TRUE;
249 int ret = 0;
250
251 mad_header_init(&header);
252 mad_stream_init(&stream);
253
254 while (1)
255 {
256 read_update_buffer(&stream, music);
257
258 if (mad_header_decode(&header, &stream) == -1) {
259 if (MAD_RECOVERABLE(stream.error)) {
260 if ((music->status & MS_input_error) == 0) {
261 continue;
262 }
263 if (is_first_frame) {
264 ret = -1;
265 }
266 break;
267 } else if (stream.error == MAD_ERROR_BUFLEN) {
268 if ((music->status & MS_input_error) == 0) {
269 continue;
270 }
271 if (is_first_frame) {
272 ret = -1;
273 }
274 break;
275 } else {
276 Mix_SetError("mad_frame_decode() failed, corrupt stream?");
277 music->status |= MS_decode_error;
278 if (is_first_frame) {
279 ret = -1;
280 }
281 break;
282 }
283 }
284
285 music->sample_rate = (int)header.samplerate;
286 mad_timer_add(&time, header.duration);
287
288 if (is_first_frame) {
289 music->total_length = extract_length(&header, &stream, music->mp3file.length);
290 if (music->total_length > 0.0) {
291 break; /* Duration has been recognized */
292 }
293 is_first_frame = SDL_FALSE;
294 /* Otherwise, do the full scan of MP3 file to retrieve a duration */
295 }
296 }
297
298 if (!is_first_frame) {
299 music->total_length = (double)(mad_timer_count(time, (enum mad_units)music->sample_rate)) / (double)music->sample_rate;
300 }
301 mad_stream_finish(&stream);
302 mad_header_finish(&header);
303 SDL_memset(music->input_buffer, 0, sizeof(music->input_buffer));
304
305 music->status = 0;
306
307 MP3_RWseek(&music->mp3file, 0, RW_SEEK_SET);
308 return ret;
309 }
310
311 static int MAD_Seek(void *context, double position);
312
313 static void *MAD_CreateFromRW(SDL_RWops *src, int freesrc)
314 {
315 MAD_Music *music;
316
317 music = (MAD_Music *)SDL_calloc(1, sizeof(MAD_Music));
318 if (!music) {
319 SDL_OutOfMemory();
320 return NULL;
321 }
322 music->volume = MIX_MAX_VOLUME;
323
324 if (MP3_RWinit(&music->mp3file, src) < 0) {
325 SDL_free(music);
326 return NULL;
327 }
328 if (mp3_skiptags(&music->mp3file, SDL_FALSE) < 0) {
329 SDL_free(music);
330 Mix_SetError("music_mad: corrupt mp3 file (bad tags.)");
331 return NULL;
332 }
333
334 if (calculate_total_time(music) < 0) {
335 SDL_free(music);
336 Mix_SetError("music_mad: corrupt mp3 file (bad stream.)");
337 return NULL;
338 }
339
340 mad_stream_init(&music->stream);
341 mad_frame_init(&music->frame);
342 mad_synth_init(&music->synth);
343 mad_timer_reset(&music->next_frame_start);
344
345 music->freesrc = freesrc;
346 return music;
347 }
348
349 static void MAD_SetVolume(void *context, int volume)
350 {
351 MAD_Music *music = (MAD_Music *)context;
352 music->volume = volume;
353 }
354
355 static int MAD_GetVolume(void *context)
356 {
357 MAD_Music *music = (MAD_Music *)context;
358 return music->volume;
359 }
360
361 /* Starts the playback. */
362 static int MAD_Play(void *context, int play_count)
363 {
364 MAD_Music *music = (MAD_Music *)context;
365 music->play_count = play_count;
366 return MAD_Seek(music, 0.0);
367 }
368
369
370 /* Reads the next frame from the file.
371 Returns true on success or false on failure.
372 */
373 static void read_update_buffer(struct mad_stream *stream, MAD_Music *music)
374 {
375 if (stream->buffer == NULL ||
376 stream->error == MAD_ERROR_BUFLEN) {
377 size_t read_size;
378 size_t remaining;
379 unsigned char *read_start;
380
381 /* There might be some bytes in the buffer left over from last
382 time. If so, move them down and read more bytes following
383 them. */
384 if (stream->next_frame != NULL) {
385 remaining = (size_t)(stream->bufend - stream->next_frame);
386 SDL_memmove(music->input_buffer, stream->next_frame, remaining);
387 read_start = music->input_buffer + remaining;
388 read_size = MAD_INPUT_BUFFER_SIZE - remaining;
389
390 } else {
391 read_size = MAD_INPUT_BUFFER_SIZE;
392 read_start = music->input_buffer;
393 remaining = 0;
394 }
395
396 /* Now read additional bytes from the input file. */
397 read_size = MP3_RWread(&music->mp3file, read_start, 1, read_size);
398
399 if (read_size == 0) {
400 if ((music->status & (MS_input_eof | MS_input_error)) == 0) {
401 /* FIXME: how to detect error? */
402 music->status |= MS_input_eof;
403
404 /* At the end of the file, we must stuff MAD_BUFFER_GUARD
405 number of 0 bytes. */
406 SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD);
407 read_size += MAD_BUFFER_GUARD;
408 }
409 }
410
411 /* Now feed those bytes into the libmad stream. */
412 mad_stream_buffer(stream, music->input_buffer,
413 read_size + remaining);
414 stream->error = MAD_ERROR_NONE;
415 }
416 }
417
418 /* Reads the next frame from the file.
419 Returns true on success or false on failure.
420 */
421 static SDL_bool read_next_frame(MAD_Music *music)
422 {
423 read_update_buffer(&music->stream, music);
424
425 /* Now ask libmad to extract a frame from the data we just put in
426 its buffer. */
427 if (mad_frame_decode(&music->frame, &music->stream)) {
428 if (MAD_RECOVERABLE(music->stream.error)) {
429 mad_stream_sync(&music->stream); /* to frame seek mode */
430 return SDL_FALSE;
431
432 } else if (music->stream.error == MAD_ERROR_BUFLEN) {
433 return SDL_FALSE;
434
435 } else {
436 Mix_SetError("mad_frame_decode() failed, corrupt stream?");
437 music->status |= MS_decode_error;
438 return SDL_FALSE;
439 }
440 }
441
442 mad_timer_add(&music->next_frame_start, music->frame.header.duration);
443
444 return SDL_TRUE;
445 }
446
447 /* Scale a MAD sample to 16 bits for output. */
448 static Sint16 scale(mad_fixed_t sample)
449 {
450 const int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16;
451
452 /* round */
453 sample += (1L << (n_bits_to_loose - 1));
454
455 #ifdef MUSIC_MP3_MAD_GPL_DITHERING
456 sample += triangular_dither_noise(n_bits_to_loose + 1);
457 #endif
458
459 /* clip */
460 if (sample >= MAD_F_ONE)
461 sample = MAD_F_ONE - 1;
462 else if (sample < -MAD_F_ONE)
463 sample = -MAD_F_ONE;
464
465 /* quantize */
466 return (Sint16)(sample >> n_bits_to_loose);
467 }
468
469 /* Once the frame has been read, copies its samples into the output buffer. */
470 static SDL_bool decode_frame(MAD_Music *music)
471 {
472 struct mad_pcm *pcm;
473 unsigned int i, nchannels, nsamples;
474 mad_fixed_t const *left_ch, *right_ch;
475 Sint16 *buffer, *dst;
476 int result;
477
478 mad_synth_frame(&music->synth, &music->frame);
479 pcm = &music->synth.pcm;
480
481 if (!music->audiostream || music->last_nchannels != pcm->channels || music->last_samplerate != pcm->samplerate) {
482 if (music->audiostream) {
483 SDL_FreeAudioStream(music->audiostream);
484 }
485 music->audiostream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)pcm->channels, (int)pcm->samplerate,
486 music_spec.format, music_spec.channels, music_spec.freq);
487 if (!music->audiostream) {
488 return SDL_FALSE;
489 }
490 music->last_nchannels = pcm->channels;
491 music->last_samplerate = pcm->samplerate;
492 }
493
494 nchannels = pcm->channels;
495 nsamples = pcm->length;
496 left_ch = pcm->samples[0];
497 right_ch = pcm->samples[1];
498 buffer = SDL_stack_alloc(Sint16, nsamples*nchannels);
499 if (!buffer) {
500 SDL_OutOfMemory();
501 return SDL_FALSE;
502 }
503
504 dst = buffer;
505 if (nchannels == 1) {
506 for (i = nsamples; i--;) {
507 *dst++ = scale(*left_ch++);
508 }
509 } else {
510 for (i = nsamples; i--;) {
511 *dst++ = scale(*left_ch++);
512 *dst++ = scale(*right_ch++);
513 }
514 }
515
516 music->sample_position += nsamples;
517 result = SDL_AudioStreamPut(music->audiostream, buffer, (int)(nsamples * nchannels * sizeof(Sint16)));
518 SDL_stack_free(buffer);
519
520 if (result < 0) {
521 return SDL_FALSE;
522 }
523 return SDL_TRUE;
524 }
525
526 static int MAD_GetSome(void *context, void *data, int bytes, SDL_bool *done)
527 {
528 MAD_Music *music = (MAD_Music *)context;
529 int filled;
530
531 if (music->audiostream) {
532 filled = SDL_AudioStreamGet(music->audiostream, data, bytes);
533 if (filled != 0) {
534 return filled;
535 }
536 }
537
538 if (!music->play_count) {
539 /* All done */
540 *done = SDL_TRUE;
541 return 0;
542 }
543
544 if (read_next_frame(music)) {
545 if (!decode_frame(music)) {
546 return -1;
547 }
548 } else if (music->status & MS_input_eof) {
549 int play_count = -1;
550 if (music->play_count > 0) {
551 play_count = (music->play_count - 1);
552 }
553 if (MAD_Play(music, play_count) < 0) {
554 return -1;
555 }
556 } else if (music->status & MS_decode_error) {
557 return -1;
558 }
559 return 0;
560 }
561
562 static int MAD_GetAudio(void *context, void *data, int bytes)
563 {
564 MAD_Music *music = (MAD_Music *)context;
565 return music_pcm_getaudio(context, data, bytes, music->volume, MAD_GetSome);
566 }
567
568 static int MAD_Seek(void *context, double position)
569 {
570 MAD_Music *music = (MAD_Music *)context;
571 mad_timer_t target;
572 int int_part;
573
574 int_part = (int)position;
575 mad_timer_set(&target, (unsigned long)int_part, (unsigned long)((position - int_part) * 1000000), 1000000);
576
577 music->sample_position = (int)(position * music->sample_rate);
578
579 if (mad_timer_compare(music->next_frame_start, target) > 0) {
580 /* In order to seek backwards in a VBR file, we have to rewind and
581 start again from the beginning. This isn't necessary if the
582 file happens to be CBR, of course; in that case we could seek
583 directly to the frame we want. But I leave that little
584 optimization for the future developer who discovers she really
585 needs it. */
586 mad_timer_reset(&music->next_frame_start);
587 music->status &= ~MS_error_flags;
588
589 MP3_RWseek(&music->mp3file, 0, RW_SEEK_SET);
590 /* Avoid junk chunk be played after seek -- Vitaly Novichkov */
591 SDL_memset(music->input_buffer, 0, sizeof(music->input_buffer));
592 }
593
594 /* Now we have to skip frames until we come to the right one.
595 Again, only truly necessary if the file is VBR. */
596 while (mad_timer_compare(music->next_frame_start, target) < 0) {
597 if (!read_next_frame(music)) {
598 if ((music->status & MS_error_flags) != 0) {
599 /* Couldn't read a frame; either an error condition or
600 end-of-file. Stop. */
601 return Mix_SetError("Seek position out of range");
602 }
603 }
604 }
605
606 /* Here we are, at the beginning of the frame that contains the
607 target time. Ehh, I say that's close enough. If we wanted to,
608 we could get more precise by decoding the frame now and counting
609 the appropriate number of samples out of it. */
610 return 0;
611 }
612
613 static double MAD_Tell(void *context)
614 {
615 MAD_Music *music = (MAD_Music *)context;
616 return (double)music->sample_position / (double)music->sample_rate;
617 }
618
619 static double MAD_Duration(void *context)
620 {
621 MAD_Music *music = (MAD_Music *)context;
622 return music->total_length;
623 }
624
625 static void MAD_Delete(void *context)
626 {
627 MAD_Music *music = (MAD_Music *)context;
628
629 mad_stream_finish(&music->stream);
630 mad_frame_finish(&music->frame);
631 mad_synth_finish(&music->synth);
632
633 if (music->audiostream) {
634 SDL_FreeAudioStream(music->audiostream);
635 }
636 if (music->freesrc) {
637 SDL_RWclose(music->mp3file.src);
638 }
639 SDL_free(music);
640 }
641
642 Mix_MusicInterface Mix_MusicInterface_MAD =
643 {
644 "MAD",
645 MIX_MUSIC_MAD,
646 MUS_MP3,
647 SDL_FALSE,
648 SDL_FALSE,
649
650 NULL, /* Load */
651 NULL, /* Open */
652 MAD_CreateFromRW,
653 NULL, /* CreateFromFile */
654 MAD_SetVolume,
655 MAD_GetVolume,
656 MAD_Play,
657 NULL, /* IsPlaying */
658 MAD_GetAudio,
659 NULL, /* Jump */
660 MAD_Seek,
661 MAD_Tell,
662 MAD_Duration,
663 NULL, /* LoopStart */
664 NULL, /* LoopEnd */
665 NULL, /* LoopLength */
666 NULL, /* GetMetaTag */
667 NULL, /* Pause */
668 NULL, /* Resume */
669 NULL, /* Stop */
670 MAD_Delete,
671 NULL, /* Close */
672 NULL /* Unload */
673 };
674
675 #endif /* MUSIC_MP3_MAD */
676
677 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with libmad */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MAD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MOD_MIKMOD
22
23 /* This file supports MOD tracker music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_mikmod.h"
28
29 #include "mikmod.h"
30
31
32 /* libmikmod >= 3.3.2 constified several funcs */
33 #if (LIBMIKMOD_VERSION < 0x030302)
34 #define MIKMOD3_CONST
35 #else
36 #define MIKMOD3_CONST const
37 #endif
38
39 typedef struct {
40 int loaded;
41 void *handle;
42
43 void (*MikMod_Exit)(void);
44 CHAR* (*MikMod_InfoDriver)(void);
45 CHAR* (*MikMod_InfoLoader)(void);
46 int (*MikMod_Init)(MIKMOD3_CONST CHAR*);
47 void (*MikMod_RegisterAllLoaders)(void);
48 void (*MikMod_RegisterDriver)(struct MDRIVER*);
49 int* MikMod_errno;
50 MIKMOD3_CONST char* (*MikMod_strerror)(int);
51 void (*MikMod_free)(void*);
52 BOOL (*Player_Active)(void);
53 void (*Player_Free)(MODULE*);
54 MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL);
55 void (*Player_SetPosition)(UWORD);
56 void (*Player_SetVolume)(SWORD);
57 void (*Player_Start)(MODULE*);
58 void (*Player_Stop)(void);
59 ULONG (*VC_WriteBytes)(SBYTE*,ULONG);
60 struct MDRIVER* drv_nos;
61 UWORD* md_device;
62 UWORD* md_mixfreq;
63 UWORD* md_mode;
64 UBYTE* md_musicvolume;
65 UBYTE* md_pansep;
66 UBYTE* md_reverb;
67 UBYTE* md_sndfxvolume;
68 UBYTE* md_volume;
69 } mikmod_loader;
70
71 static mikmod_loader mikmod = {
72 0, NULL
73 };
74
75 #ifdef MIKMOD_DYNAMIC
76 #define FUNCTION_LOADER(FUNC, SIG) \
77 mikmod.FUNC = (SIG) SDL_LoadFunction(mikmod.handle, #FUNC); \
78 if (mikmod.FUNC == NULL) { SDL_UnloadObject(mikmod.handle); return -1; }
79 #define VARIABLE_LOADER(NAME, SIG) \
80 mikmod.NAME = (SIG) SDL_LoadFunction(mikmod.handle, #NAME); \
81 if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; }
82 #else
83 #define FUNCTION_LOADER(FUNC, SIG) \
84 mikmod.FUNC = FUNC;
85 #define VARIABLE_LOADER(NAME, SIG) \
86 mikmod.NAME = &NAME;
87 #endif
88
89 static int MIKMOD_Load(void)
90 {
91 if (mikmod.loaded == 0) {
92 #ifdef MIKMOD_DYNAMIC
93 mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC);
94 if (mikmod.handle == NULL) {
95 return -1;
96 }
97 #elif defined(__MACOSX__)
98 extern void Player_Start(MODULE*) __attribute__((weak_import));
99 if (Player_Start == NULL)
100 {
101 /* Missing weakly linked framework */
102 Mix_SetError("Missing mikmod.framework");
103 return -1;
104 }
105 #endif
106 FUNCTION_LOADER(MikMod_Exit, void (*)(void))
107 FUNCTION_LOADER(MikMod_InfoDriver, CHAR* (*)(void))
108 FUNCTION_LOADER(MikMod_InfoLoader, CHAR* (*)(void))
109 FUNCTION_LOADER(MikMod_Init, int (*)(MIKMOD3_CONST CHAR*))
110 FUNCTION_LOADER(MikMod_RegisterAllLoaders, void (*)(void))
111 FUNCTION_LOADER(MikMod_RegisterDriver, void (*)(struct MDRIVER*))
112 VARIABLE_LOADER(MikMod_errno, int*)
113 FUNCTION_LOADER(MikMod_strerror, MIKMOD3_CONST char* (*)(int))
114 #ifdef MIKMOD_DYNAMIC
115 mikmod.MikMod_free = (void (*)(void*)) SDL_LoadFunction(mikmod.handle, "MikMod_free");
116 if (!mikmod.MikMod_free) {
117 /* libmikmod-3.2.0-beta2 and earlier doesn't have it. */
118 mikmod.MikMod_free = free;
119 }
120 #else
121 #if (LIBMIKMOD_VERSION < 0x030200) || (LIBMIKMOD_VERSION == 0x030200 && !defined(DMODE_NOISEREDUCTION))
122 /* libmikmod 3.2.0-beta2 or earlier */
123 mikmod.MikMod_free = free;
124 #else
125 mikmod.MikMod_free = MikMod_free;
126 #endif
127 #endif /* MIKMOD_DYNAMIC */
128 FUNCTION_LOADER(Player_Active, BOOL (*)(void))
129 FUNCTION_LOADER(Player_Free, void (*)(MODULE*))
130 FUNCTION_LOADER(Player_LoadGeneric, MODULE* (*)(MREADER*,int,BOOL))
131 FUNCTION_LOADER(Player_SetPosition, void (*)(UWORD))
132 FUNCTION_LOADER(Player_SetVolume, void (*)(SWORD))
133 FUNCTION_LOADER(Player_Start, void (*)(MODULE*))
134 FUNCTION_LOADER(Player_Stop, void (*)(void))
135 FUNCTION_LOADER(VC_WriteBytes, ULONG (*)(SBYTE*,ULONG))
136 VARIABLE_LOADER(drv_nos, MDRIVER*)
137 VARIABLE_LOADER(md_device, UWORD*)
138 VARIABLE_LOADER(md_mixfreq, UWORD*)
139 VARIABLE_LOADER(md_mode, UWORD*)
140 VARIABLE_LOADER(md_musicvolume, UBYTE*)
141 VARIABLE_LOADER(md_pansep, UBYTE*)
142 VARIABLE_LOADER(md_reverb, UBYTE*)
143 VARIABLE_LOADER(md_sndfxvolume, UBYTE*)
144 VARIABLE_LOADER(md_volume, UBYTE*)
145 }
146 ++mikmod.loaded;
147
148 return 0;
149 }
150
151 static void MIKMOD_Unload(void)
152 {
153 if (mikmod.loaded == 0) {
154 return;
155 }
156 if (mikmod.loaded == 1) {
157 #ifdef MIKMOD_DYNAMIC
158 SDL_UnloadObject(mikmod.handle);
159 #endif
160 }
161 --mikmod.loaded;
162 }
163
164
165 typedef struct
166 {
167 int play_count;
168 int volume;
169 MODULE *module;
170 SDL_AudioStream *stream;
171 SBYTE *buffer;
172 ULONG buffer_size;
173 Mix_MusicMetaTags tags;
174 } MIKMOD_Music;
175
176
177 static int MIKMOD_Seek(void *context, double position);
178 static void MIKMOD_Delete(void *context);
179
180 /* Initialize the MOD player, with the given mixer settings
181 This function returns 0, or -1 if there was an error.
182 */
183 static int MIKMOD_Open(const SDL_AudioSpec *spec)
184 {
185 CHAR *list;
186
187 /* Set the MikMod music format */
188 if (spec->format == AUDIO_S8 || spec->format == AUDIO_U8) {
189 /* MIKMOD audio format is AUDIO_U8 */
190 *mikmod.md_mode = 0;
191 } else {
192 /* MIKMOD audio format is AUDIO_S16SYS */
193 *mikmod.md_mode = DMODE_16BITS;
194 }
195 if (spec->channels > 1) {
196 *mikmod.md_mode |= DMODE_STEREO;
197 }
198 *mikmod.md_mixfreq = (spec->freq <= 65535) ? (UWORD)spec->freq : 44100;
199 *mikmod.md_device = 0;
200 *mikmod.md_volume = 96;
201 *mikmod.md_musicvolume = 128;
202 *mikmod.md_sndfxvolume = 128;
203 *mikmod.md_pansep = 128;
204 *mikmod.md_reverb = 0;
205 *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND;
206
207 list = mikmod.MikMod_InfoDriver();
208 if (list) {
209 mikmod.MikMod_free(list);
210 } else {
211 mikmod.MikMod_RegisterDriver(mikmod.drv_nos);
212 }
213
214 list = mikmod.MikMod_InfoLoader();
215 if (list) {
216 mikmod.MikMod_free(list);
217 } else {
218 mikmod.MikMod_RegisterAllLoaders();
219 }
220
221 if (mikmod.MikMod_Init(NULL)) {
222 Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
223 return -1;
224 }
225 return 0;
226 }
227
228 /* Uninitialize the music players */
229 static void MIKMOD_Close(void)
230 {
231 if (mikmod.MikMod_Exit) {
232 mikmod.MikMod_Exit();
233 }
234 }
235
236 typedef struct
237 {
238 /* MREADER basic members in libmikmod2/3: */
239 int (*Seek)(struct MREADER*, long, int);
240 long (*Tell)(struct MREADER*);
241 BOOL (*Read)(struct MREADER*, void*, size_t);
242 int (*Get)(struct MREADER*);
243 BOOL (*Eof)(struct MREADER*);
244 /* no iobase members in libmikmod <= 3.2.0-beta2 */
245 long iobase, prev_iobase;
246
247 Sint64 eof;
248 SDL_RWops *src;
249 } LMM_MREADER;
250
251 int LMM_Seek(struct MREADER *mr,long to,int dir)
252 {
253 Sint64 offset = to;
254 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
255 if (dir == SEEK_SET) {
256 offset += lmmmr->iobase;
257 if (offset < lmmmr->iobase)
258 return -1;
259 }
260 return (SDL_RWseek(lmmmr->src, offset, dir) < lmmmr->iobase)? -1 : 0;
261 }
262 long LMM_Tell(struct MREADER *mr)
263 {
264 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
265 return (long)(SDL_RWtell(lmmmr->src) - lmmmr->iobase);
266 }
267 BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz)
268 {
269 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
270 return (BOOL)SDL_RWread(lmmmr->src, buf, sz, 1);
271 }
272 int LMM_Get(struct MREADER *mr)
273 {
274 unsigned char c;
275 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
276 if (SDL_RWread(lmmmr->src, &c, 1, 1)) {
277 return c;
278 }
279 return EOF;
280 }
281 BOOL LMM_Eof(struct MREADER *mr)
282 {
283 Sint64 offset;
284 LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
285 offset = LMM_Tell(mr);
286 return offset >= lmmmr->eof;
287 }
288 MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan)
289 {
290 LMM_MREADER lmmmr;
291 SDL_memset(&lmmmr, 0, sizeof(LMM_MREADER));
292 lmmmr.Seek = LMM_Seek;
293 lmmmr.Tell = LMM_Tell;
294 lmmmr.Read = LMM_Read;
295 lmmmr.Get = LMM_Get;
296 lmmmr.Eof = LMM_Eof;
297
298 lmmmr.prev_iobase = lmmmr.iobase = SDL_RWtell(src);
299 SDL_RWseek(src, 0, RW_SEEK_END);
300 lmmmr.eof = SDL_RWtell(src);
301 SDL_RWseek(src, lmmmr.iobase, RW_SEEK_SET);
302 lmmmr.src = src;
303 return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0);
304 }
305
306 /* Load a MOD stream from an SDL_RWops object */
307 void *MIKMOD_CreateFromRW(SDL_RWops *src, int freesrc)
308 {
309 MIKMOD_Music *music;
310 SDL_AudioFormat format;
311 Uint8 channels;
312
313 music = (MIKMOD_Music *)SDL_calloc(1, sizeof(*music));
314 if (!music) {
315 SDL_OutOfMemory();
316 return NULL;
317 }
318 music->volume = MIX_MAX_VOLUME;
319
320 music->module = MikMod_LoadSongRW(src, 64);
321 if (!music->module) {
322 Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
323 MIKMOD_Delete(music);
324 return NULL;
325 }
326
327 /* Allow implicit looping, disable fade out and other flags. */
328 music->module->extspd = 1;
329 music->module->panflag = 1;
330 music->module->wrap = 0;
331 music->module->loop = 1;
332 music->module->fadeout = 0;
333
334 meta_tags_init(&music->tags);
335 meta_tags_set(&music->tags, MIX_META_TITLE, music->module->songname);
336
337 if ((*mikmod.md_mode & DMODE_16BITS) == DMODE_16BITS) {
338 format = AUDIO_S16SYS;
339 } else {
340 format = AUDIO_U8;
341 }
342 if ((*mikmod.md_mode & DMODE_STEREO) == DMODE_STEREO) {
343 channels = 2;
344 } else {
345 channels = 1;
346 }
347 music->stream = SDL_NewAudioStream(format, channels, *mikmod.md_mixfreq,
348 music_spec.format, music_spec.channels, music_spec.freq);
349 if (!music->stream) {
350 MIKMOD_Delete(music);
351 return NULL;
352 }
353
354 music->buffer_size = music_spec.samples * (SDL_AUDIO_BITSIZE(format) / 8) * channels;
355 music->buffer = (SBYTE *)SDL_malloc(music->buffer_size);
356 if (!music->buffer) {
357 SDL_OutOfMemory();
358 MIKMOD_Delete(music);
359 return NULL;
360 }
361
362 if (freesrc) {
363 SDL_RWclose(src);
364 }
365
366 return music;
367 }
368
369 /* Set the volume for a MOD stream */
370 static void MIKMOD_SetVolume(void *context, int volume)
371 {
372 MIKMOD_Music *music = (MIKMOD_Music *)context;
373 music->volume = volume;
374 mikmod.Player_SetVolume((SWORD)volume);
375 }
376
377 /* Set the volume for a MOD stream */
378 static int MIKMOD_GetVolume(void *context)
379 {
380 MIKMOD_Music *music = (MIKMOD_Music *)context;
381 return music->volume;
382 }
383
384 /* Start playback of a given MOD stream */
385 static int MIKMOD_Play(void *context, int play_count)
386 {
387 MIKMOD_Music *music = (MIKMOD_Music *)context;
388 music->play_count = play_count;
389 music->module->initvolume = (UBYTE)music->volume;
390 mikmod.Player_Start(music->module);
391 return MIKMOD_Seek(music, 0.0);
392 }
393
394 /* Return non-zero if a stream is currently playing */
395 static SDL_bool MIKMOD_IsPlaying(void *context)
396 {
397 (void)context;
398 return mikmod.Player_Active() ? SDL_TRUE : SDL_FALSE;
399 }
400
401 /* Play some of a stream previously started with MOD_play() */
402 static int MIKMOD_GetSome(void *context, void *data, int bytes, SDL_bool *done)
403 {
404 MIKMOD_Music *music = (MIKMOD_Music *)context;
405 int filled;
406
407 filled = SDL_AudioStreamGet(music->stream, data, bytes);
408 if (filled != 0) {
409 return filled;
410 }
411
412 if (!music->play_count) {
413 /* All done */
414 *done = SDL_TRUE;
415 return 0;
416 }
417
418 /* This never fails, and always writes a full buffer */
419 mikmod.VC_WriteBytes(music->buffer, music->buffer_size);
420
421 if (SDL_AudioStreamPut(music->stream, music->buffer, (int)music->buffer_size) < 0) {
422 return -1;
423 }
424
425 /* Check to see if we're done now */
426 if (!mikmod.Player_Active()) {
427 if (music->play_count == 1) {
428 music->play_count = 0;
429 SDL_AudioStreamFlush(music->stream);
430 } else {
431 int play_count = -1;
432 if (music->play_count > 0) {
433 play_count = (music->play_count - 1);
434 }
435 if (MIKMOD_Play(music, play_count) < 0) {
436 return -1;
437 }
438 }
439 }
440 return 0;
441 }
442 static int MIKMOD_GetAudio(void *context, void *data, int bytes)
443 {
444 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MIKMOD_GetSome);
445 }
446
447 /* Jump to a given order */
448 static int MIKMOD_Jump(void *context, int order)
449 {
450 (void)context;
451 mikmod.Player_SetPosition((UWORD)order);
452 return 0;
453 }
454
455 /* Jump (seek) to a given position (time is in seconds) */
456 static int MIKMOD_Seek(void *context, double position)
457 {
458 (void)context;
459 /* FIXME: WRONG: THIS IS NOT A TIME SEEK */
460 mikmod.Player_SetPosition((UWORD)position);
461 return 0;
462 }
463
464 /* Stop playback of a stream previously started with MOD_play() */
465 static void MIKMOD_Stop(void *context)
466 {
467 (void)context;
468 mikmod.Player_Stop();
469 }
470
471 static const char* MIKMOD_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
472 {
473 MIKMOD_Music *music = (MIKMOD_Music *)context;
474 return meta_tags_get(&music->tags, tag_type);
475 }
476
477 /* Close the given MOD stream */
478 static void MIKMOD_Delete(void *context)
479 {
480 MIKMOD_Music *music = (MIKMOD_Music *)context;
481
482 meta_tags_clear(&music->tags);
483 if (music->module) {
484 mikmod.Player_Free(music->module);
485 }
486 if (music->stream) {
487 SDL_FreeAudioStream(music->stream);
488 }
489 if (music->buffer) {
490 SDL_free(music->buffer);
491 }
492 SDL_free(music);
493 }
494
495 Mix_MusicInterface Mix_MusicInterface_MIKMOD =
496 {
497 "MIKMOD",
498 MIX_MUSIC_MIKMOD,
499 MUS_MOD,
500 SDL_FALSE,
501 SDL_FALSE,
502
503 MIKMOD_Load,
504 MIKMOD_Open,
505 MIKMOD_CreateFromRW,
506 NULL, /* CreateFromFile */
507 MIKMOD_SetVolume,
508 MIKMOD_GetVolume,
509 MIKMOD_Play,
510 MIKMOD_IsPlaying,
511 MIKMOD_GetAudio,
512 MIKMOD_Jump,
513 MIKMOD_Seek,
514 NULL, /* Tell */
515 NULL, /* Duration */
516 NULL, /* LoopStart */
517 NULL, /* LoopEnd */
518 NULL, /* LoopLength */
519 MIKMOD_GetMetaTag,
520 NULL, /* Pause */
521 NULL, /* Resume */
522 MIKMOD_Stop,
523 MIKMOD_Delete,
524 MIKMOD_Close,
525 MIKMOD_Unload
526 };
527
528 #endif /* MUSIC_MOD_MIKMOD */
529
530 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MOD files with libmikmod */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MIKMOD;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MOD_MODPLUG
22
23 #include "SDL_loadso.h"
24
25 #include "music_modplug.h"
26
27 #ifdef MODPLUG_HEADER
28 #include MODPLUG_HEADER
29 #else
30 #include <libmodplug/modplug.h>
31 #endif
32
33 typedef struct {
34 int loaded;
35 void *handle;
36
37 ModPlugFile* (*ModPlug_Load)(const void* data, int size);
38 void (*ModPlug_Unload)(ModPlugFile* file);
39 int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size);
40 void (*ModPlug_Seek)(ModPlugFile* file, int millisecond);
41 void (*ModPlug_SeekOrder)(ModPlugFile* file, int order);
42 int (*ModPlug_GetLength)(ModPlugFile* file);
43 void (*ModPlug_GetSettings)(ModPlug_Settings* settings);
44 void (*ModPlug_SetSettings)(const ModPlug_Settings* settings);
45 void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol);
46 const char* (*ModPlug_GetName)(ModPlugFile* file);
47 } modplug_loader;
48
49 static modplug_loader modplug = {
50 0, NULL
51 };
52
53
54 static ModPlug_Settings settings;
55
56 #ifdef MODPLUG_DYNAMIC
57 #define FUNCTION_LOADER(FUNC, SIG) \
58 modplug.FUNC = (SIG) SDL_LoadFunction(modplug.handle, #FUNC); \
59 if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; }
60 #else
61 #define FUNCTION_LOADER(FUNC, SIG) \
62 modplug.FUNC = FUNC;
63 #endif
64
65 static int MODPLUG_Load(void)
66 {
67 if (modplug.loaded == 0) {
68 #ifdef MODPLUG_DYNAMIC
69 modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC);
70 if (modplug.handle == NULL) {
71 return -1;
72 }
73 #elif defined(__MACOSX__)
74 extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import));
75 if (ModPlug_Load == NULL) {
76 /* Missing weakly linked framework */
77 Mix_SetError("Missing modplug.framework");
78 return -1;
79 }
80 #endif
81 FUNCTION_LOADER(ModPlug_Load, ModPlugFile* (*)(const void* data, int size))
82 FUNCTION_LOADER(ModPlug_Unload, void (*)(ModPlugFile* file))
83 FUNCTION_LOADER(ModPlug_Read, int (*)(ModPlugFile* file, void* buffer, int size))
84 FUNCTION_LOADER(ModPlug_Seek, void (*)(ModPlugFile* file, int millisecond))
85 FUNCTION_LOADER(ModPlug_SeekOrder, void (*)(ModPlugFile* file, int order))
86 FUNCTION_LOADER(ModPlug_GetLength, int (*)(ModPlugFile* file))
87 FUNCTION_LOADER(ModPlug_GetSettings, void (*)(ModPlug_Settings* settings))
88 FUNCTION_LOADER(ModPlug_SetSettings, void (*)(const ModPlug_Settings* settings))
89 FUNCTION_LOADER(ModPlug_SetMasterVolume, void (*)(ModPlugFile* file,unsigned int cvol))
90 FUNCTION_LOADER(ModPlug_GetName, const char* (*)(ModPlugFile* file))
91 }
92 ++modplug.loaded;
93
94 return 0;
95 }
96
97 static void MODPLUG_Unload(void)
98 {
99 if (modplug.loaded == 0) {
100 return;
101 }
102 if (modplug.loaded == 1) {
103 #ifdef MODPLUG_DYNAMIC
104 SDL_UnloadObject(modplug.handle);
105 #endif
106 }
107 --modplug.loaded;
108 }
109
110
111 typedef struct
112 {
113 int volume;
114 int play_count;
115 ModPlugFile *file;
116 SDL_AudioStream *stream;
117 void *buffer;
118 int buffer_size;
119 Mix_MusicMetaTags tags;
120 } MODPLUG_Music;
121
122
123 static int MODPLUG_Seek(void *context, double position);
124 static void MODPLUG_Delete(void *context);
125
126 static int MODPLUG_Open(const SDL_AudioSpec *spec)
127 {
128 /* ModPlug supports U8 or S16 audio output */
129 modplug.ModPlug_GetSettings(&settings);
130 settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
131 if (spec->channels == 1) {
132 settings.mChannels = 1;
133 } else {
134 settings.mChannels = 2;
135 }
136 if (SDL_AUDIO_BITSIZE(spec->format) == 8) {
137 settings.mBits = 8;
138 } else {
139 settings.mBits = 16;
140 }
141 if (spec->freq >= 44100) {
142 settings.mFrequency = 44100;
143 } else if (spec->freq >= 22050) {
144 settings.mFrequency = 22050;
145 } else {
146 settings.mFrequency = 11025;
147 }
148 settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
149 settings.mReverbDepth = 0;
150 settings.mReverbDelay = 100;
151 settings.mBassAmount = 0;
152 settings.mBassRange = 50;
153 settings.mSurroundDepth = 0;
154 settings.mSurroundDelay = 10;
155 settings.mLoopCount = -1;
156 modplug.ModPlug_SetSettings(&settings);
157 return 0;
158 }
159
160 /* Load a modplug stream from an SDL_RWops object */
161 void *MODPLUG_CreateFromRW(SDL_RWops *src, int freesrc)
162 {
163 MODPLUG_Music *music;
164 void *buffer;
165 size_t size;
166
167 music = (MODPLUG_Music *)SDL_calloc(1, sizeof(*music));
168 if (!music) {
169 SDL_OutOfMemory();
170 return NULL;
171 }
172
173 music->volume = MIX_MAX_VOLUME;
174
175 music->stream = SDL_NewAudioStream((settings.mBits == 8) ? AUDIO_U8 : AUDIO_S16SYS, (Uint8)settings.mChannels, settings.mFrequency,
176 music_spec.format, music_spec.channels, music_spec.freq);
177 if (!music->stream) {
178 MODPLUG_Delete(music);
179 return NULL;
180 }
181
182 music->buffer_size = music_spec.samples * (settings.mBits / 8) * settings.mChannels;
183 music->buffer = SDL_malloc((size_t)music->buffer_size);
184 if (!music->buffer) {
185 MODPLUG_Delete(music);
186 return NULL;
187 }
188
189 buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE);
190 if (buffer) {
191 music->file = modplug.ModPlug_Load(buffer, (int)size);
192 if (!music->file) {
193 Mix_SetError("ModPlug_Load failed");
194 }
195 SDL_free(buffer);
196 }
197
198 if (!music->file) {
199 MODPLUG_Delete(music);
200 return NULL;
201 }
202
203 meta_tags_init(&music->tags);
204 meta_tags_set(&music->tags, MIX_META_TITLE, modplug.ModPlug_GetName(music->file));
205
206 if (freesrc) {
207 SDL_RWclose(src);
208 }
209 return music;
210 }
211
212 /* Set the volume for a modplug stream */
213 static void MODPLUG_SetVolume(void *context, int volume)
214 {
215 MODPLUG_Music *music = (MODPLUG_Music *)context;
216 music->volume = volume;
217 modplug.ModPlug_SetMasterVolume(music->file, (unsigned int)volume * 2); /* 0-512, reduced to 0-256 to prevent clipping */
218 }
219
220 /* Get the volume for a modplug stream */
221 static int MODPLUG_GetVolume(void *context)
222 {
223 MODPLUG_Music *music = (MODPLUG_Music *)context;
224 return music->volume;
225 }
226
227 /* Start playback of a given modplug stream */
228 static int MODPLUG_Play(void *context, int play_count)
229 {
230 MODPLUG_Music *music = (MODPLUG_Music *)context;
231 music->play_count = play_count;
232 return MODPLUG_Seek(music, 0.0);
233 }
234
235 /* Play some of a stream previously started with modplug_play() */
236 static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
237 {
238 MODPLUG_Music *music = (MODPLUG_Music *)context;
239 int filled, amount;
240
241 filled = SDL_AudioStreamGet(music->stream, data, bytes);
242 if (filled != 0) {
243 return filled;
244 }
245
246 if (!music->play_count) {
247 /* All done */
248 *done = SDL_TRUE;
249 return 0;
250 }
251
252 amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size);
253 if (amount > 0) {
254 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
255 return -1;
256 }
257 } else {
258 if (music->play_count == 1) {
259 music->play_count = 0;
260 SDL_AudioStreamFlush(music->stream);
261 } else {
262 int play_count = -1;
263 if (music->play_count > 0) {
264 play_count = (music->play_count - 1);
265 }
266 if (MODPLUG_Play(music, play_count) < 0) {
267 return -1;
268 }
269 }
270 }
271 return 0;
272 }
273
274 static int MODPLUG_GetAudio(void *context, void *data, int bytes)
275 {
276 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MODPLUG_GetSome);
277 }
278
279 /* Jump to a given order */
280 static int MODPLUG_Jump(void *context, int order)
281 {
282 MODPLUG_Music *music = (MODPLUG_Music *)context;
283 modplug.ModPlug_SeekOrder(music->file, order);
284 return 0;
285 }
286
287 /* Jump (seek) to a given position */
288 static int MODPLUG_Seek(void *context, double position)
289 {
290 MODPLUG_Music *music = (MODPLUG_Music *)context;
291 modplug.ModPlug_Seek(music->file, (int)(position*1000));
292 return 0;
293 }
294
295 /* Return music duration in seconds */
296 static double MODPLUG_Duration(void *context)
297 {
298 MODPLUG_Music *music = (MODPLUG_Music *)context;
299 return modplug.ModPlug_GetLength(music->file) / 1000.0;
300 }
301
302 static const char* MODPLUG_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
303 {
304 MODPLUG_Music *music = (MODPLUG_Music *)context;
305 return meta_tags_get(&music->tags, tag_type);
306 }
307
308 /* Close the given modplug stream */
309 static void MODPLUG_Delete(void *context)
310 {
311 MODPLUG_Music *music = (MODPLUG_Music *)context;
312 meta_tags_clear(&music->tags);
313 if (music->file) {
314 modplug.ModPlug_Unload(music->file);
315 }
316 if (music->stream) {
317 SDL_FreeAudioStream(music->stream);
318 }
319 if (music->buffer) {
320 SDL_free(music->buffer);
321 }
322 SDL_free(music);
323 }
324
325 Mix_MusicInterface Mix_MusicInterface_MODPLUG =
326 {
327 "MODPLUG",
328 MIX_MUSIC_MODPLUG,
329 MUS_MOD,
330 SDL_FALSE,
331 SDL_FALSE,
332
333 MODPLUG_Load,
334 MODPLUG_Open,
335 MODPLUG_CreateFromRW,
336 NULL, /* CreateFromFile */
337 MODPLUG_SetVolume,
338 MODPLUG_GetVolume,
339 MODPLUG_Play,
340 NULL, /* IsPlaying */
341 MODPLUG_GetAudio,
342 MODPLUG_Jump,
343 MODPLUG_Seek,
344 NULL, /* Tell */
345 MODPLUG_Duration,
346 NULL, /* LoopStart */
347 NULL, /* LoopEnd */
348 NULL, /* LoopLength */
349 MODPLUG_GetMetaTag,
350 NULL, /* Pause */
351 NULL, /* Resume */
352 NULL, /* Stop */
353 MODPLUG_Delete,
354 NULL, /* Close */
355 MODPLUG_Unload
356 };
357
358 #endif /* MUSIC_MOD_MODPLUG */
359
360 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MOD files with libmodplug */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MODPLUG;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with mpg123 */
22
23 #ifdef MUSIC_MP3_MPG123
24
25 #include "SDL_loadso.h"
26 #include "SDL_assert.h"
27
28 #include "music_mpg123.h"
29 #include "mp3utils.h"
30
31 #include <stdio.h> /* For SEEK_SET */
32 #include <mpg123.h>
33 #ifdef _MSC_VER
34 typedef ptrdiff_t MIX_SSIZE_T;
35 #else
36 typedef ssize_t MIX_SSIZE_T;
37 #endif
38
39
40 typedef struct {
41 int loaded;
42 void *handle;
43
44 int (*mpg123_close)(mpg123_handle *mh);
45 void (*mpg123_delete)(mpg123_handle *mh);
46 void (*mpg123_exit)(void);
47 int (*mpg123_format)( mpg123_handle *mh, long rate, int channels, int encodings );
48 int (*mpg123_format_none)(mpg123_handle *mh);
49 int (*mpg123_getformat)( mpg123_handle *mh, long *rate, int *channels, int *encoding );
50 int (*mpg123_init)(void);
51 mpg123_handle *(*mpg123_new)(const char* decoder, int *error);
52 int (*mpg123_open_handle)(mpg123_handle *mh, void *iohandle);
53 const char* (*mpg123_plain_strerror)(int errcode);
54 void (*mpg123_rates)(const long **list, size_t *number);
55 int (*mpg123_read)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done );
56 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*) );
57 off_t (*mpg123_seek)( mpg123_handle *mh, off_t sampleoff, int whence );
58 off_t (*mpg123_tell)( mpg123_handle *mh);
59 off_t (*mpg123_length)(mpg123_handle *mh);
60 const char* (*mpg123_strerror)(mpg123_handle *mh);
61 } mpg123_loader;
62
63 static mpg123_loader mpg123 = {
64 0, NULL
65 };
66
67 #ifdef MPG123_DYNAMIC
68 #define FUNCTION_LOADER(FUNC, SIG) \
69 mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \
70 if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; }
71 #else
72 #define FUNCTION_LOADER(FUNC, SIG) \
73 mpg123.FUNC = FUNC;
74 #endif
75
76 static int MPG123_Load(void)
77 {
78 if (mpg123.loaded == 0) {
79 #ifdef MPG123_DYNAMIC
80 mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC);
81 if (mpg123.handle == NULL) {
82 return -1;
83 }
84 #elif defined(__MACOSX__)
85 extern int mpg123_init(void) __attribute__((weak_import));
86 if (mpg123_init == NULL)
87 {
88 /* Missing weakly linked framework */
89 Mix_SetError("Missing mpg123.framework");
90 return -1;
91 }
92 #endif
93 FUNCTION_LOADER(mpg123_close, int (*)(mpg123_handle *mh))
94 FUNCTION_LOADER(mpg123_delete, void (*)(mpg123_handle *mh))
95 FUNCTION_LOADER(mpg123_exit, void (*)(void))
96 FUNCTION_LOADER(mpg123_format, int (*)( mpg123_handle *mh, long rate, int channels, int encodings ))
97 FUNCTION_LOADER(mpg123_format_none, int (*)(mpg123_handle *mh))
98 FUNCTION_LOADER(mpg123_getformat, int (*)( mpg123_handle *mh, long *rate, int *channels, int *encoding ))
99 FUNCTION_LOADER(mpg123_init, int (*)(void))
100 FUNCTION_LOADER(mpg123_new, mpg123_handle *(*)(const char* decoder, int *error))
101 FUNCTION_LOADER(mpg123_open_handle, int (*)(mpg123_handle *mh, void *iohandle))
102 FUNCTION_LOADER(mpg123_plain_strerror, const char* (*)(int errcode))
103 FUNCTION_LOADER(mpg123_rates, void (*)(const long **list, size_t *number))
104 FUNCTION_LOADER(mpg123_read, int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done ))
105 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*) ))
106 FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence ))
107 FUNCTION_LOADER(mpg123_tell, off_t (*)( mpg123_handle *mh))
108 FUNCTION_LOADER(mpg123_length, off_t (*)(mpg123_handle *mh))
109 FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh))
110 }
111 ++mpg123.loaded;
112
113 return 0;
114 }
115
116 static void MPG123_Unload(void)
117 {
118 if (mpg123.loaded == 0) {
119 return;
120 }
121 if (mpg123.loaded == 1) {
122 #ifdef MPG123_DYNAMIC
123 SDL_UnloadObject(mpg123.handle);
124 #endif
125 }
126 --mpg123.loaded;
127 }
128
129
130 typedef struct
131 {
132 struct mp3file_t mp3file;
133 int play_count;
134 int freesrc;
135 int volume;
136
137 mpg123_handle* handle;
138 SDL_AudioStream *stream;
139 unsigned char *buffer;
140 size_t buffer_size;
141 long sample_rate;
142 off_t total_length;
143 } MPG123_Music;
144
145
146 static int MPG123_Seek(void *context, double secs);
147 static void MPG123_Delete(void *context);
148
149
150 static int mpg123_format_to_sdl(int fmt)
151 {
152 switch (fmt) {
153 case MPG123_ENC_SIGNED_8: return AUDIO_S8;
154 case MPG123_ENC_UNSIGNED_8: return AUDIO_U8;
155 case MPG123_ENC_SIGNED_16: return AUDIO_S16SYS;
156 case MPG123_ENC_UNSIGNED_16: return AUDIO_U16SYS;
157 case MPG123_ENC_SIGNED_32: return AUDIO_S32SYS;
158 case MPG123_ENC_FLOAT_32: return AUDIO_F32SYS;
159 default: return -1;
160 }
161 }
162
163 /*#define DEBUG_MPG123*/
164 #ifdef DEBUG_MPG123
165 static const char *mpg123_format_str(int fmt)
166 {
167 switch (fmt) {
168 #define f(x) case x: return #x;
169 f(MPG123_ENC_UNSIGNED_8)
170 f(MPG123_ENC_UNSIGNED_16)
171 f(MPG123_ENC_SIGNED_8)
172 f(MPG123_ENC_SIGNED_16)
173 f(MPG123_ENC_SIGNED_32)
174 f(MPG123_ENC_FLOAT_32)
175 #undef f
176 }
177 return "unknown";
178 }
179 #endif
180
181 static char const* mpg_err(mpg123_handle* mpg, int result)
182 {
183 char const* err = "unknown error";
184
185 if (mpg && result == MPG123_ERR) {
186 err = mpg123.mpg123_strerror(mpg);
187 } else {
188 err = mpg123.mpg123_plain_strerror(result);
189 }
190 return err;
191 }
192
193 /* we're gonna override mpg123's I/O with these wrappers for RWops */
194 static MIX_SSIZE_T rwops_read(void* p, void* dst, size_t n)
195 {
196 return (MIX_SSIZE_T)MP3_RWread((struct mp3file_t *)p, dst, 1, n);
197 }
198
199 static off_t rwops_seek(void* p, off_t offset, int whence)
200 {
201 return (off_t)MP3_RWseek((struct mp3file_t *)p, (Sint64)offset, whence);
202 }
203
204 static void rwops_cleanup(void* p)
205 {
206 (void)p;
207 /* do nothing, we will free the file later */
208 }
209
210
211 static int MPG123_Open(const SDL_AudioSpec *spec)
212 {
213 (void)spec;
214 if (mpg123.mpg123_init() != MPG123_OK) {
215 Mix_SetError("mpg123_init() failed");
216 return -1;
217 }
218 return 0;
219 }
220
221 static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc)
222 {
223 MPG123_Music *music;
224 int result, format, channels, encoding;
225 long rate;
226 const long *rates;
227 size_t i, num_rates;
228
229 music = (MPG123_Music*)SDL_calloc(1, sizeof(*music));
230 if (!music) {
231 SDL_OutOfMemory();
232 return NULL;
233 }
234 music->volume = MIX_MAX_VOLUME;
235
236 if (MP3_RWinit(&music->mp3file, src) < 0) {
237 SDL_free(music);
238 return NULL;
239 }
240 if (mp3_skiptags(&music->mp3file, SDL_TRUE) < 0) {
241 SDL_free(music);
242 Mix_SetError("music_mpg123: corrupt mp3 file (bad tags.)");
243 return NULL;
244 }
245
246 /* Just assume 16-bit 2 channel audio for now */
247 music->buffer_size = music_spec.samples * sizeof(Sint16) * 2;
248 music->buffer = (unsigned char *)SDL_malloc(music->buffer_size);
249 if (!music->buffer) {
250 MPG123_Delete(music);
251 SDL_OutOfMemory();
252 return NULL;
253 }
254
255 music->handle = mpg123.mpg123_new(0, &result);
256 if (result != MPG123_OK) {
257 MPG123_Delete(music);
258 Mix_SetError("mpg123_new failed");
259 return NULL;
260 }
261
262 result = mpg123.mpg123_replace_reader_handle(
263 music->handle,
264 rwops_read, rwops_seek, rwops_cleanup
265 );
266 if (result != MPG123_OK) {
267 MPG123_Delete(music);
268 Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result));
269 return NULL;
270 }
271
272 result = mpg123.mpg123_format_none(music->handle);
273 if (result != MPG123_OK) {
274 MPG123_Delete(music);
275 Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result));
276 return NULL;
277 }
278
279 mpg123.mpg123_rates(&rates, &num_rates);
280 for (i = 0; i < num_rates; ++i) {
281 const int channels = (MPG123_MONO|MPG123_STEREO);
282 const int formats = (MPG123_ENC_SIGNED_8 |
283 MPG123_ENC_UNSIGNED_8 |
284 MPG123_ENC_SIGNED_16 |
285 MPG123_ENC_UNSIGNED_16 |
286 MPG123_ENC_SIGNED_32 |
287 MPG123_ENC_FLOAT_32);
288
289 mpg123.mpg123_format(music->handle, rates[i], channels, formats);
290 }
291
292 result = mpg123.mpg123_open_handle(music->handle, &music->mp3file);
293 if (result != MPG123_OK) {
294 MPG123_Delete(music);
295 Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result));
296 return NULL;
297 }
298
299 result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
300 if (result != MPG123_OK) {
301 MPG123_Delete(music);
302 Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
303 return NULL;
304 }
305 #ifdef DEBUG_MPG123
306 printf("MPG123 format: %s, channels: %d, rate: %ld\n",
307 mpg123_format_str(encoding), channels, rate);
308 #endif
309
310 format = mpg123_format_to_sdl(encoding);
311 SDL_assert(format != -1);
312 music->sample_rate = rate;
313
314 music->stream = SDL_NewAudioStream((SDL_AudioFormat)format, (Uint8)channels, (int)rate,
315 music_spec.format, music_spec.channels, music_spec.freq);
316 if (!music->stream) {
317 MPG123_Delete(music);
318 return NULL;
319 }
320
321 music->total_length = mpg123.mpg123_length(music->handle);
322
323 music->freesrc = freesrc;
324 return music;
325 }
326
327 static void MPG123_SetVolume(void *context, int volume)
328 {
329 MPG123_Music *music = (MPG123_Music *)context;
330 music->volume = volume;
331 }
332
333 static int MPG123_GetVolume(void *context)
334 {
335 MPG123_Music *music = (MPG123_Music *)context;
336 return music->volume;
337 }
338
339 static int MPG123_Play(void *context, int play_count)
340 {
341 MPG123_Music *music = (MPG123_Music *)context;
342 music->play_count = play_count;
343 return MPG123_Seek(music, 0.0);
344 }
345
346 /* read some mp3 stream data and convert it for output */
347 static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
348 {
349 MPG123_Music *music = (MPG123_Music *)context;
350 int filled, result;
351 size_t amount;
352 long rate;
353 int channels, encoding, format;
354
355 if (music->stream) {
356 filled = SDL_AudioStreamGet(music->stream, data, bytes);
357 if (filled != 0) {
358 return filled;
359 }
360 }
361
362 if (!music->play_count) {
363 /* All done */
364 *done = SDL_TRUE;
365 return 0;
366 }
367
368 result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount);
369 switch (result) {
370 case MPG123_OK:
371 if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) {
372 return -1;
373 }
374 break;
375
376 case MPG123_NEW_FORMAT:
377 result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
378 if (result != MPG123_OK) {
379 Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
380 return -1;
381 }
382 #ifdef DEBUG_MPG123
383 printf("MPG123 format: %s, channels: %d, rate: %ld\n",
384 mpg123_format_str(encoding), channels, rate);
385 #endif
386
387 format = mpg123_format_to_sdl(encoding);
388 SDL_assert(format != -1);
389
390 if (music->stream) {
391 SDL_FreeAudioStream(music->stream);
392 }
393 music->stream = SDL_NewAudioStream((SDL_AudioFormat)format, (Uint8)channels, (int)rate,
394 music_spec.format, music_spec.channels, music_spec.freq);
395 if (!music->stream) {
396 return -1;
397 }
398 music->sample_rate = rate;
399 break;
400
401 case MPG123_DONE:
402 if (music->play_count == 1) {
403 music->play_count = 0;
404 SDL_AudioStreamFlush(music->stream);
405 } else {
406 int play_count = -1;
407 if (music->play_count > 0) {
408 play_count = (music->play_count - 1);
409 }
410 if (MPG123_Play(music, play_count) < 0) {
411 return -1;
412 }
413 }
414 break;
415 default:
416 Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
417 return -1;
418 }
419 return 0;
420 }
421 static int MPG123_GetAudio(void *context, void *data, int bytes)
422 {
423 MPG123_Music *music = (MPG123_Music *)context;
424 return music_pcm_getaudio(context, data, bytes, music->volume, MPG123_GetSome);
425 }
426
427 static int MPG123_Seek(void *context, double secs)
428 {
429 MPG123_Music *music = (MPG123_Music *)context;
430 off_t offset = (off_t)(music->sample_rate * secs);
431
432 if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) {
433 return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset));
434 }
435 return 0;
436 }
437
438 static double MPG123_Tell(void *context)
439 {
440 MPG123_Music *music = (MPG123_Music *)context;
441 off_t offset = 0;
442 if (!music->sample_rate) {
443 return 0.0;
444 }
445 if ((offset = mpg123.mpg123_tell(music->handle)) < 0) {
446 return Mix_SetError("mpg123_tell: %s", mpg_err(music->handle, (int)-offset));
447 }
448 return (double)offset / music->sample_rate;
449 }
450
451 /* Return music duration in seconds */
452 static double MPG123_Duration(void *context)
453 {
454 MPG123_Music *music = (MPG123_Music *)context;
455 if (music->total_length < 0) {
456 return -1.0;
457 }
458 return (double)music->total_length / music->sample_rate;
459 }
460
461 static void MPG123_Delete(void *context)
462 {
463 MPG123_Music *music = (MPG123_Music *)context;
464
465 if (music->handle) {
466 mpg123.mpg123_close(music->handle);
467 mpg123.mpg123_delete(music->handle);
468 }
469 if (music->stream) {
470 SDL_FreeAudioStream(music->stream);
471 }
472 if (music->buffer) {
473 SDL_free(music->buffer);
474 }
475 if (music->freesrc) {
476 SDL_RWclose(music->mp3file.src);
477 }
478 SDL_free(music);
479 }
480
481 static void MPG123_Close(void)
482 {
483 mpg123.mpg123_exit();
484 }
485
486 Mix_MusicInterface Mix_MusicInterface_MPG123 =
487 {
488 "MPG123",
489 MIX_MUSIC_MPG123,
490 MUS_MP3,
491 SDL_FALSE,
492 SDL_FALSE,
493
494 MPG123_Load,
495 MPG123_Open,
496 MPG123_CreateFromRW,
497 NULL, /* CreateFromFile */
498 MPG123_SetVolume,
499 MPG123_GetVolume,
500 MPG123_Play,
501 NULL, /* IsPlaying */
502 MPG123_GetAudio,
503 NULL, /* Jump */
504 MPG123_Seek,
505 MPG123_Tell,
506 MPG123_Duration,
507 NULL, /* LoopStart */
508 NULL, /* LoopEnd */
509 NULL, /* LoopLength */
510 NULL, /* GetMetaTag */
511 NULL, /* Pause */
512 NULL, /* Resume */
513 NULL, /* Stop */
514 MPG123_Delete,
515 MPG123_Close,
516 MPG123_Unload
517 };
518
519 #endif /* MUSIC_MP3_MPG123 */
520
521 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MP3 files with mpg123 */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_MPG123;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MID_NATIVE
22
23 /* This file supports playing MIDI files with OS APIs */
24
25 #include "music_nativemidi.h"
26 #include "native_midi/native_midi.h"
27
28
29 static void *NATIVEMIDI_CreateFromRW(SDL_RWops *src, int freesrc)
30 {
31 NativeMidiSong *music = native_midi_loadsong_RW(src, freesrc);
32 if (!music) {
33 Mix_SetError("%s", native_midi_error());
34 }
35 return music;
36 }
37
38 static int NATIVEMIDI_Play(void *context, int play_count)
39 {
40 NativeMidiSong *music = (NativeMidiSong *)context;
41 int loops = play_count;
42 if (loops > 0) {
43 --loops;
44 }
45 native_midi_start(music, loops);
46 return 0;
47 }
48
49 static void NATIVEMIDI_SetVolume(void *context, int volume)
50 {
51 (void)context;
52 native_midi_setvolume(volume);
53 }
54
55 static SDL_bool NATIVEMIDI_IsPlaying(void *context)
56 {
57 (void)context;
58 return native_midi_active() ? SDL_TRUE : SDL_FALSE;
59 }
60
61 static void NATIVEMIDI_Pause(void *context)
62 {
63 (void)context;
64 native_midi_pause();
65 }
66
67 static void NATIVEMIDI_Resume(void *context)
68 {
69 (void)context;
70 native_midi_resume();
71 }
72
73 static void NATIVEMIDI_Stop(void *context)
74 {
75 (void)context;
76 native_midi_stop();
77 }
78
79 static void NATIVEMIDI_Delete(void *context)
80 {
81 NativeMidiSong *music = (NativeMidiSong *)context;
82 native_midi_freesong(music);
83 }
84
85 Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI =
86 {
87 "NATIVEMIDI",
88 MIX_MUSIC_NATIVEMIDI,
89 MUS_MID,
90 SDL_FALSE,
91 SDL_FALSE,
92
93 NULL, /* Load */
94 NULL, /* Open */
95 NATIVEMIDI_CreateFromRW,
96 NULL, /* CreateFromFile */
97 NATIVEMIDI_SetVolume,
98 NULL, /* GetVolume */
99 NATIVEMIDI_Play,
100 NATIVEMIDI_IsPlaying,
101 NULL, /* GetAudio */
102 NULL, /* Jump */
103 NULL, /* Seek */
104 NULL, /* Tell */
105 NULL, /* Duration */
106 NULL, /* LoopStart */
107 NULL, /* LoopEnd */
108 NULL, /* LoopLength */
109 NULL, /* GetMetaTag */
110 NATIVEMIDI_Pause,
111 NATIVEMIDI_Resume,
112 NATIVEMIDI_Stop,
113 NATIVEMIDI_Delete,
114 NULL, /* Close */
115 NULL /* Unload */
116 };
117
118 #endif /* MUSIC_MID_NATIVE */
119
120 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with OS APIs */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_OGG
22
23 /* This file supports Ogg Vorbis music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_ogg.h"
28 #include "utils.h"
29
30 #define OV_EXCLUDE_STATIC_CALLBACKS
31 #if defined(OGG_HEADER)
32 #include OGG_HEADER
33 #elif defined(OGG_USE_TREMOR)
34 #include <tremor/ivorbisfile.h>
35 #else
36 #include <vorbis/vorbisfile.h>
37 #endif
38
39
40 typedef struct {
41 int loaded;
42 void *handle;
43 int (*ov_clear)(OggVorbis_File *vf);
44 vorbis_info *(*ov_info)(OggVorbis_File *vf,int link);
45 vorbis_comment *(*ov_comment)(OggVorbis_File *vf,int link);
46 int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks);
47 ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i);
48 #ifdef OGG_USE_TREMOR
49 long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream);
50 int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos);
51 ogg_int64_t (*ov_time_tell)(OggVorbis_File *vf);
52 ogg_int64_t (*ov_time_total)(OggVorbis_File *vf, int i);
53 #else
54 long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream);
55 int (*ov_time_seek)(OggVorbis_File *vf,double pos);
56 double (*ov_time_tell)(OggVorbis_File *vf);
57 double (*ov_time_total)(OggVorbis_File *vf, int i);
58 #endif
59 int (*ov_pcm_seek)(OggVorbis_File *vf, ogg_int64_t pos);
60 ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf);
61 } vorbis_loader;
62
63 static vorbis_loader vorbis = {
64 0, NULL
65 };
66
67 #ifdef OGG_DYNAMIC
68 #define FUNCTION_LOADER(FUNC, SIG) \
69 vorbis.FUNC = (SIG) SDL_LoadFunction(vorbis.handle, #FUNC); \
70 if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; }
71 #else
72 #define FUNCTION_LOADER(FUNC, SIG) \
73 vorbis.FUNC = FUNC;
74 #endif
75
76 static int OGG_Load(void)
77 {
78 if (vorbis.loaded == 0) {
79 #ifdef OGG_DYNAMIC
80 vorbis.handle = SDL_LoadObject(OGG_DYNAMIC);
81 if (vorbis.handle == NULL) {
82 return -1;
83 }
84 #elif defined(__MACOSX__)
85 extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import));
86 if (ov_open_callbacks == NULL)
87 {
88 /* Missing weakly linked framework */
89 Mix_SetError("Missing Vorbis.framework");
90 return -1;
91 }
92 #endif
93 FUNCTION_LOADER(ov_clear, int (*)(OggVorbis_File *))
94 FUNCTION_LOADER(ov_info, vorbis_info *(*)(OggVorbis_File *,int))
95 FUNCTION_LOADER(ov_comment, vorbis_comment *(*)(OggVorbis_File *,int))
96 FUNCTION_LOADER(ov_open_callbacks, int (*)(void *,OggVorbis_File *,const char *,long,ov_callbacks))
97 FUNCTION_LOADER(ov_pcm_total, ogg_int64_t (*)(OggVorbis_File *,int))
98 #ifdef OGG_USE_TREMOR
99 FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int *))
100 FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,ogg_int64_t))
101 FUNCTION_LOADER(ov_time_tell, ogg_int64_t (*)(OggVorbis_File *))
102 FUNCTION_LOADER(ov_time_total, ogg_int64_t (*)(OggVorbis_File *, int))
103 #else
104 FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int,int,int,int *))
105 FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,double))
106 FUNCTION_LOADER(ov_time_tell, double (*)(OggVorbis_File *))
107 FUNCTION_LOADER(ov_time_total, double (*)(OggVorbis_File *, int))
108 #endif
109 FUNCTION_LOADER(ov_pcm_seek, int (*)(OggVorbis_File *,ogg_int64_t))
110 FUNCTION_LOADER(ov_pcm_tell, ogg_int64_t (*)(OggVorbis_File *))
111 }
112 ++vorbis.loaded;
113
114 return 0;
115 }
116
117 static void OGG_Unload(void)
118 {
119 if (vorbis.loaded == 0) {
120 return;
121 }
122 if (vorbis.loaded == 1) {
123 #ifdef OGG_DYNAMIC
124 SDL_UnloadObject(vorbis.handle);
125 #endif
126 }
127 --vorbis.loaded;
128 }
129
130
131 typedef struct {
132 SDL_RWops *src;
133 int freesrc;
134 int play_count;
135 int volume;
136 OggVorbis_File vf;
137 vorbis_info vi;
138 int section;
139 SDL_AudioStream *stream;
140 char *buffer;
141 int buffer_size;
142 int loop;
143 ogg_int64_t loop_start;
144 ogg_int64_t loop_end;
145 ogg_int64_t loop_len;
146 Mix_MusicMetaTags tags;
147 } OGG_music;
148
149
150 static int set_ov_error(const char *function, int error)
151 {
152 #define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break;
153 switch (error) {
154 HANDLE_ERROR_CASE(OV_FALSE)
155 HANDLE_ERROR_CASE(OV_EOF)
156 HANDLE_ERROR_CASE(OV_HOLE)
157 HANDLE_ERROR_CASE(OV_EREAD)
158 HANDLE_ERROR_CASE(OV_EFAULT)
159 HANDLE_ERROR_CASE(OV_EIMPL)
160 HANDLE_ERROR_CASE(OV_EINVAL)
161 HANDLE_ERROR_CASE(OV_ENOTVORBIS)
162 HANDLE_ERROR_CASE(OV_EBADHEADER)
163 HANDLE_ERROR_CASE(OV_EVERSION)
164 HANDLE_ERROR_CASE(OV_ENOTAUDIO)
165 HANDLE_ERROR_CASE(OV_EBADPACKET)
166 HANDLE_ERROR_CASE(OV_EBADLINK)
167 HANDLE_ERROR_CASE(OV_ENOSEEK)
168 default:
169 Mix_SetError("%s: unknown error %d\n", function, error);
170 break;
171 }
172 return -1;
173 }
174
175 static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
176 {
177 return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb);
178 }
179
180 static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
181 {
182 return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence);
183 }
184
185 static long sdl_tell_func(void *datasource)
186 {
187 return (long)SDL_RWtell((SDL_RWops*)datasource);
188 }
189
190 static int OGG_Seek(void *context, double time);
191 static void OGG_Delete(void *context);
192
193 static int OGG_UpdateSection(OGG_music *music)
194 {
195 vorbis_info *vi;
196
197 vi = vorbis.ov_info(&music->vf, -1);
198 if (!vi) {
199 Mix_SetError("ov_info returned NULL");
200 return -1;
201 }
202
203 if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) {
204 return 0;
205 }
206 SDL_memcpy(&music->vi, vi, sizeof(*vi));
207
208 if (music->buffer) {
209 SDL_free(music->buffer);
210 music->buffer = NULL;
211 }
212
213 if (music->stream) {
214 SDL_FreeAudioStream(music->stream);
215 music->stream = NULL;
216 }
217
218 music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)vi->channels, (int)vi->rate,
219 music_spec.format, music_spec.channels, music_spec.freq);
220 if (!music->stream) {
221 return -1;
222 }
223
224 music->buffer_size = music_spec.samples * (int)sizeof(Sint16) * vi->channels;
225 music->buffer = (char *)SDL_malloc((size_t)music->buffer_size);
226 if (!music->buffer) {
227 return -1;
228 }
229 return 0;
230 }
231
232 /* Load an OGG stream from an SDL_RWops object */
233 static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
234 {
235 OGG_music *music;
236 ov_callbacks callbacks;
237 vorbis_comment *vc;
238 long rate;
239 ogg_int64_t full_length;
240 SDL_bool is_loop_length = SDL_FALSE;
241 int i;
242
243 music = (OGG_music *)SDL_calloc(1, sizeof *music);
244 if (!music) {
245 SDL_OutOfMemory();
246 return NULL;
247 }
248 music->src = src;
249 music->volume = MIX_MAX_VOLUME;
250 music->section = -1;
251
252 SDL_zero(callbacks);
253 callbacks.read_func = sdl_read_func;
254 callbacks.seek_func = sdl_seek_func;
255 callbacks.tell_func = sdl_tell_func;
256
257 if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) {
258 SDL_SetError("Not an Ogg Vorbis audio stream");
259 SDL_free(music);
260 return NULL;
261 }
262
263 if (OGG_UpdateSection(music) < 0) {
264 OGG_Delete(music);
265 return NULL;
266 }
267
268 rate = music->vi.rate;
269 vc = vorbis.ov_comment(&music->vf, -1);
270 if (vc != NULL) {
271 for (i = 0; i < vc->comments; i++) {
272 char *param = SDL_strdup(vc->user_comments[i]);
273 char *argument = param;
274 char *value = SDL_strchr(param, '=');
275 if (value == NULL) {
276 value = param + SDL_strlen(param);
277 } else {
278 *(value++) = '\0';
279 }
280
281 /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from
282 * string if it is present at position 4. */
283 if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) {
284 SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4);
285 }
286
287 if (SDL_strcasecmp(argument, "LOOPSTART") == 0)
288 music->loop_start = _Mix_ParseTime(value, rate);
289 else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) {
290 music->loop_len = SDL_strtoll(value, NULL, 10);
291 is_loop_length = SDL_TRUE;
292 } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
293 music->loop_end = _Mix_ParseTime(value, rate);
294 is_loop_length = SDL_FALSE;
295 } else if (SDL_strcasecmp(argument, "TITLE") == 0) {
296 meta_tags_set(&music->tags, MIX_META_TITLE, value);
297 } else if (SDL_strcasecmp(argument, "ARTIST") == 0) {
298 meta_tags_set(&music->tags, MIX_META_ARTIST, value);
299 } else if (SDL_strcasecmp(argument, "ALBUM") == 0) {
300 meta_tags_set(&music->tags, MIX_META_ALBUM, value);
301 } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) {
302 meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value);
303 }
304 SDL_free(param);
305 }
306
307 if (is_loop_length) {
308 music->loop_end = music->loop_start + music->loop_len;
309 } else {
310 music->loop_len = music->loop_end - music->loop_start;
311 }
312
313 /* Ignore invalid loop tag */
314 if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) {
315 music->loop_start = 0;
316 music->loop_len = 0;
317 music->loop_end = 0;
318 }
319 }
320
321 full_length = vorbis.ov_pcm_total(&music->vf, -1);
322 if ((music->loop_end > 0) && (music->loop_end <= full_length) &&
323 (music->loop_start < music->loop_end)) {
324 music->loop = 1;
325 }
326
327 music->freesrc = freesrc;
328 return music;
329 }
330
331 static const char* OGG_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
332 {
333 OGG_music *music = (OGG_music *)context;
334 return meta_tags_get(&music->tags, tag_type);
335 }
336
337 /* Set the volume for an OGG stream */
338 static void OGG_SetVolume(void *context, int volume)
339 {
340 OGG_music *music = (OGG_music *)context;
341 music->volume = volume;
342 }
343
344 /* Get the volume for an OGG stream */
345 static int OGG_GetVolume(void *context)
346 {
347 OGG_music *music = (OGG_music *)context;
348 return music->volume;
349 }
350
351 /* Start playback of a given OGG stream */
352 static int OGG_Play(void *context, int play_count)
353 {
354 OGG_music *music = (OGG_music *)context;
355 music->play_count = play_count;
356 return OGG_Seek(music, 0.0);
357 }
358
359 /* Play some of a stream previously started with OGG_play() */
360 static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
361 {
362 OGG_music *music = (OGG_music *)context;
363 SDL_bool looped = SDL_FALSE;
364 int filled, amount, result;
365 int section;
366 ogg_int64_t pcmPos;
367
368 filled = SDL_AudioStreamGet(music->stream, data, bytes);
369 if (filled != 0) {
370 return filled;
371 }
372
373 if (!music->play_count) {
374 /* All done */
375 *done = SDL_TRUE;
376 return 0;
377 }
378
379 section = music->section;
380 #ifdef OGG_USE_TREMOR
381 amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, &section);
382 #else
383 amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, &section);
384 #endif
385 if (amount < 0) {
386 set_ov_error("ov_read", amount);
387 return -1;
388 }
389
390 if (section != music->section) {
391 music->section = section;
392 if (OGG_UpdateSection(music) < 0) {
393 return -1;
394 }
395 }
396
397 pcmPos = vorbis.ov_pcm_tell(&music->vf);
398 if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
399 amount -= (int)((pcmPos - music->loop_end) * music->vi.channels) * (int)sizeof(Sint16);
400 result = vorbis.ov_pcm_seek(&music->vf, music->loop_start);
401 if (result < 0) {
402 set_ov_error("ov_pcm_seek", result);
403 return -1;
404 } else {
405 int play_count = -1;
406 if (music->play_count > 0) {
407 play_count = (music->play_count - 1);
408 }
409 music->play_count = play_count;
410 }
411 looped = SDL_TRUE;
412 }
413
414 if (amount > 0) {
415 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
416 return -1;
417 }
418 } else if (!looped) {
419 if (music->play_count == 1) {
420 music->play_count = 0;
421 SDL_AudioStreamFlush(music->stream);
422 } else {
423 int play_count = -1;
424 if (music->play_count > 0) {
425 play_count = (music->play_count - 1);
426 }
427 if (OGG_Play(music, play_count) < 0) {
428 return -1;
429 }
430 }
431 }
432 return 0;
433 }
434 static int OGG_GetAudio(void *context, void *data, int bytes)
435 {
436 OGG_music *music = (OGG_music *)context;
437 return music_pcm_getaudio(context, data, bytes, music->volume, OGG_GetSome);
438 }
439
440 /* Jump (seek) to a given position (time is in seconds) */
441 static int OGG_Seek(void *context, double time)
442 {
443 OGG_music *music = (OGG_music *)context;
444 int result;
445 #ifdef OGG_USE_TREMOR
446 result = vorbis.ov_time_seek(&music->vf, (ogg_int64_t)(time * 1000.0));
447 #else
448 result = vorbis.ov_time_seek(&music->vf, time);
449 #endif
450 if (result < 0) {
451 return set_ov_error("ov_time_seek", result);
452 }
453 return 0;
454 }
455
456 static double OGG_Tell(void *context)
457 {
458 OGG_music *music = (OGG_music *)context;
459 #ifdef OGG_USE_TREMOR
460 return vorbis.ov_time_tell(&music->vf) / 1000.0;
461 #else
462 return vorbis.ov_time_tell(&music->vf);
463 #endif
464 }
465
466 /* Return music duration in seconds */
467 static double OGG_Duration(void *context)
468 {
469 OGG_music *music = (OGG_music *)context;
470 #ifdef OGG_USE_TREMOR
471 return vorbis.ov_time_total(&music->vf, -1) / 1000.0;
472 #else
473 return vorbis.ov_time_total(&music->vf, -1);
474 #endif
475 }
476
477 static double OGG_LoopStart(void *music_p)
478 {
479 OGG_music *music = (OGG_music *)music_p;
480 if (music->loop > 0) {
481 return (double)music->loop_start / music->vi.rate;
482 }
483 return -1.0;
484 }
485
486 static double OGG_LoopEnd(void *music_p)
487 {
488 OGG_music *music = (OGG_music *)music_p;
489 if (music->loop > 0) {
490 return (double)music->loop_end / music->vi.rate;
491 }
492 return -1.0;
493 }
494
495 static double OGG_LoopLength(void *music_p)
496 {
497 OGG_music *music = (OGG_music *)music_p;
498 if (music->loop > 0) {
499 return (double)music->loop_len / music->vi.rate;
500 }
501 return -1.0;
502 }
503
504
505 /* Close the given OGG stream */
506 static void OGG_Delete(void *context)
507 {
508 OGG_music *music = (OGG_music *)context;
509 meta_tags_clear(&music->tags);
510 vorbis.ov_clear(&music->vf);
511 if (music->stream) {
512 SDL_FreeAudioStream(music->stream);
513 }
514 if (music->buffer) {
515 SDL_free(music->buffer);
516 }
517 if (music->freesrc) {
518 SDL_RWclose(music->src);
519 }
520 SDL_free(music);
521 }
522
523 Mix_MusicInterface Mix_MusicInterface_OGG =
524 {
525 "OGG",
526 MIX_MUSIC_OGG,
527 MUS_OGG,
528 SDL_FALSE,
529 SDL_FALSE,
530
531 OGG_Load,
532 NULL, /* Open */
533 OGG_CreateFromRW,
534 NULL, /* CreateFromFile */
535 OGG_SetVolume,
536 OGG_GetVolume,
537 OGG_Play,
538 NULL, /* IsPlaying */
539 OGG_GetAudio,
540 NULL, /* Jump */
541 OGG_Seek,
542 OGG_Tell,
543 OGG_Duration,
544 OGG_LoopStart,
545 OGG_LoopEnd,
546 OGG_LoopLength,
547 OGG_GetMetaTag, /* GetMetaTag */
548 NULL, /* Pause */
549 NULL, /* Resume */
550 NULL, /* Stop */
551 OGG_Delete,
552 NULL, /* Close */
553 OGG_Unload
554 };
555
556 #endif /* MUSIC_OGG */
557
558 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports Ogg Vorbis music streams */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_OGG;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_OPUS
22
23 /* This file supports Ogg Opus music streams */
24
25 #include "SDL_loadso.h"
26
27 #include "music_opus.h"
28 #include "utils.h"
29
30 #if defined(OPUS_HEADER)
31 #include OPUS_HEADER
32 #else
33 #include <opus/opusfile.h>
34 #endif
35
36 typedef struct {
37 int loaded;
38 void *handle;
39 const OpusTags *(*op_tags)(const OggOpusFile *,int);
40 OggOpusFile *(*op_open_callbacks)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *);
41 void (*op_free)(OggOpusFile *);
42 const OpusHead *(*op_head)(const OggOpusFile *,int);
43 int (*op_seekable)(const OggOpusFile *);
44 int (*op_read)(OggOpusFile *, opus_int16 *,int,int *);
45 int (*op_pcm_seek)(OggOpusFile *,ogg_int64_t);
46 ogg_int64_t (*op_pcm_tell)(const OggOpusFile *);
47 ogg_int64_t (*op_pcm_total)(const OggOpusFile *, int);
48 } opus_loader;
49
50 static opus_loader opus = {
51 0, NULL
52 };
53
54 #ifdef OPUS_DYNAMIC
55 #define FUNCTION_LOADER(FUNC, SIG) \
56 opus.FUNC = (SIG) SDL_LoadFunction(opus.handle, #FUNC); \
57 if (opus.FUNC == NULL) { SDL_UnloadObject(opus.handle); return -1; }
58 #else
59 #define FUNCTION_LOADER(FUNC, SIG) \
60 opus.FUNC = FUNC;
61 #endif
62
63 static int OPUS_Load(void)
64 {
65 if (opus.loaded == 0) {
66 #ifdef OPUS_DYNAMIC
67 opus.handle = SDL_LoadObject(OPUS_DYNAMIC);
68 if (opus.handle == NULL) {
69 return -1;
70 }
71 #elif defined(__MACOSX__)
72 extern OggOpusFile *op_open_callbacks(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *) __attribute__((weak_import));
73 if (op_open_callbacks == NULL) {
74 /* Missing weakly linked framework */
75 Mix_SetError("Missing OpusFile.framework");
76 return -1;
77 }
78 #endif
79 FUNCTION_LOADER(op_open_callbacks, OggOpusFile *(*)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *))
80 FUNCTION_LOADER(op_tags, const OpusTags *(*)(const OggOpusFile *,int))
81 FUNCTION_LOADER(op_free, void (*)(OggOpusFile *))
82 FUNCTION_LOADER(op_head, const OpusHead *(*)(const OggOpusFile *,int))
83 FUNCTION_LOADER(op_seekable, int (*)(const OggOpusFile *))
84 FUNCTION_LOADER(op_read, int (*)(OggOpusFile *, opus_int16 *,int,int *))
85 FUNCTION_LOADER(op_pcm_seek, int (*)(OggOpusFile *,ogg_int64_t))
86 FUNCTION_LOADER(op_pcm_tell, ogg_int64_t (*)(const OggOpusFile *))
87 FUNCTION_LOADER(op_pcm_total, ogg_int64_t (*)(const OggOpusFile *, int))
88 }
89 ++opus.loaded;
90
91 return 0;
92 }
93
94 static void OPUS_Unload(void)
95 {
96 if (opus.loaded == 0) {
97 return;
98 }
99 if (opus.loaded == 1) {
100 #ifdef OPUS_DYNAMIC
101 SDL_UnloadObject(opus.handle);
102 #endif
103 }
104 --opus.loaded;
105 }
106
107
108 typedef struct {
109 SDL_RWops *src;
110 int freesrc;
111 int play_count;
112 int volume;
113 OggOpusFile *of;
114 const OpusHead *op_info;
115 int section;
116 SDL_AudioStream *stream;
117 char *buffer;
118 int buffer_size;
119 int loop;
120 ogg_int64_t loop_start;
121 ogg_int64_t loop_end;
122 ogg_int64_t loop_len;
123 ogg_int64_t full_length;
124 Mix_MusicMetaTags tags;
125 } OPUS_music;
126
127
128 static int set_op_error(const char *function, int error)
129 {
130 #define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break;
131 switch (error) {
132 HANDLE_ERROR_CASE(OP_FALSE)
133 HANDLE_ERROR_CASE(OP_EOF)
134 HANDLE_ERROR_CASE(OP_HOLE)
135 HANDLE_ERROR_CASE(OP_EREAD)
136 HANDLE_ERROR_CASE(OP_EFAULT)
137 HANDLE_ERROR_CASE(OP_EIMPL)
138 HANDLE_ERROR_CASE(OP_EINVAL)
139 HANDLE_ERROR_CASE(OP_ENOTFORMAT)
140 HANDLE_ERROR_CASE(OP_EBADHEADER)
141 HANDLE_ERROR_CASE(OP_EVERSION)
142 HANDLE_ERROR_CASE(OP_ENOTAUDIO)
143 HANDLE_ERROR_CASE(OP_EBADPACKET)
144 HANDLE_ERROR_CASE(OP_EBADLINK)
145 HANDLE_ERROR_CASE(OP_ENOSEEK)
146 HANDLE_ERROR_CASE(OP_EBADTIMESTAMP)
147 default:
148 Mix_SetError("%s: unknown error %d\n", function, error);
149 break;
150 }
151 return -1;
152 }
153
154 static int sdl_read_func(void *datasource, unsigned char *ptr, int size)
155 {
156 return (int)SDL_RWread((SDL_RWops*)datasource, ptr, 1, (size_t)size);
157 }
158
159 static int sdl_seek_func(void *datasource, opus_int64 offset, int whence)
160 {
161 return (SDL_RWseek((SDL_RWops*)datasource, offset, whence) < 0)? -1 : 0;
162 }
163
164 static opus_int64 sdl_tell_func(void *datasource)
165 {
166 return SDL_RWtell((SDL_RWops*)datasource);
167 }
168
169 static int OPUS_Seek(void*, double);
170 static void OPUS_Delete(void*);
171
172 static int OPUS_UpdateSection(OPUS_music *music)
173 {
174 const OpusHead *op_info;
175
176 op_info = opus.op_head(music->of, -1);
177 if (!op_info) {
178 Mix_SetError("op_head returned NULL");
179 return -1;
180 }
181
182 if (music->op_info && op_info->channel_count == music->op_info->channel_count) {
183 return 0;
184 }
185 music->op_info = op_info;
186
187 if (music->buffer) {
188 SDL_free(music->buffer);
189 music->buffer = NULL;
190 }
191
192 if (music->stream) {
193 SDL_FreeAudioStream(music->stream);
194 music->stream = NULL;
195 }
196
197 music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)op_info->channel_count, 48000,
198 music_spec.format, music_spec.channels, music_spec.freq);
199 if (!music->stream) {
200 return -1;
201 }
202
203 music->buffer_size = (int)music_spec.samples * (int)sizeof(opus_int16) * op_info->channel_count;
204 music->buffer = (char *)SDL_malloc((size_t)music->buffer_size);
205 if (!music->buffer) {
206 return -1;
207 }
208 return 0;
209 }
210
211 /* Load an Opus stream from an SDL_RWops object */
212 static void *OPUS_CreateFromRW(SDL_RWops *src, int freesrc)
213 {
214 OPUS_music *music;
215 OpusFileCallbacks callbacks;
216 const OpusTags* tags;
217 int err = 0, ci;
218 SDL_bool is_loop_length = SDL_FALSE;
219 ogg_int64_t full_length;
220
221 music = (OPUS_music *)SDL_calloc(1, sizeof *music);
222 if (!music) {
223 SDL_OutOfMemory();
224 return NULL;
225 }
226 music->src = src;
227 music->volume = MIX_MAX_VOLUME;
228 music->section = -1;
229
230 SDL_zero(callbacks);
231 callbacks.read = sdl_read_func;
232 callbacks.seek = sdl_seek_func;
233 callbacks.tell = sdl_tell_func;
234
235 music->of = opus.op_open_callbacks(src, &callbacks, NULL, 0, &err);
236 if (music->of == NULL) {
237 /* set_op_error("op_open_callbacks", err);*/
238 SDL_SetError("Not an Opus audio stream");
239 SDL_free(music);
240 return NULL;
241 }
242
243 if (!opus.op_seekable(music->of)) {
244 OPUS_Delete(music);
245 Mix_SetError("Opus stream not seekable");
246 return NULL;
247 }
248
249 if (OPUS_UpdateSection(music) < 0) {
250 OPUS_Delete(music);
251 return NULL;
252 }
253
254 tags = opus.op_tags(music->of, -1);
255 if (tags != NULL) {
256 for (ci = 0; ci < tags->comments; ci++) {
257 char *param = SDL_strdup(tags->user_comments[ci]);
258 char *argument = param;
259 char *value = SDL_strchr(param, '=');
260 if (value == NULL) {
261 value = param + SDL_strlen(param);
262 } else {
263 *(value++) = '\0';
264 }
265
266 /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from
267 * string if it is present at position 4. */
268 if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) {
269 SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4);
270 }
271
272 if (SDL_strcasecmp(argument, "LOOPSTART") == 0)
273 music->loop_start = _Mix_ParseTime(value, 48000);
274 else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) {
275 music->loop_len = SDL_strtoll(value, NULL, 10);
276 is_loop_length = SDL_TRUE;
277 } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
278 music->loop_end = _Mix_ParseTime(value, 48000);
279 is_loop_length = SDL_FALSE;
280 } else if (SDL_strcasecmp(argument, "TITLE") == 0) {
281 meta_tags_set(&music->tags, MIX_META_TITLE, value);
282 } else if (SDL_strcasecmp(argument, "ARTIST") == 0) {
283 meta_tags_set(&music->tags, MIX_META_ARTIST, value);
284 } else if (SDL_strcasecmp(argument, "ALBUM") == 0) {
285 meta_tags_set(&music->tags, MIX_META_ALBUM, value);
286 } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) {
287 meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value);
288 }
289 SDL_free(param);
290 }
291
292 if (is_loop_length) {
293 music->loop_end = music->loop_start + music->loop_len;
294 } else {
295 music->loop_len = music->loop_end - music->loop_start;
296 }
297
298 /* Ignore invalid loop tag */
299 if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) {
300 music->loop_start = 0;
301 music->loop_len = 0;
302 music->loop_end = 0;
303 }
304 }
305
306 full_length = opus.op_pcm_total(music->of, -1);
307 if ((music->loop_end > 0) && (music->loop_end <= full_length) &&
308 (music->loop_start < music->loop_end)) {
309 music->loop = 1;
310 }
311
312 music->full_length = full_length;
313 music->freesrc = freesrc;
314 return music;
315 }
316
317 static const char* OPUS_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
318 {
319 OPUS_music *music = (OPUS_music *)context;
320 return meta_tags_get(&music->tags, tag_type);
321 }
322
323 /* Set the volume for an Opus stream */
324 static void OPUS_SetVolume(void *context, int volume)
325 {
326 OPUS_music *music = (OPUS_music *)context;
327 music->volume = volume;
328 }
329
330 /* Get the volume for an Opus stream */
331 static int OPUS_GetVolume(void *context)
332 {
333 OPUS_music *music = (OPUS_music *)context;
334 return music->volume;
335 }
336
337 /* Start playback of a given Opus stream */
338 static int OPUS_Play(void *context, int play_count)
339 {
340 OPUS_music *music = (OPUS_music *)context;
341 music->play_count = play_count;
342 return OPUS_Seek(music, 0.0);
343 }
344
345 /* Play some of a stream previously started with OPUS_Play() */
346 static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done)
347 {
348 OPUS_music *music = (OPUS_music *)context;
349 int filled, samples, section;
350 int result;
351 SDL_bool looped = SDL_FALSE;
352 ogg_int64_t pcmPos;
353
354 filled = SDL_AudioStreamGet(music->stream, data, bytes);
355 if (filled != 0) {
356 return filled;
357 }
358
359 if (!music->play_count) {
360 /* All done */
361 *done = SDL_TRUE;
362 return 0;
363 }
364
365 section = music->section;
366 samples = opus.op_read(music->of, (opus_int16 *)music->buffer, music->buffer_size / (int)sizeof(opus_int16), &section);
367 if (samples < 0) {
368 set_op_error("op_read", samples);
369 return -1;
370 }
371
372 if (section != music->section) {
373 music->section = section;
374 if (OPUS_UpdateSection(music) < 0) {
375 return -1;
376 }
377 }
378
379 pcmPos = opus.op_pcm_tell(music->of);
380 if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
381 samples -= (int)((pcmPos - music->loop_end) * music->op_info->channel_count) * (int)sizeof(Sint16);
382 result = opus.op_pcm_seek(music->of, music->loop_start);
383 if (result < 0) {
384 set_op_error("ov_pcm_seek", result);
385 return -1;
386 } else {
387 int play_count = -1;
388 if (music->play_count > 0) {
389 play_count = (music->play_count - 1);
390 }
391 music->play_count = play_count;
392 }
393 looped = SDL_TRUE;
394 }
395
396 if (samples > 0) {
397 filled = samples * music->op_info->channel_count * 2;
398 if (SDL_AudioStreamPut(music->stream, music->buffer, filled) < 0) {
399 return -1;
400 }
401 } else if (!looped) {
402 if (music->play_count == 1) {
403 music->play_count = 0;
404 SDL_AudioStreamFlush(music->stream);
405 } else {
406 int play_count = -1;
407 if (music->play_count > 0) {
408 play_count = (music->play_count - 1);
409 }
410 if (OPUS_Play(music, play_count) < 0) {
411 return -1;
412 }
413 }
414 }
415 return 0;
416 }
417
418 static int OPUS_GetAudio(void *context, void *data, int bytes)
419 {
420 OPUS_music *music = (OPUS_music *)context;
421 return music_pcm_getaudio(context, data, bytes, music->volume, OPUS_GetSome);
422 }
423
424 /* Jump (seek) to a given position (time is in seconds) */
425 static int OPUS_Seek(void *context, double time)
426 {
427 OPUS_music *music = (OPUS_music *)context;
428 int result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000));
429 if (result < 0) {
430 return set_op_error("op_pcm_seek", result);
431 }
432 return 0;
433 }
434
435 static double OPUS_Tell(void *context)
436 {
437 OPUS_music *music = (OPUS_music *)context;
438 return (double)(opus.op_pcm_tell(music->of)) / 48000.0;
439 }
440
441 /* Return music duration in seconds */
442 static double OPUS_Duration(void *context)
443 {
444 OPUS_music *music = (OPUS_music *)context;
445 return music->full_length / 48000.0;
446 }
447
448 static double OPUS_LoopStart(void *music_p)
449 {
450 OPUS_music *music = (OPUS_music *)music_p;
451 if (music->loop > 0) {
452 return (double)music->loop_start / 48000.0;
453 }
454 return -1.0;
455 }
456
457 static double OPUS_LoopEnd(void *music_p)
458 {
459 OPUS_music *music = (OPUS_music *)music_p;
460 if (music->loop > 0) {
461 return (double)music->loop_end / 48000.0;
462 }
463 return -1.0;
464 }
465
466 static double OPUS_LoopLength(void *music_p)
467 {
468 OPUS_music *music = (OPUS_music *)music_p;
469 if (music->loop > 0) {
470 return (double)music->loop_len / 48000.0;
471 }
472 return -1.0;
473 }
474
475 /* Close the given Opus stream */
476 static void OPUS_Delete(void *context)
477 {
478 OPUS_music *music = (OPUS_music *)context;
479 opus.op_free(music->of);
480 if (music->stream) {
481 SDL_FreeAudioStream(music->stream);
482 }
483 if (music->buffer) {
484 SDL_free(music->buffer);
485 }
486 if (music->freesrc) {
487 SDL_RWclose(music->src);
488 }
489 SDL_free(music);
490 }
491
492 Mix_MusicInterface Mix_MusicInterface_Opus =
493 {
494 "OPUS",
495 MIX_MUSIC_OPUS,
496 MUS_OPUS,
497 SDL_FALSE,
498 SDL_FALSE,
499
500 OPUS_Load,
501 NULL, /* Open */
502 OPUS_CreateFromRW,
503 NULL, /* CreateFromFile */
504 OPUS_SetVolume,
505 OPUS_GetVolume,
506 OPUS_Play,
507 NULL, /* IsPlaying */
508 OPUS_GetAudio,
509 NULL, /* Jump */
510 OPUS_Seek,
511 OPUS_Tell,
512 OPUS_Duration,
513 OPUS_LoopStart,
514 OPUS_LoopEnd,
515 OPUS_LoopLength,
516 OPUS_GetMetaTag,
517 NULL, /* Pause */
518 NULL, /* Resume */
519 NULL, /* Stop */
520 OPUS_Delete,
521 NULL, /* Close */
522 OPUS_Unload
523 };
524
525 #endif /* MUSIC_OPUS */
526
527 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports Ogg Opus music streams */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_Opus;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with timidity */
22
23 #ifdef MUSIC_MID_TIMIDITY
24
25 #include "music_timidity.h"
26
27 #include "timidity/timidity.h"
28
29
30 typedef struct
31 {
32 int play_count;
33 MidiSong *song;
34 SDL_AudioStream *stream;
35 void *buffer;
36 Sint32 buffer_size;
37 int volume;
38 } TIMIDITY_Music;
39
40
41 static int TIMIDITY_Seek(void *context, double position);
42 static void TIMIDITY_Delete(void *context);
43
44 /* Config file should contain any other directory that needs
45 * to be added to the search path. The library adds the path
46 * of the config file to its search path, too. */
47 #if defined(__WIN32__)
48 # define TIMIDITY_CFG "C:\\TIMIDITY\\TIMIDITY.CFG"
49 #elif defined(__OS2__)
50 # define TIMIDITY_CFG "C:\\TIMIDITY\\TIMIDITY.CFG"
51 # define TIMIDITY_CFG_ETC "/@unixroot/etc/timidity/timidity.cfg"
52 #else /* unix: */
53 # define TIMIDITY_CFG_ETC "/etc/timidity.cfg"
54 # define TIMIDITY_CFG_FREEPATS "/etc/timidity/freepats.cfg"
55 #endif
56
57 static int TIMIDITY_Open(const SDL_AudioSpec *spec)
58 {
59 const char *cfg;
60 int rc = -1;
61
62 (void) spec;
63
64 cfg = SDL_getenv("TIMIDITY_CFG");
65 if(!cfg) cfg = Mix_GetTimidityCfg();
66 if (cfg) {
67 return Timidity_Init(cfg); /* env or user override: no other tries */
68 }
69 #if defined(TIMIDITY_CFG)
70 if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG);
71 #endif
72 #if defined(TIMIDITY_CFG_ETC)
73 if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG_ETC);
74 #endif
75 #if defined(TIMIDITY_CFG_FREEPATS)
76 if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG_FREEPATS);
77 #endif
78 if (rc < 0) rc = Timidity_Init(NULL); /* library's default cfg. */
79
80 return rc;
81 }
82
83 static void TIMIDITY_Close(void)
84 {
85 Timidity_Exit();
86 }
87
88 void *TIMIDITY_CreateFromRW(SDL_RWops *src, int freesrc)
89 {
90 TIMIDITY_Music *music;
91 SDL_AudioSpec spec;
92 SDL_bool need_stream = SDL_FALSE;
93
94 music = (TIMIDITY_Music *)SDL_calloc(1, sizeof(*music));
95 if (!music) {
96 SDL_OutOfMemory();
97 return NULL;
98 }
99
100 music->volume = MIX_MAX_VOLUME;
101
102 SDL_memcpy(&spec, &music_spec, sizeof(spec));
103 if (spec.channels > 2) {
104 need_stream = SDL_TRUE;
105 spec.channels = 2;
106 }
107 music->song = Timidity_LoadSong(src, &spec);
108 if (!music->song) {
109 TIMIDITY_Delete(music);
110 return NULL;
111 }
112
113 if (need_stream) {
114 music->stream = SDL_NewAudioStream(spec.format, spec.channels, spec.freq,
115 music_spec.format, music_spec.channels, music_spec.freq);
116 if (!music->stream) {
117 TIMIDITY_Delete(music);
118 return NULL;
119 }
120
121 music->buffer_size = spec.samples * (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels;
122 music->buffer = SDL_malloc((size_t)music->buffer_size);
123 if (!music->buffer) {
124 SDL_OutOfMemory();
125 TIMIDITY_Delete(music);
126 return NULL;
127 }
128 }
129
130 if (freesrc) {
131 SDL_RWclose(src);
132 }
133 return music;
134 }
135
136 static void TIMIDITY_SetVolume(void *context, int volume)
137 {
138 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
139 music->volume = volume;
140 Timidity_SetVolume(music->song, volume);
141 }
142
143 static int TIMIDITY_GetVolume(void *context)
144 {
145 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
146 return music->volume;
147 }
148
149 static int TIMIDITY_Play(void *context, int play_count)
150 {
151 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
152 music->play_count = play_count;
153 Timidity_Start(music->song);
154 return TIMIDITY_Seek(music, 0.0);
155 }
156
157 static SDL_bool TIMIDITY_IsPlaying(void *context)
158 {
159 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
160 return Timidity_IsActive(music->song);
161 }
162
163 static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done)
164 {
165 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
166 int filled, amount, expected;
167
168 if (music->stream) {
169 filled = SDL_AudioStreamGet(music->stream, data, bytes);
170 if (filled != 0) {
171 return filled;
172 }
173 }
174
175 if (!music->play_count) {
176 /* All done */
177 *done = SDL_TRUE;
178 return 0;
179 }
180
181 if (music->stream) {
182 expected = music->buffer_size;
183 amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size);
184 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
185 return -1;
186 }
187 } else {
188 expected = bytes;
189 amount = Timidity_PlaySome(music->song, data, bytes);
190 }
191
192 if (amount < expected) {
193 if (music->play_count == 1) {
194 /* We didn't consume anything and we're done */
195 music->play_count = 0;
196 } else {
197 int play_count = -1;
198 if (music->play_count > 0) {
199 play_count = (music->play_count - 1);
200 }
201 if (TIMIDITY_Play(music, play_count) < 0) {
202 return -1;
203 }
204 }
205 }
206 if (music->stream) {
207 /* We'll pick it up from the stream next time around */
208 return 0;
209 } else {
210 /* We wrote output data */
211 return amount;
212 }
213 }
214
215 static int TIMIDITY_GetAudio(void *context, void *data, int bytes)
216 {
217 return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, TIMIDITY_GetSome);
218 }
219
220 static int TIMIDITY_Seek(void *context, double position)
221 {
222 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
223 Timidity_Seek(music->song, (Uint32)(position * 1000));
224 return 0;
225 }
226
227 static double TIMIDITY_Tell(void *context)
228 {
229 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
230 return Timidity_GetSongTime(music->song) / 1000.0;
231 }
232
233 static double TIMIDITY_Duration(void *context)
234 {
235 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
236 return Timidity_GetSongLength(music->song) / 1000.0;
237 }
238
239 static void TIMIDITY_Delete(void *context)
240 {
241 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
242
243 if (music->song) {
244 Timidity_FreeSong(music->song);
245 }
246 if (music->stream) {
247 SDL_FreeAudioStream(music->stream);
248 }
249 if (music->buffer) {
250 SDL_free(music->buffer);
251 }
252 SDL_free(music);
253 }
254
255 static void TIMIDITY_Stop(void *context)
256 {
257 TIMIDITY_Music *music = (TIMIDITY_Music *)context;
258 Timidity_Stop(music->song);
259 }
260
261 Mix_MusicInterface Mix_MusicInterface_TIMIDITY =
262 {
263 "TIMIDITY",
264 MIX_MUSIC_TIMIDITY,
265 MUS_MID,
266 SDL_FALSE,
267 SDL_FALSE,
268
269 NULL, /* Load */
270 TIMIDITY_Open,
271 TIMIDITY_CreateFromRW,
272 NULL, /* CreateFromFile */
273 TIMIDITY_SetVolume,
274 TIMIDITY_GetVolume,
275 TIMIDITY_Play,
276 TIMIDITY_IsPlaying,
277 TIMIDITY_GetAudio,
278 NULL, /* Jump */
279 TIMIDITY_Seek,
280 TIMIDITY_Tell,
281 TIMIDITY_Duration,
282 NULL, /* LoopStart */
283 NULL, /* LoopEnd */
284 NULL, /* LoopLength */
285 NULL, /* GetMetaTag */
286 NULL, /* Pause */
287 NULL, /* Resume */
288 TIMIDITY_Stop,
289 TIMIDITY_Delete,
290 TIMIDITY_Close,
291 NULL /* Unload */
292 };
293
294 #endif /* MUSIC_MID_TIMIDITY */
295
296 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MIDI files with timidity */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_WAV
22
23 /* This file supports streaming WAV files */
24
25 #include "music_wav.h"
26
27
28 typedef struct {
29 SDL_bool active;
30 Uint32 start;
31 Uint32 stop;
32 Uint32 initial_play_count;
33 Uint32 current_play_count;
34 } WAVLoopPoint;
35
36 typedef struct {
37 SDL_RWops *src;
38 int freesrc;
39 SDL_AudioSpec spec;
40 int volume;
41 int play_count;
42 Sint64 start;
43 Sint64 stop;
44 Sint64 samplesize;
45 Uint8 *buffer;
46 SDL_AudioStream *stream;
47 unsigned int numloops;
48 WAVLoopPoint *loops;
49 Mix_MusicMetaTags tags;
50 Uint16 encoding;
51 int (*decode)(void *music, int length);
52 } WAV_Music;
53
54 /*
55 Taken with permission from SDL_wave.h, part of the SDL library,
56 available at: http://www.libsdl.org/
57 and placed under the same license as this mixer library.
58 */
59
60 /* WAVE files are little-endian */
61
62 /*******************************************/
63 /* Define values for Microsoft WAVE format */
64 /*******************************************/
65 #define RIFF 0x46464952 /* "RIFF" */
66 #define WAVE 0x45564157 /* "WAVE" */
67 #define FMT 0x20746D66 /* "fmt " */
68 #define DATA 0x61746164 /* "data" */
69 #define SMPL 0x6c706d73 /* "smpl" */
70 #define LIST 0x5453494c /* "LIST" */
71 #define ID3_ 0x20336469 /* "id3 " */
72 #define PCM_CODE 1 /* WAVE_FORMAT_PCM */
73 #define ADPCM_CODE 2 /* WAVE_FORMAT_ADPCM */
74 #define FLOAT_CODE 3 /* WAVE_FORMAT_IEEE_FLOAT */
75 #define ALAW_CODE 6 /* WAVE_FORMAT_ALAW */
76 #define uLAW_CODE 7 /* WAVE_FORMAT_MULAW */
77 #define EXT_CODE 0xFFFE /* WAVE_FORMAT_EXTENSIBLE */
78 #define WAVE_MONO 1
79 #define WAVE_STEREO 2
80
81 typedef struct {
82 /* Not saved in the chunk we read:
83 Uint32 chunkID;
84 Uint32 chunkLen;
85 */
86 Uint16 encoding;
87 Uint16 channels; /* 1 = mono, 2 = stereo */
88 Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
89 Uint32 byterate; /* Average bytes per second */
90 Uint16 blockalign; /* Bytes per sample block */
91 Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
92 } WaveFMT;
93
94 typedef struct {
95 Uint16 cbSize;
96 union {
97 Uint16 validbitspersample; /* bits of precision */
98 Uint16 samplesperblock; /* valid if wBitsPerSample==0 */
99 Uint16 reserved; /* If neither applies, set to zero. */
100 } Samples;
101 Uint32 channelsmask;
102 /* GUID subFormat 16 bytes */
103 Uint32 subencoding;
104 Uint16 sub_data2;
105 Uint16 sub_data3;
106 Uint8 sub_data[8];
107 } WaveFMTex;
108
109 typedef struct {
110 Uint32 identifier;
111 Uint32 type;
112 Uint32 start;
113 Uint32 end;
114 Uint32 fraction;
115 Uint32 play_count;
116 } SampleLoop;
117
118 typedef struct {
119 /* Not saved in the chunk we read:
120 Uint32 chunkID;
121 Uint32 chunkLen;
122 */
123 Uint32 manufacturer;
124 Uint32 product;
125 Uint32 sample_period;
126 Uint32 MIDI_unity_note;
127 Uint32 MIDI_pitch_fraction;
128 Uint32 SMTPE_format;
129 Uint32 SMTPE_offset;
130 Uint32 sample_loops;
131 Uint32 sampler_data;
132 SampleLoop loops[1];
133 } SamplerChunk;
134
135 /*********************************************/
136 /* Define values for AIFF (IFF audio) format */
137 /*********************************************/
138 #define FORM 0x4d524f46 /* "FORM" */
139 #define AIFF 0x46464941 /* "AIFF" */
140 #define AIFC 0x43464941 /* "AIFС" */
141 #define FVER 0x52455646 /* "FVER" */
142 #define SSND 0x444e5353 /* "SSND" */
143 #define COMM 0x4d4d4f43 /* "COMM" */
144 #define AIFF_ID3_ 0x20334449 /* "ID3 " */
145 #define MARK 0x4B52414D /* "MARK" */
146 #define INST 0x54534E49 /* "INST" */
147 #define AUTH 0x48545541 /* "AUTH" */
148 #define NAME 0x454D414E /* "NAME" */
149 #define _c__ 0x20296328 /* "(c) " */
150
151 /* Supported compression types */
152 #define NONE 0x454E4F4E /* "NONE" */
153 #define sowt 0x74776F73 /* "sowt" */
154 #define raw_ 0x20776172 /* "raw " */
155 #define ulaw 0x77616C75 /* "ulaw" */
156 #define alaw 0x77616C61 /* "alaw" */
157 #define ULAW 0x57414C55 /* "ULAW" */
158 #define ALAW 0x57414C41 /* "ALAW" */
159 #define fl32 0x32336C66 /* "fl32" */
160 #define fl64 0x34366C66 /* "fl64" */
161 #define FL32 0x32334C46 /* "FL32" */
162
163 /* Function to load the WAV/AIFF stream */
164 static SDL_bool LoadWAVMusic(WAV_Music *wave);
165 static SDL_bool LoadAIFFMusic(WAV_Music *wave);
166
167 static void WAV_Delete(void *context);
168
169 static int fetch_pcm(void *context, int length);
170
171 /* Load a WAV stream from the given RWops object */
172 static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc)
173 {
174 WAV_Music *music;
175 Uint32 magic;
176 SDL_bool loaded = SDL_FALSE;
177
178 music = (WAV_Music *)SDL_calloc(1, sizeof(*music));
179 if (!music) {
180 SDL_OutOfMemory();
181 return NULL;
182 }
183 music->src = src;
184 music->volume = MIX_MAX_VOLUME;
185 /* Default decoder is PCM */
186 music->decode = fetch_pcm;
187 music->encoding = PCM_CODE;
188
189 magic = SDL_ReadLE32(src);
190 if (magic == RIFF || magic == WAVE) {
191 loaded = LoadWAVMusic(music);
192 } else if (magic == FORM) {
193 loaded = LoadAIFFMusic(music);
194 } else {
195 Mix_SetError("Unknown WAVE format");
196 }
197 if (!loaded) {
198 WAV_Delete(music);
199 return NULL;
200 }
201 music->buffer = (Uint8*)SDL_malloc(music->spec.size);
202 if (!music->buffer) {
203 WAV_Delete(music);
204 return NULL;
205 }
206 music->stream = SDL_NewAudioStream(
207 music->spec.format, music->spec.channels, music->spec.freq,
208 music_spec.format, music_spec.channels, music_spec.freq);
209 if (!music->stream) {
210 WAV_Delete(music);
211 return NULL;
212 }
213
214 music->freesrc = freesrc;
215 return music;
216 }
217
218 static void WAV_SetVolume(void *context, int volume)
219 {
220 WAV_Music *music = (WAV_Music *)context;
221 music->volume = volume;
222 }
223
224 static int WAV_GetVolume(void *context)
225 {
226 WAV_Music *music = (WAV_Music *)context;
227 return music->volume;
228 }
229
230 /* Start playback of a given WAV stream */
231 static int WAV_Play(void *context, int play_count)
232 {
233 WAV_Music *music = (WAV_Music *)context;
234 unsigned int i;
235 for (i = 0; i < music->numloops; ++i) {
236 WAVLoopPoint *loop = &music->loops[i];
237 loop->active = SDL_TRUE;
238 loop->current_play_count = loop->initial_play_count;
239 }
240 music->play_count = play_count;
241 if (SDL_RWseek(music->src, music->start, RW_SEEK_SET) < 0) {
242 return -1;
243 }
244 return 0;
245 }
246
247 static int fetch_pcm(void *context, int length)
248 {
249 WAV_Music *music = (WAV_Music *)context;
250 return (int)SDL_RWread(music->src, music->buffer, 1, (size_t)length);
251 }
252
253 static Uint32 PCM_S24_to_S32_BE(Uint8 *x) {
254 const Uint32 bits = 24;
255 Uint32 in = (((Uint32)x[0] << 0) & 0x0000FF) |
256 (((Uint32)x[1] << 8) & 0x00FF00) |
257 (((Uint32)x[2] << 16) & 0xFF0000);
258 Uint32 m = 1u << (bits - 1);
259 return (in ^ m) - m;
260 }
261
262 static Uint32 PCM_S24_to_S32_LE(Uint8 *x) {
263 const Uint32 bits = 24;
264 Uint32 in = (((Uint32)x[2] << 0) & 0x0000FF) |
265 (((Uint32)x[1] << 8) & 0x00FF00) |
266 (((Uint32)x[0] << 16) & 0xFF0000);
267 Uint32 m = 1u << (bits - 1);
268 return (in ^ m) - m;
269 }
270
271 static int fetch_pcm24be(void *context, int length)
272 {
273 WAV_Music *music = (WAV_Music *)context;
274 int i = 0, o = 0;
275 length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)((length / 4) * 3));
276 if (length % music->samplesize != 0) {
277 length -= length % music->samplesize;
278 }
279 for (i = length - 3, o = ((length - 3) / 3) * 4; i >= 0; i -= 3, o -= 4) {
280 Uint32 decoded = PCM_S24_to_S32_BE(music->buffer + i);
281 music->buffer[o + 0] = (decoded >> 0) & 0xFF;
282 music->buffer[o + 1] = (decoded >> 8) & 0xFF;
283 music->buffer[o + 2] = (decoded >> 16) & 0xFF;
284 music->buffer[o + 3] = (decoded >> 24) & 0xFF;
285 }
286 return (length / 3) * 4;
287 }
288
289 static int fetch_pcm24le(void *context, int length)
290 {
291 WAV_Music *music = (WAV_Music *)context;
292 int i = 0, o = 0;
293 length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)((length / 4) * 3));
294 if (length % music->samplesize != 0) {
295 length -= length % music->samplesize;
296 }
297 for (i = length - 3, o = ((length - 3) / 3) * 4; i >= 0; i -= 3, o -= 4) {
298 Uint32 decoded = PCM_S24_to_S32_LE(music->buffer + i);
299 music->buffer[o + 3] = (decoded >> 0) & 0xFF;
300 music->buffer[o + 2] = (decoded >> 8) & 0xFF;
301 music->buffer[o + 1] = (decoded >> 16) & 0xFF;
302 music->buffer[o + 0] = (decoded >> 24) & 0xFF;
303 }
304 return (length / 3) * 4;
305 }
306
307 SDL_FORCE_INLINE double
308 Mix_SwapDouble(double x)
309 {
310 union
311 {
312 double f;
313 Uint64 ui64;
314 } swapper;
315 swapper.f = x;
316 swapper.ui64 = SDL_Swap64(swapper.ui64);
317 return swapper.f;
318 }
319
320 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
321 #define Mix_SwapDoubleLE(X) (X)
322 #define Mix_SwapDoubleBE(X) Mix_SwapDouble(X)
323 #else
324 #define Mix_SwapDoubleLE(X) Mix_SwapDouble(X)
325 #define Mix_SwapDoubleBE(X) (X)
326 #endif
327
328 static int fetch_float64be(void *context, int length)
329 {
330 WAV_Music *music = (WAV_Music *)context;
331 int i = 0, o = 0;
332 length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length));
333 if (length % music->samplesize != 0) {
334 length -= length % music->samplesize;
335 }
336 for (i = 0, o = 0; i <= length; i += 8, o += 4) {
337 union
338 {
339 float f;
340 Uint32 ui32;
341 } sample;
342 sample.f = (float)Mix_SwapDoubleBE(*(double*)(music->buffer + i));
343 music->buffer[o + 0] = (sample.ui32 >> 0) & 0xFF;
344 music->buffer[o + 1] = (sample.ui32 >> 8) & 0xFF;
345 music->buffer[o + 2] = (sample.ui32 >> 16) & 0xFF;
346 music->buffer[o + 3] = (sample.ui32 >> 24) & 0xFF;
347 }
348 return length / 2;
349 }
350
351 static int fetch_float64le(void *context, int length)
352 {
353 WAV_Music *music = (WAV_Music *)context;
354 int i = 0, o = 0;
355 length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length));
356 if (length % music->samplesize != 0) {
357 length -= length % music->samplesize;
358 }
359 for (i = 0, o = 0; i <= length; i += 8, o += 4) {
360 union
361 {
362 float f;
363 Uint32 ui32;
364 } sample;
365 sample.f = (float)Mix_SwapDoubleLE(*(double*)(music->buffer + i));
366 music->buffer[o + 0] = (sample.ui32 >> 0) & 0xFF;
367 music->buffer[o + 1] = (sample.ui32 >> 8) & 0xFF;
368 music->buffer[o + 2] = (sample.ui32 >> 16) & 0xFF;
369 music->buffer[o + 3] = (sample.ui32 >> 24) & 0xFF;
370 }
371 return length / 2;
372 }
373
374 /*
375 G711 decode tables taken from SDL2 (src/audio/SDL_wave.c)
376 */
377 #ifdef SDL_WAVE_LAW_LUT
378 static const Sint16 alaw_lut[256] = {
379 -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, -2752,
380 -2624, -3008, -2880, -2240, -2112, -2496, -2368, -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, -22016,
381 -20992, -24064, -23040, -17920, -16896, -19968, -18944, -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, -11008,
382 -10496, -12032, -11520, -8960, -8448, -9984, -9472, -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, -344,
383 -328, -376, -360, -280, -264, -312, -296, -472, -456, -504, -488, -408, -392, -440, -424, -88,
384 -72, -120, -104, -24, -8, -56, -40, -216, -200, -248, -232, -152, -136, -184, -168, -1376,
385 -1312, -1504, -1440, -1120, -1056, -1248, -1184, -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, -688,
386 -656, -752, -720, -560, -528, -624, -592, -944, -912, -1008, -976, -816, -784, -880, -848, 5504,
387 5248, 6016, 5760, 4480, 4224, 4992, 4736, 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, 2752,
388 2624, 3008, 2880, 2240, 2112, 2496, 2368, 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, 22016,
389 20992, 24064, 23040, 17920, 16896, 19968, 18944, 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, 11008,
390 10496, 12032, 11520, 8960, 8448, 9984, 9472, 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, 344,
391 328, 376, 360, 280, 264, 312, 296, 472, 456, 504, 488, 408, 392, 440, 424, 88,
392 72, 120, 104, 24, 8, 56, 40, 216, 200, 248, 232, 152, 136, 184, 168, 1376,
393 1312, 1504, 1440, 1120, 1056, 1248, 1184, 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, 688,
394 656, 752, 720, 560, 528, 624, 592, 944, 912, 1008, 976, 816, 784, 880, 848
395 };
396
397 static const Sint16 mulaw_lut[256] = {
398 -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, -15996,
399 -15484, -14972, -14460, -13948, -13436, -12924, -12412, -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, -7932,
400 -7676, -7420, -7164, -6908, -6652, -6396, -6140, -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, -3900,
401 -3772, -3644, -3516, -3388, -3260, -3132, -3004, -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, -1884,
402 -1820, -1756, -1692, -1628, -1564, -1500, -1436, -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, -876,
403 -844, -812, -780, -748, -716, -684, -652, -620, -588, -556, -524, -492, -460, -428, -396, -372,
404 -356, -340, -324, -308, -292, -276, -260, -244, -228, -212, -196, -180, -164, -148, -132, -120,
405 -112, -104, -96, -88, -80, -72, -64, -56, -48, -40, -32, -24, -16, -8, 0, 32124,
406 31100, 30076, 29052, 28028, 27004, 25980, 24956, 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, 15996,
407 15484, 14972, 14460, 13948, 13436, 12924, 12412, 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, 7932,
408 7676, 7420, 7164, 6908, 6652, 6396, 6140, 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, 3900,
409 3772, 3644, 3516, 3388, 3260, 3132, 3004, 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, 1884,
410 1820, 1756, 1692, 1628, 1564, 1500, 1436, 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, 876,
411 844, 812, 780, 748, 716, 684, 652, 620, 588, 556, 524, 492, 460, 428, 396, 372,
412 356, 340, 324, 308, 292, 276, 260, 244, 228, 212, 196, 180, 164, 148, 132, 120,
413 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0
414 };
415 #endif
416
417 static Sint16 uLAW_To_PCM16(Uint8 u_val)
418 {
419 #ifdef SDL_WAVE_LAW_LUT
420 return mulaw_lut[u_val];
421 #else
422 Uint8 nibble = ~u_val;
423 Sint16 mantissa = nibble & 0xf;
424 Uint8 exponent = (nibble >> 4) & 0x7;
425 Sint16 step = (Sint16)(4 << (exponent + 1));
426
427 mantissa = (Sint16)(0x80 << exponent) + step * mantissa + step / 2 - 132;
428
429 return nibble & 0x80 ? -mantissa : mantissa;
430 #endif
431 }
432
433 static Sint16 ALAW_To_PCM16(Uint8 a_val)
434 {
435 #ifdef SDL_WAVE_LAW_LUT
436 return alaw_lut[a_val];
437 #else
438 Uint8 nibble = a_val;
439 Uint8 exponent = (nibble & 0x7f) ^ 0x55;
440 Sint16 mantissa = exponent & 0xf;
441
442 exponent >>= 4;
443 if (exponent > 0) {
444 mantissa |= 0x10;
445 }
446 mantissa = (Sint16)(mantissa << 4) | 0x8;
447 if (exponent > 1) {
448 mantissa <<= exponent - 1;
449 }
450
451 return nibble & 0x80 ? mantissa : -mantissa;
452 #endif
453 }
454
455 static int fetch_xlaw(Sint16 (*decode_sample)(Uint8), void *context, int length)
456 {
457 WAV_Music *music = (WAV_Music *)context;
458 int i = 0, o = 0;
459 length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length / 2));
460 if (length % music->samplesize != 0) {
461 length -= length % music->samplesize;
462 }
463 for (i = length - 1, o = (length - 1) * 2; i >= 0; i--, o -= 2) {
464 Uint16 decoded = (Uint16)decode_sample(music->buffer[i]);
465 music->buffer[o] = decoded & 0xFF;
466 music->buffer[o + 1] = (decoded >> 8) & 0xFF;
467 }
468 return length * 2;
469 }
470
471 static int fetch_ulaw(void *context, int length)
472 {
473 return fetch_xlaw(uLAW_To_PCM16, context, length);
474 }
475
476 static int fetch_alaw(void *context, int length)
477 {
478 return fetch_xlaw(ALAW_To_PCM16, context, length);
479 }
480
481 /* Play some of a stream previously started with WAV_Play() */
482 static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done)
483 {
484 WAV_Music *music = (WAV_Music *)context;
485 Sint64 pos, stop;
486 WAVLoopPoint *loop;
487 Sint64 loop_start = music->start;
488 Sint64 loop_stop = music->stop;
489 SDL_bool looped = SDL_FALSE;
490 SDL_bool at_end = SDL_FALSE;
491 unsigned int i;
492 int filled, amount, result;
493
494 filled = SDL_AudioStreamGet(music->stream, data, bytes);
495 if (filled != 0) {
496 return filled;
497 }
498
499 if (!music->play_count) {
500 /* All done */
501 *done = SDL_TRUE;
502 return 0;
503 }
504
505 pos = SDL_RWtell(music->src);
506 stop = music->stop;
507 loop = NULL;
508 for (i = 0; i < music->numloops; ++i) {
509 loop = &music->loops[i];
510 if (loop->active) {
511 const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels;
512 loop_start = music->start + loop->start * (Uint32)bytes_per_sample;
513 loop_stop = music->start + (loop->stop + 1) * (Uint32)bytes_per_sample;
514 if (pos >= loop_start && pos < loop_stop) {
515 stop = loop_stop;
516 break;
517 }
518 }
519 loop = NULL;
520 }
521
522 amount = (int)music->spec.size;
523 if ((stop - pos) < amount) {
524 amount = (int)(stop - pos);
525 }
526
527 amount = music->decode(music, amount);
528 if (amount > 0) {
529 result = SDL_AudioStreamPut(music->stream, music->buffer, amount);
530 if (result < 0) {
531 return -1;
532 }
533 } else {
534 /* We might be looping, continue */
535 at_end = SDL_TRUE;
536 }
537
538 if (loop && SDL_RWtell(music->src) >= stop) {
539 if (loop->current_play_count == 1) {
540 loop->active = SDL_FALSE;
541 } else {
542 if (loop->current_play_count > 0) {
543 --loop->current_play_count;
544 }
545 SDL_RWseek(music->src, loop_start, RW_SEEK_SET);
546 looped = SDL_TRUE;
547 }
548 }
549
550 if (!looped && (at_end || SDL_RWtell(music->src) >= music->stop)) {
551 if (music->play_count == 1) {
552 music->play_count = 0;
553 SDL_AudioStreamFlush(music->stream);
554 } else {
555 int play_count = -1;
556 if (music->play_count > 0) {
557 play_count = (music->play_count - 1);
558 }
559 if (WAV_Play(music, play_count) < 0) {
560 return -1;
561 }
562 }
563 }
564
565 /* We'll get called again in the case where we looped or have more data */
566 return 0;
567 }
568
569 static int WAV_GetAudio(void *context, void *data, int bytes)
570 {
571 WAV_Music *music = (WAV_Music *)context;
572 return music_pcm_getaudio(context, data, bytes, music->volume, WAV_GetSome);
573 }
574
575 static int WAV_Seek(void *context, double position)
576 {
577 WAV_Music *music = (WAV_Music *)context;
578 Sint64 sample_size = music->spec.freq * music->samplesize;
579 Sint64 dest_offset = (Sint64)(position * (double)music->spec.freq * music->samplesize);
580 Sint64 destpos = music->start + dest_offset;
581 destpos -= dest_offset % sample_size;
582 if (destpos > music->stop)
583 return -1;
584 SDL_RWseek(music->src, destpos, RW_SEEK_SET);
585 return 0;
586 }
587
588 static double WAV_Tell(void *context)
589 {
590 WAV_Music *music = (WAV_Music *)context;
591 Sint64 phys_pos = SDL_RWtell(music->src);
592 return (double)(phys_pos - music->start) / (double)(music->spec.freq * music->samplesize);
593 }
594
595 /* Return music duration in seconds */
596 static double WAV_Duration(void *context)
597 {
598 WAV_Music *music = (WAV_Music *)context;
599 Sint64 sample_size = music->spec.freq * music->samplesize;
600 return (double)(music->stop - music->start) / sample_size;
601 }
602
603 static const char* WAV_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
604 {
605 WAV_Music *music = (WAV_Music *)context;
606 return meta_tags_get(&music->tags, tag_type);
607 }
608
609 /* Close the given WAV stream */
610 static void WAV_Delete(void *context)
611 {
612 WAV_Music *music = (WAV_Music *)context;
613
614 /* Clean up associated data */
615 meta_tags_clear(&music->tags);
616 if (music->loops) {
617 SDL_free(music->loops);
618 }
619 if (music->stream) {
620 SDL_FreeAudioStream(music->stream);
621 }
622 if (music->buffer) {
623 SDL_free(music->buffer);
624 }
625 if (music->freesrc) {
626 SDL_RWclose(music->src);
627 }
628 SDL_free(music);
629 }
630
631 static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length)
632 {
633 SDL_AudioSpec *spec = &wave->spec;
634 WaveFMT *format;
635 WaveFMTex *formatEx = NULL;
636 Uint8 *data;
637 int bits;
638 SDL_bool loaded = SDL_FALSE;
639
640 if (chunk_length < sizeof(*format)) {
641 Mix_SetError("Wave format chunk too small");
642 return SDL_FALSE;
643 }
644
645 data = (Uint8 *)SDL_malloc(chunk_length);
646 if (!data) {
647 Mix_SetError("Out of memory");
648 return SDL_FALSE;
649 }
650 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
651 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
652 goto done;
653 }
654 format = (WaveFMT *)data;
655
656 wave->encoding = SDL_SwapLE16(format->encoding);
657
658 if (wave->encoding == EXT_CODE) {
659 formatEx = (WaveFMTex*)(data + sizeof(WaveFMT));
660 wave->encoding = (Uint16)SDL_SwapLE32(formatEx->subencoding);
661 }
662
663 /* Decode the audio data format */
664 switch (wave->encoding) {
665 case PCM_CODE:
666 case FLOAT_CODE:
667 /* We can understand this */
668 wave->decode = fetch_pcm;
669 break;
670 case uLAW_CODE:
671 /* , this */
672 wave->decode = fetch_ulaw;
673 break;
674 case ALAW_CODE:
675 /* , and this */
676 wave->decode = fetch_alaw;
677 break;
678 default:
679 /* but NOT this */
680 Mix_SetError("Unknown WAVE data format");
681 goto done;
682 }
683 spec->freq = (int)SDL_SwapLE32(format->frequency);
684 bits = (int) SDL_SwapLE16(format->bitspersample);
685 switch (bits) {
686 case 8:
687 switch(wave->encoding) {
688 case PCM_CODE: spec->format = AUDIO_U8; break;
689 case ALAW_CODE: spec->format = AUDIO_S16; break;
690 case uLAW_CODE: spec->format = AUDIO_S16; break;
691 default: goto unknown_bits;
692 }
693 break;
694 case 16:
695 switch(wave->encoding) {
696 case PCM_CODE: spec->format = AUDIO_S16; break;
697 default: goto unknown_bits;
698 }
699 break;
700 case 24:
701 switch(wave->encoding) {
702 case PCM_CODE:
703 wave->decode = fetch_pcm24le;
704 spec->format = AUDIO_S32;
705 break;
706 default: goto unknown_bits;
707 }
708 break;
709 case 32:
710 switch(wave->encoding) {
711 case PCM_CODE: spec->format = AUDIO_S32; break;
712 case FLOAT_CODE: spec->format = AUDIO_F32; break;
713 default: goto unknown_bits;
714 }
715 break;
716 case 64:
717 switch(wave->encoding) {
718 case FLOAT_CODE:
719 wave->decode = fetch_float64le;
720 spec->format = AUDIO_F32;
721 break;
722 default: goto unknown_bits;
723 }
724 break;
725 default:
726 unknown_bits:
727 Mix_SetError("Unknown PCM format with %d bits", bits);
728 goto done;
729 }
730 spec->channels = (Uint8) SDL_SwapLE16(format->channels);
731 spec->samples = 4096; /* Good default buffer size */
732 wave->samplesize = spec->channels * (bits / 8);
733 /* SDL_CalculateAudioSpec */
734 spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
735 spec->size *= spec->channels;
736 spec->size *= spec->samples;
737
738 loaded = SDL_TRUE;
739
740 done:
741 SDL_free(data);
742 return loaded;
743 }
744
745 static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length)
746 {
747 wave->start = SDL_RWtell(wave->src);
748 wave->stop = wave->start + chunk_length;
749 SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR);
750 return SDL_TRUE;
751 }
752
753 static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop)
754 {
755 WAVLoopPoint *loop;
756 WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1) * sizeof(*wave->loops));
757 if (!loops) {
758 Mix_SetError("Out of memory");
759 return SDL_FALSE;
760 }
761
762 loop = &loops[ wave->numloops ];
763 loop->start = start;
764 loop->stop = stop;
765 loop->initial_play_count = play_count;
766 loop->current_play_count = play_count;
767
768 wave->loops = loops;
769 ++wave->numloops;
770 return SDL_TRUE;
771 }
772
773 static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length)
774 {
775 SamplerChunk *chunk;
776 Uint8 *data;
777 Uint32 i;
778 SDL_bool loaded = SDL_FALSE;
779
780 data = (Uint8 *)SDL_malloc(chunk_length);
781 if (!data) {
782 Mix_SetError("Out of memory");
783 return SDL_FALSE;
784 }
785 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
786 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
787 SDL_free(data);
788 return SDL_FALSE;
789 }
790 chunk = (SamplerChunk *)data;
791
792 for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) {
793 const Uint32 LOOP_TYPE_FORWARD = 0;
794 Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type);
795 if (loop_type == LOOP_TYPE_FORWARD) {
796 AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end));
797 }
798 }
799
800 loaded = SDL_TRUE;
801 SDL_free(data);
802 return loaded;
803 }
804
805 static void read_meta_field(Mix_MusicMetaTags *tags, Mix_MusicMetaTag tag_type, size_t *i, Uint32 chunk_length, Uint8 *data, size_t fieldOffset)
806 {
807 Uint32 len = 0;
808 int isID3 = fieldOffset == 7;
809 char *field = NULL;
810 *i += 4;
811 len = isID3 ?
812 SDL_SwapBE32(*((Uint32 *)(data + *i))) : /* ID3 */
813 SDL_SwapLE32(*((Uint32 *)(data + *i))); /* LIST */
814 if (len > chunk_length) {
815 return; /* Do nothing due to broken lenght */
816 }
817 *i += fieldOffset;
818 field = (char *)SDL_malloc(len + 1);
819 SDL_memset(field, 0, (len + 1));
820 SDL_strlcpy(field, (char *)(data + *i), isID3 ? len - 1 : len);
821 *i += len;
822 meta_tags_set(tags, tag_type, field);
823 SDL_free(field);
824 }
825
826 static SDL_bool ParseLIST(WAV_Music *wave, Uint32 chunk_length)
827 {
828 Uint8 *data;
829
830 data = (Uint8 *)SDL_malloc(chunk_length);
831 if (!data) {
832 Mix_SetError("Out of memory");
833 return SDL_FALSE;
834 }
835
836 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
837 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
838 SDL_free(data);
839 return SDL_FALSE;
840 }
841
842 if (SDL_strncmp((char *)data, "INFO", 4) == 0) {
843 size_t i = 4;
844 for (i = 4; i < chunk_length - 4;) {
845 if(SDL_strncmp((char *)(data + i), "INAM", 4) == 0) {
846 read_meta_field(&wave->tags, MIX_META_TITLE, &i, chunk_length, data, 4);
847 continue;
848 } else if(SDL_strncmp((char *)(data + i), "IART", 4) == 0) {
849 read_meta_field(&wave->tags, MIX_META_ARTIST, &i, chunk_length, data, 4);
850 continue;
851 } else if(SDL_strncmp((char *)(data + i), "IALB", 4) == 0) {
852 read_meta_field(&wave->tags, MIX_META_ALBUM, &i, chunk_length, data, 4);
853 continue;
854 } else if (SDL_strncmp((char *)(data + i), "BCPR", 4) == 0) {
855 read_meta_field(&wave->tags, MIX_META_COPYRIGHT, &i, chunk_length, data, 4);
856 continue;
857 }
858 i++;
859 }
860 }
861
862 /* done: */
863 SDL_free(data);
864
865 return SDL_TRUE;
866 }
867
868 static SDL_bool LoadWAVMusic(WAV_Music *wave)
869 {
870 SDL_RWops *src = wave->src;
871 Uint32 chunk_type;
872 Uint32 chunk_length;
873 SDL_bool found_FMT = SDL_FALSE;
874 SDL_bool found_DATA = SDL_FALSE;
875 /* WAV magic header */
876 Uint32 wavelen;
877 Uint32 WAVEmagic;
878
879 meta_tags_init(&wave->tags);
880
881 /* Check the magic header */
882 wavelen = SDL_ReadLE32(src);
883 WAVEmagic = SDL_ReadLE32(src);
884
885 (void)wavelen; /* unused */
886 (void)WAVEmagic; /* unused */
887
888 /* Read the chunks */
889 for (; ;) {
890 chunk_type = SDL_ReadLE32(src);
891 chunk_length = SDL_ReadLE32(src);
892
893 if (chunk_length == 0)
894 break;
895
896 switch (chunk_type)
897 {
898 case FMT:
899 found_FMT = SDL_TRUE;
900 if (!ParseFMT(wave, chunk_length))
901 return SDL_FALSE;
902 break;
903 case DATA:
904 found_DATA = SDL_TRUE;
905 if (!ParseDATA(wave, chunk_length))
906 return SDL_FALSE;
907 break;
908 case SMPL:
909 if (!ParseSMPL(wave, chunk_length))
910 return SDL_FALSE;
911 break;
912 case LIST:
913 if (!ParseLIST(wave, chunk_length))
914 return SDL_FALSE;
915 break;
916 default:
917 SDL_RWseek(src, chunk_length, RW_SEEK_CUR);
918 break;
919 }
920 }
921
922 if (!found_FMT) {
923 Mix_SetError("Bad WAV file (no FMT chunk)");
924 return SDL_FALSE;
925 }
926
927 if (!found_DATA) {
928 Mix_SetError("Bad WAV file (no DATA chunk)");
929 return SDL_FALSE;
930 }
931
932 return SDL_TRUE;
933 }
934
935 /* I couldn't get SANE_to_double() to work, so I stole this from libsndfile.
936 * I don't pretend to fully understand it.
937 */
938
939 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
940 {
941 /* Negative number? */
942 if (sanebuf[0] & 0x80)
943 return 0;
944
945 /* Less than 1? */
946 if (sanebuf[0] <= 0x3F)
947 return 1;
948
949 /* Way too big? */
950 if (sanebuf[0] > 0x40)
951 return 0x4000000;
952
953 /* Still too big? */
954 if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)
955 return 800000000;
956
957 return (Uint32)(((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) |
958 (sanebuf[5] >> 1)) >> (29 - sanebuf[1]));
959 }
960
961 static SDL_bool LoadAIFFMusic(WAV_Music *wave)
962 {
963 SDL_RWops *src = wave->src;
964 SDL_AudioSpec *spec = &wave->spec;
965 SDL_bool found_SSND = SDL_FALSE;
966 SDL_bool found_COMM = SDL_FALSE;
967 SDL_bool found_FVER = SDL_FALSE;
968 SDL_bool is_AIFC = SDL_FALSE;
969
970 Uint32 chunk_type;
971 Uint32 chunk_length;
972 Sint64 next_chunk = 0;
973 Sint64 file_length;
974
975 /* AIFF magic header */
976 Uint32 AIFFmagic;
977 /* SSND chunk */
978 Uint32 offset;
979 Uint32 blocksize;
980 /* COMM format chunk */
981 Uint16 channels = 0;
982 Uint32 numsamples = 0;
983 Uint16 samplesize = 0;
984 Uint8 sane_freq[10];
985 Uint32 frequency = 0;
986 Uint32 AIFCVersion1 = 0;
987 Uint32 compressionType = 0;
988 char *chunk_buffer;
989
990 file_length = SDL_RWsize(src);
991
992 /* Check the magic header */
993 chunk_length = SDL_ReadBE32(src);
994 AIFFmagic = SDL_ReadLE32(src);
995 if (AIFFmagic != AIFF && AIFFmagic != AIFC) {
996 Mix_SetError("Unrecognized file type (not AIFF or AIFC)");
997 return SDL_FALSE;
998 }
999 if (AIFFmagic == AIFC) {
1000 is_AIFC = SDL_TRUE;
1001 }
1002
1003 /* From what I understand of the specification, chunks may appear in
1004 * any order, and we should just ignore unknown ones.
1005 *
1006 * TODO: Better sanity-checking. E.g. what happens if the AIFF file
1007 * contains compressed sound data?
1008 */
1009 do {
1010 chunk_type = SDL_ReadLE32(src);
1011 chunk_length = SDL_ReadBE32(src);
1012 next_chunk = SDL_RWtell(src) + chunk_length;
1013
1014 if (chunk_length % 2) {
1015 next_chunk++;
1016 }
1017
1018 switch (chunk_type) {
1019 case SSND:
1020 found_SSND = SDL_TRUE;
1021 offset = SDL_ReadBE32(src);
1022 blocksize = SDL_ReadBE32(src);
1023 wave->start = SDL_RWtell(src) + offset;
1024 (void)blocksize; /* unused */
1025 break;
1026
1027 case FVER:
1028 found_FVER = SDL_TRUE;
1029 AIFCVersion1 = SDL_ReadBE32(src);
1030 (void)AIFCVersion1; /* unused */
1031 break;
1032
1033 case MARK:
1034 case INST:
1035 /* Just skip those chunks */
1036 break;
1037
1038 case NAME:
1039 case AUTH:
1040 case _c__:
1041 chunk_buffer = (char*)SDL_calloc(1, chunk_length + 1);
1042 if (SDL_RWread(src, chunk_buffer, 1, chunk_length) != chunk_length) {
1043 SDL_free(chunk_buffer);
1044 return SDL_FALSE;
1045 }
1046 meta_tags_set(&wave->tags,
1047 chunk_type == NAME ? MIX_META_TITLE :
1048 chunk_type == AUTH ? MIX_META_ARTIST :
1049 chunk_type == _c__ ? MIX_META_COPYRIGHT : 0,
1050 chunk_buffer);
1051 SDL_free(chunk_buffer);
1052 break;
1053
1054 case COMM:
1055 found_COMM = SDL_TRUE;
1056
1057 /* Read the audio data format chunk */
1058 channels = SDL_ReadBE16(src);
1059 numsamples = SDL_ReadBE32(src);
1060 samplesize = SDL_ReadBE16(src);
1061 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
1062 frequency = SANE_to_Uint32(sane_freq);
1063 if (is_AIFC) {
1064 compressionType = SDL_ReadLE32(src);
1065 /* here must be a "compressionName" which is a padded string */
1066 }
1067 break;
1068
1069 default:
1070 /* Unknown/unsupported chunk: we just skip over */
1071 break;
1072 }
1073 } while (next_chunk < file_length && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1);
1074
1075 if (!found_SSND) {
1076 Mix_SetError("Bad AIFF/AIFF-C file (no SSND chunk)");
1077 return SDL_FALSE;
1078 }
1079
1080 if (!found_COMM) {
1081 Mix_SetError("Bad AIFF/AIFF-C file (no COMM chunk)");
1082 return SDL_FALSE;
1083 }
1084
1085 if (is_AIFC && !found_FVER) {
1086 Mix_SetError("Bad AIFF-C file (no FVER chunk)");
1087 return SDL_FALSE;
1088 }
1089
1090
1091 wave->samplesize = channels * (samplesize / 8);
1092 wave->stop = wave->start + channels * numsamples * (samplesize / 8);
1093
1094 /* Decode the audio data format */
1095 SDL_memset(spec, 0, (sizeof *spec));
1096 spec->freq = (int)frequency;
1097 switch (samplesize) {
1098 case 8:
1099 if (!is_AIFC)
1100 spec->format = AUDIO_S8;
1101 else switch (compressionType) {
1102 case raw_: spec->format = AUDIO_U8; break;
1103 case sowt: spec->format = AUDIO_S8; break;
1104 case ulaw:
1105 spec->format = AUDIO_S16LSB;
1106 wave->encoding = uLAW_CODE;
1107 wave->decode = fetch_ulaw;
1108 break;
1109 case alaw:
1110 spec->format = AUDIO_S16LSB;
1111 wave->encoding = ALAW_CODE;
1112 wave->decode = fetch_alaw;
1113 break;
1114 default: goto unsupported_format;
1115 }
1116 break;
1117 case 16:
1118 if (!is_AIFC)
1119 spec->format = AUDIO_S16MSB;
1120 else switch (compressionType) {
1121 case sowt: spec->format = AUDIO_S16LSB; break;
1122 case NONE: spec->format = AUDIO_S16MSB; break;
1123 case ULAW:
1124 spec->format = AUDIO_S16LSB;
1125 wave->encoding = uLAW_CODE;
1126 wave->decode = fetch_ulaw;
1127 break;
1128 case ALAW:
1129 spec->format = AUDIO_S16LSB;
1130 wave->encoding = ALAW_CODE;
1131 wave->decode = fetch_alaw;
1132 break;
1133 default: goto unsupported_format;
1134 }
1135 break;
1136 case 24:
1137 wave->encoding = PCM_CODE;
1138 wave->decode = fetch_pcm24be;
1139 if (!is_AIFC)
1140 spec->format = AUDIO_S32MSB;
1141 else switch (compressionType) {
1142 case sowt: spec->format = AUDIO_S32LSB; break;
1143 case NONE: spec->format = AUDIO_S32MSB; break;
1144 default: goto unsupported_format;
1145 }
1146 break;
1147 case 32:
1148 if (!is_AIFC)
1149 spec->format = AUDIO_S32MSB;
1150 else switch (compressionType) {
1151 case sowt: spec->format = AUDIO_S32LSB; break;
1152 case NONE: spec->format = AUDIO_S32MSB; break;
1153 case fl32:
1154 case FL32: spec->format = AUDIO_F32MSB; break;
1155 default: goto unsupported_format;
1156 }
1157 break;
1158 case 64:
1159 wave->encoding = FLOAT_CODE;
1160 wave->decode = fetch_float64be;
1161 if (!is_AIFC)
1162 spec->format = AUDIO_F32;
1163 else switch (compressionType) {
1164 case fl64:
1165 spec->format = AUDIO_F32;
1166 break;
1167 default: goto unsupported_format;
1168 }
1169 break;
1170 default:
1171 unsupported_format:
1172 Mix_SetError("Unknown samplesize in data format");
1173 return SDL_FALSE;
1174 }
1175 spec->channels = (Uint8) channels;
1176 spec->samples = 4096; /* Good default buffer size */
1177 spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
1178 spec->size *= spec->channels;
1179 spec->size *= spec->samples;
1180
1181 return SDL_TRUE;
1182 }
1183
1184 Mix_MusicInterface Mix_MusicInterface_WAV =
1185 {
1186 "WAVE",
1187 MIX_MUSIC_WAVE,
1188 MUS_WAV,
1189 SDL_FALSE,
1190 SDL_FALSE,
1191
1192 NULL, /* Load */
1193 NULL, /* Open */
1194 WAV_CreateFromRW,
1195 NULL, /* CreateFromFile */
1196 WAV_SetVolume,
1197 WAV_GetVolume,
1198 WAV_Play,
1199 NULL, /* IsPlaying */
1200 WAV_GetAudio,
1201 NULL, /* Jump */
1202 WAV_Seek, /* Seek */
1203 WAV_Tell, /* Tell */
1204 WAV_Duration,
1205 NULL, /* LoopStart */
1206 NULL, /* LoopEnd */
1207 NULL, /* LoopLength */
1208 WAV_GetMetaTag, /* GetMetaTag */
1209 NULL, /* Pause */
1210 NULL, /* Resume */
1211 NULL, /* Stop */
1212 WAV_Delete,
1213 NULL, /* Close */
1214 NULL /* Unload */
1215 };
1216
1217 #endif /* MUSIC_WAV */
1218
1219 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports streaming WAV files */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_WAV;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifdef MUSIC_MOD_XMP
22
23 #include "SDL_loadso.h"
24
25 #include "music_xmp.h"
26
27 #ifdef LIBXMP_HEADER
28 #include LIBXMP_HEADER
29 #else
30 #include <xmp.h>
31 #endif
32
33 /* libxmp >= 4.5.0 constified several funcs */
34 #if (XMP_VERCODE < 0x040500)
35 #define LIBXMP_CONST
36 #else
37 #define LIBXMP_CONST const
38 #endif
39
40 typedef struct {
41 int loaded;
42 void *handle;
43
44 xmp_context (*xmp_create_context)(void);
45 int (*xmp_load_module_from_memory)(xmp_context, LIBXMP_CONST void *, long);
46 int (*xmp_start_player)(xmp_context, int, int);
47 void (*xmp_end_player)(xmp_context);
48 void (*xmp_get_module_info)(xmp_context, struct xmp_module_info *);
49 int (*xmp_play_buffer)(xmp_context, void *, int, int);
50 int (*xmp_set_position)(xmp_context, int);
51 int (*xmp_seek_time)(xmp_context, int);
52 void (*xmp_get_frame_info)(xmp_context, struct xmp_frame_info *);
53 void (*xmp_stop_module)(xmp_context);
54 void (*xmp_release_module)(xmp_context);
55 void (*xmp_free_context)(xmp_context);
56 } xmp_loader;
57
58 static xmp_loader libxmp = {
59 0, NULL
60 };
61
62 #ifdef XMP_DYNAMIC
63 #define FUNCTION_LOADER(FUNC, SIG) \
64 libxmp.FUNC = (SIG) SDL_LoadFunction(libxmp.handle, #FUNC); \
65 if (libxmp.FUNC == NULL) { SDL_UnloadObject(libxmp.handle); return -1; }
66 #else
67 #define FUNCTION_LOADER(FUNC, SIG) \
68 libxmp.FUNC = FUNC;
69 #endif
70
71 static int XMP_Load(void)
72 {
73 if (libxmp.loaded == 0) {
74 #ifdef XMP_DYNAMIC
75 libxmp.handle = SDL_LoadObject(XMP_DYNAMIC);
76 if (libxmp.handle == NULL) {
77 return -1;
78 }
79 #elif defined(__MACOSX__)
80 extern xmp_context xmp_create_context(void) __attribute__((weak_import));
81 if (xmp_create_context == NULL) {
82 /* Missing weakly linked framework */
83 Mix_SetError("Missing xmp.framework");
84 return -1;
85 }
86 #endif
87 FUNCTION_LOADER(xmp_create_context, xmp_context(*)(void))
88 FUNCTION_LOADER(xmp_load_module_from_memory, int(*)(xmp_context,LIBXMP_CONST void *,long))
89 FUNCTION_LOADER(xmp_start_player, int(*)(xmp_context,int,int))
90 FUNCTION_LOADER(xmp_end_player, void(*)(xmp_context))
91 FUNCTION_LOADER(xmp_get_module_info, void(*)(xmp_context,struct xmp_module_info*))
92 FUNCTION_LOADER(xmp_play_buffer, int(*)(xmp_context,void*,int,int))
93 FUNCTION_LOADER(xmp_set_position, int(*)(xmp_context,int))
94 FUNCTION_LOADER(xmp_seek_time, int(*)(xmp_context,int))
95 FUNCTION_LOADER(xmp_get_frame_info, void(*)(xmp_context,struct xmp_frame_info*))
96 FUNCTION_LOADER(xmp_stop_module, void(*)(xmp_context))
97 FUNCTION_LOADER(xmp_release_module, void(*)(xmp_context))
98 FUNCTION_LOADER(xmp_free_context, void(*)(xmp_context))
99 }
100 ++libxmp.loaded;
101
102 return 0;
103 }
104
105 static void XMP_Unload(void)
106 {
107 if (libxmp.loaded == 0) {
108 return;
109 }
110 if (libxmp.loaded == 1) {
111 #ifdef XMP_DYNAMIC
112 SDL_UnloadObject(libxmp.handle);
113 #endif
114 }
115 --libxmp.loaded;
116 }
117
118
119 typedef struct
120 {
121 int volume;
122 int play_count;
123 struct xmp_module_info mi;
124 struct xmp_frame_info fi;
125 xmp_context ctx;
126 SDL_AudioStream *stream;
127 void *buffer;
128 int buffer_size;
129 Mix_MusicMetaTags tags;
130 } XMP_Music;
131
132
133 static int XMP_Seek(void *ctx, double pos);
134 static void XMP_Delete(void *ctx);
135
136 static void libxmp_set_error(int e)
137 {
138 const char *msg;
139 switch (e) {
140 case -XMP_ERROR_INTERNAL:
141 msg = "Internal error in libxmp";
142 break;
143 case -XMP_ERROR_FORMAT:
144 msg = "Unrecognized file format";
145 break;
146 case -XMP_ERROR_LOAD:
147 msg = "Error loading file";
148 break;
149 case -XMP_ERROR_DEPACK:
150 msg = "Error depacking file";
151 break;
152 case -XMP_ERROR_SYSTEM:
153 msg = "System error in libxmp";
154 break;
155 case -XMP_ERROR_INVALID:
156 msg = "Invalid parameter";
157 break;
158 case -XMP_ERROR_STATE:
159 msg = "Invalid player state";
160 break;
161 default:
162 msg = "Unknown error";
163 break;
164 }
165 Mix_SetError("XMP: %s", msg);
166 }
167
168 /* Load a libxmp stream from an SDL_RWops object */
169 void *XMP_CreateFromRW(SDL_RWops *src, int freesrc)
170 {
171 XMP_Music *music;
172 void *mem;
173 size_t size;
174 int err;
175
176 music = (XMP_Music *)SDL_calloc(1, sizeof(*music));
177 if (!music) {
178 SDL_OutOfMemory();
179 return NULL;
180 }
181
182 music->ctx = libxmp.xmp_create_context();
183 if (!music->ctx) {
184 SDL_OutOfMemory();
185 goto e0;
186 }
187
188 music->buffer_size = music_spec.samples * 2 * 2;
189 music->buffer = SDL_malloc((size_t)music->buffer_size);
190 if (!music->buffer) {
191 SDL_OutOfMemory();
192 goto e1;
193 }
194
195 mem = SDL_LoadFile_RW(src, &size, SDL_FALSE);
196 if (mem) {
197 err = libxmp.xmp_load_module_from_memory(music->ctx, mem, (long)size);
198 SDL_free(mem);
199 if (err < 0) {
200 libxmp_set_error(err);
201 goto e1;
202 }
203 } else {
204 SDL_OutOfMemory();
205 goto e1;
206 }
207
208 err = libxmp.xmp_start_player(music->ctx, music_spec.freq, 0);
209 if (err < 0) {
210 libxmp_set_error(err);
211 goto e2;
212 }
213
214 music->volume = MIX_MAX_VOLUME;
215 music->stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, music_spec.freq,
216 music_spec.format, music_spec.channels, music_spec.freq);
217 if (!music->stream) {
218 goto e3;
219 }
220
221 meta_tags_init(&music->tags);
222 libxmp.xmp_get_module_info(music->ctx, &music->mi);
223 if (music->mi.comment) {
224 meta_tags_set(&music->tags, MIX_META_TITLE, music->mi.comment);
225 }
226
227 if (freesrc) {
228 SDL_RWclose(src);
229 }
230 return music;
231
232 e3: libxmp.xmp_end_player(music->ctx);
233 e2: libxmp.xmp_release_module(music->ctx);
234 e1: libxmp.xmp_free_context(music->ctx);
235 e0: SDL_free(music->buffer); SDL_free(music);
236 return NULL;
237 }
238
239 /* Set the volume for a libxmp stream */
240 static void XMP_SetVolume(void *context, int volume)
241 {
242 XMP_Music *music = (XMP_Music *)context;
243 music->volume = volume;
244 }
245
246 /* Get the volume for a libxmp stream */
247 static int XMP_GetVolume(void *context)
248 {
249 XMP_Music *music = (XMP_Music *)context;
250 return music->volume;
251 }
252
253 /* Start playback of a given libxmp stream */
254 static int XMP_Play(void *context, int play_count)
255 {
256 XMP_Music *music = (XMP_Music *)context;
257 music->play_count = play_count;
258 return XMP_Seek(music, 0);
259 }
260
261 /* Play some of a stream previously started with xmp_play() */
262 static int XMP_GetSome(void *context, void *data, int bytes, SDL_bool *done)
263 {
264 XMP_Music *music = (XMP_Music *)context;
265 int filled, amount, ret;
266
267 filled = SDL_AudioStreamGet(music->stream, data, bytes);
268 if (filled != 0) {
269 return filled;
270 }
271
272 if (!music->play_count) {
273 /* All done */
274 *done = SDL_TRUE;
275 return 0;
276 }
277
278 /* if the data write is partial, rest of the buffer will be zero-filled.
279 * the loop param is the max number that the current sequence of song
280 * will be looped, or 0 to disable loop checking: 0 for play_count < 0
281 * for an endless loop, or 1 for our own loop checks to do their job. */
282 ret = libxmp.xmp_play_buffer(music->ctx, music->buffer, music->buffer_size, (music->play_count > 0));
283 amount = music->buffer_size;
284
285 if (ret == 0) {
286 if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) {
287 return -1;
288 }
289 } else {
290 if (ret != -XMP_END) {
291 return -1;
292 }
293 if (music->play_count == 1) {
294 music->play_count = 0;
295 SDL_AudioStreamFlush(music->stream);
296 } else {
297 int play_count = -1;
298 if (music->play_count > 0) {
299 play_count = (music->play_count - 1);
300 }
301 if (XMP_Play(music, play_count) < 0) {
302 return -1;
303 }
304 }
305 }
306 return 0;
307 }
308 static int XMP_GetAudio(void *context, void *data, int bytes)
309 {
310 XMP_Music *music = (XMP_Music *)context;
311 return music_pcm_getaudio(context, data, bytes, music->volume, XMP_GetSome);
312 }
313
314 /* Jump to a given order */
315 static int XMP_Jump(void *context, int order)
316 {
317 XMP_Music *music = (XMP_Music *)context;
318 return libxmp.xmp_set_position(music->ctx, order);
319 }
320
321 /* Jump (seek) to a given position */
322 static int XMP_Seek(void *context, double pos)
323 {
324 XMP_Music *music = (XMP_Music *)context;
325 libxmp.xmp_seek_time(music->ctx, (int)(pos * 1000));
326 libxmp.xmp_play_buffer(music->ctx, NULL, 0, 0); /* reset internal state. */
327 return 0;
328 }
329
330 static double XMP_Tell(void *context)
331 {
332 XMP_Music *music = (XMP_Music *)context;
333 libxmp.xmp_get_frame_info(music->ctx, &music->fi);
334 return music->fi.time / 1000.0;
335 }
336
337 static double XMP_Duration(void *context)
338 {
339 XMP_Music *music = (XMP_Music *)context;
340 libxmp.xmp_get_frame_info(music->ctx, &music->fi);
341 return music->fi.total_time / 1000.0;
342 }
343
344 static const char* XMP_GetMetaTag(void *context, Mix_MusicMetaTag tag_type)
345 {
346 XMP_Music *music = (XMP_Music *)context;
347 return meta_tags_get(&music->tags, tag_type);
348 }
349
350 /* Close the given libxmp stream */
351 static void XMP_Delete(void *context)
352 {
353 XMP_Music *music = (XMP_Music *)context;
354 meta_tags_clear(&music->tags);
355 if (music->ctx) {
356 libxmp.xmp_stop_module(music->ctx);
357 libxmp.xmp_end_player(music->ctx);
358 libxmp.xmp_release_module(music->ctx);
359 libxmp.xmp_free_context(music->ctx);
360 }
361 if (music->stream) {
362 SDL_FreeAudioStream(music->stream);
363 }
364 if (music->buffer) {
365 SDL_free(music->buffer);
366 }
367 SDL_free(music);
368 }
369
370 Mix_MusicInterface Mix_MusicInterface_XMP =
371 {
372 "XMP",
373 MIX_MUSIC_LIBXMP,
374 MUS_MOD,
375 SDL_FALSE,
376 SDL_FALSE,
377
378 XMP_Load,
379 NULL, /* Open */
380 XMP_CreateFromRW,
381 NULL, /* CreateFromFile */
382 XMP_SetVolume,
383 XMP_GetVolume,
384 XMP_Play,
385 NULL, /* IsPlaying */
386 XMP_GetAudio,
387 XMP_Jump,
388 XMP_Seek,
389 XMP_Tell,
390 XMP_Duration,
391 NULL, /* LoopStart */
392 NULL, /* LoopEnd */
393 NULL, /* LoopLength */
394 XMP_GetMetaTag,
395 NULL, /* Pause */
396 NULL, /* Resume */
397 NULL, /* Stop */
398 XMP_Delete,
399 NULL, /* Close */
400 XMP_Unload
401 };
402
403 #endif /* MUSIC_MOD_XMP */
404
405 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* This file supports playing MOD files with libxmp */
22
23 #include "music.h"
24
25 extern Mix_MusicInterface Mix_MusicInterface_XMP;
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef NATIVE_MIDI_H_
22 #define NATIVE_MIDI_H_
23
24 #include "SDL_rwops.h"
25
26 typedef struct _NativeMidiSong NativeMidiSong;
27
28 int native_midi_detect(void);
29 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc);
30 void native_midi_freesong(NativeMidiSong *song);
31 void native_midi_start(NativeMidiSong *song, int loops);
32 void native_midi_pause(void);
33 void native_midi_resume(void);
34 void native_midi_stop(void);
35 int native_midi_active(void);
36 void native_midi_setvolume(int volume);
37 const char *native_midi_error(void);
38
39 #endif /* NATIVE_MIDI_H_ */
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21
22 #include "native_midi_common.h"
23
24 #include "SDL_mixer.h"
25
26 /* The constant 'MThd' */
27 #define MIDI_MAGIC 0x4d546864
28 /* The constant 'RIFF' */
29 #define RIFF_MAGIC 0x52494646
30
31 /* A single midi track as read from the midi file */
32 typedef struct
33 {
34 Uint8 *data; /* MIDI message stream */
35 int len; /* length of the track data */
36 } MIDITrack;
37
38 /* A midi file, stripped down to the absolute minimum - divison & track data */
39 typedef struct
40 {
41 int division; /* number of pulses per quarter note (ppqn) */
42 int nTracks; /* number of tracks */
43 MIDITrack *track; /* tracks */
44 } MIDIFile;
45
46
47 /* Some macros that help us stay endianess-independant */
48 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
49 #define BE_SHORT(x) (x)
50 #define BE_LONG(x) (x)
51 #else
52 #define BE_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
53 #define BE_LONG(x) ((((x)&0x0000FF)<<24) | \
54 (((x)&0x00FF00)<<8) | \
55 (((x)&0xFF0000)>>8) | \
56 (((x)>>24)&0xFF))
57 #endif
58
59
60
61 /* Get Variable Length Quantity */
62 static int GetVLQ(MIDITrack *track, int *currentPos)
63 {
64 int l = 0;
65 Uint8 c;
66 while(1)
67 {
68 c = track->data[*currentPos];
69 (*currentPos)++;
70 l += (c & 0x7f);
71 if (!(c & 0x80))
72 return l;
73 l <<= 7;
74 }
75 }
76
77 /* Create a single MIDIEvent */
78 static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b)
79 {
80 MIDIEvent *newEvent;
81
82 newEvent = SDL_calloc(1, sizeof(MIDIEvent));
83
84 if (newEvent)
85 {
86 newEvent->time = time;
87 newEvent->status = event;
88 newEvent->data[0] = a;
89 newEvent->data[1] = b;
90 }
91 else
92 Mix_SetError("Out of memory");
93
94 return newEvent;
95 }
96
97 /* Convert a single midi track to a list of MIDIEvents */
98 static MIDIEvent *MIDITracktoStream(MIDITrack *track)
99 {
100 Uint32 atime = 0;
101 Uint32 len = 0;
102 Uint8 event,type,a,b;
103 Uint8 laststatus = 0;
104 Uint8 lastchan = 0;
105 int currentPos = 0;
106 int end = 0;
107 MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
108 MIDIEvent *currentEvent = head;
109
110 while (!end)
111 {
112 if (currentPos >= track->len)
113 break; /* End of data stream reached */
114
115 atime += GetVLQ(track, &currentPos);
116 event = track->data[currentPos++];
117
118 /* Handle SysEx seperatly */
119 if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX)
120 {
121 if (event == 0xFF)
122 {
123 type = track->data[currentPos];
124 currentPos++;
125 switch(type)
126 {
127 case 0x2f: /* End of data marker */
128 end = 1;
129 case 0x51: /* Tempo change */
130 /*
131 a=track->data[currentPos];
132 b=track->data[currentPos+1];
133 c=track->data[currentPos+2];
134 AddEvent(song, atime, MEVT_TEMPO, c, b, a);
135 */
136 break;
137 }
138 }
139 else
140 type = 0;
141
142 len = GetVLQ(track, &currentPos);
143
144 /* Create an event and attach the extra data, if any */
145 currentEvent->next = CreateEvent(atime, event, type, 0);
146 currentEvent = currentEvent->next;
147 if (NULL == currentEvent)
148 {
149 FreeMIDIEventList(head);
150 return NULL;
151 }
152 if (len)
153 {
154 currentEvent->extraLen = len;
155 currentEvent->extraData = SDL_malloc(len);
156 SDL_memcpy(currentEvent->extraData, &(track->data[currentPos]), len);
157 currentPos += len;
158 }
159 }
160 else
161 {
162 a = event;
163 if (a & 0x80) /* It's a status byte */
164 {
165 /* Extract channel and status information */
166 lastchan = a & 0x0F;
167 laststatus = (a>>4) & 0x0F;
168
169 /* Read the next byte which should always be a data byte */
170 a = track->data[currentPos++] & 0x7F;
171 }
172 switch(laststatus)
173 {
174 case MIDI_STATUS_NOTE_OFF:
175 case MIDI_STATUS_NOTE_ON: /* Note on */
176 case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */
177 case MIDI_STATUS_CONTROLLER: /* Control change */
178 case MIDI_STATUS_PITCH_WHEEL: /* Pitch wheel */
179 b = track->data[currentPos++] & 0x7F;
180 currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b);
181 currentEvent = currentEvent->next;
182 if (NULL == currentEvent)
183 {
184 FreeMIDIEventList(head);
185 return NULL;
186 }
187 break;
188
189 case MIDI_STATUS_PROG_CHANGE: /* Program change */
190 case MIDI_STATUS_PRESSURE: /* Channel pressure */
191 a &= 0x7f;
192 currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0);
193 currentEvent = currentEvent->next;
194 if (NULL == currentEvent)
195 {
196 FreeMIDIEventList(head);
197 return NULL;
198 }
199 break;
200
201 default: /* Sysex already handled above */
202 break;
203 }
204 }
205 }
206
207 currentEvent = head->next;
208 SDL_free(head); /* release the dummy head event */
209 return currentEvent;
210 }
211
212 /*
213 * Convert a midi song, consisting of up to 32 tracks, to a list of MIDIEvents.
214 * To do so, first convert the tracks seperatly, then interweave the resulting
215 * MIDIEvent-Lists to one big list.
216 */
217 static MIDIEvent *MIDItoStream(MIDIFile *mididata)
218 {
219 MIDIEvent **track;
220 MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
221 MIDIEvent *currentEvent = head;
222 int trackID;
223
224 if (NULL == head)
225 return NULL;
226
227 track = (MIDIEvent**) SDL_calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
228 if (NULL == track)
229 {
230 SDL_free(head);
231 return NULL;
232 }
233
234 /* First, convert all tracks to MIDIEvent lists */
235 for (trackID = 0; trackID < mididata->nTracks; trackID++)
236 track[trackID] = MIDITracktoStream(&mididata->track[trackID]);
237
238 /* Now, merge the lists. */
239 /* TODO */
240 while(1)
241 {
242 Uint32 lowestTime = 0x7FFFFFFF; /* INT_MAX */
243 int currentTrackID = -1;
244
245 /* Find the next event */
246 for (trackID = 0; trackID < mididata->nTracks; trackID++)
247 {
248 if (track[trackID] && (track[trackID]->time < lowestTime))
249 {
250 currentTrackID = trackID;
251 lowestTime = track[currentTrackID]->time;
252 }
253 }
254
255 /* Check if we processes all events */
256 if (currentTrackID == -1)
257 break;
258
259 currentEvent->next = track[currentTrackID];
260 track[currentTrackID] = track[currentTrackID]->next;
261
262 currentEvent = currentEvent->next;
263
264
265 lowestTime = 0;
266 }
267
268 /* Make sure the list is properly terminated */
269 currentEvent->next = 0;
270
271 currentEvent = head->next;
272 SDL_free(track);
273 SDL_free(head); /* release the dummy head event */
274 return currentEvent;
275 }
276
277 static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
278 {
279 int i = 0;
280 Uint32 ID;
281 Uint32 size;
282 Uint16 format;
283 Uint16 tracks;
284 Uint16 division;
285
286 if (!mididata)
287 return 0;
288 if (!src)
289 return 0;
290
291 /* Make sure this is really a MIDI file */
292 SDL_RWread(src, &ID, 1, 4);
293 if (BE_LONG(ID) == RIFF_MAGIC) {
294 SDL_RWseek(src, 16, RW_SEEK_CUR);
295 SDL_RWread(src, &ID, 1, 4);
296 }
297 if (BE_LONG(ID) != MIDI_MAGIC)
298 return 0;
299
300 /* Header size must be 6 */
301 SDL_RWread(src, &size, 1, 4);
302 size = BE_LONG(size);
303 if (size != 6)
304 return 0;
305
306 /* We only support format 0 and 1, but not 2 */
307 SDL_RWread(src, &format, 1, 2);
308 format = BE_SHORT(format);
309 if (format != 0 && format != 1)
310 return 0;
311
312 SDL_RWread(src, &tracks, 1, 2);
313 tracks = BE_SHORT(tracks);
314 mididata->nTracks = tracks;
315
316 /* Allocate tracks */
317 mididata->track = (MIDITrack*) SDL_calloc(1, sizeof(MIDITrack) * mididata->nTracks);
318 if (NULL == mididata->track)
319 {
320 Mix_SetError("Out of memory");
321 goto bail;
322 }
323
324 /* Retrieve the PPQN value, needed for playback */
325 SDL_RWread(src, &division, 1, 2);
326 mididata->division = BE_SHORT(division);
327
328
329 for (i=0; i<tracks; i++)
330 {
331 SDL_RWread(src, &ID, 1, 4); /* We might want to verify this is MTrk... */
332 SDL_RWread(src, &size, 1, 4);
333 size = BE_LONG(size);
334 mididata->track[i].len = size;
335 mididata->track[i].data = SDL_malloc(size);
336 if (NULL == mididata->track[i].data)
337 {
338 Mix_SetError("Out of memory");
339 goto bail;
340 }
341 SDL_RWread(src, mididata->track[i].data, 1, size);
342 }
343 return 1;
344
345 bail:
346 for(;i >= 0; i--)
347 {
348 if (mididata->track[i].data)
349 SDL_free(mididata->track[i].data);
350 }
351
352 return 0;
353 }
354
355 MIDIEvent *CreateMIDIEventList(SDL_RWops *src, Uint16 *division)
356 {
357 MIDIFile *mididata = NULL;
358 MIDIEvent *eventList;
359 int trackID;
360
361 mididata = SDL_calloc(1, sizeof(MIDIFile));
362 if (!mididata)
363 return NULL;
364
365 /* Open the file */
366 if ( src != NULL )
367 {
368 /* Read in the data */
369 if ( ! ReadMIDIFile(mididata, src))
370 {
371 SDL_free(mididata);
372 return NULL;
373 }
374 }
375 else
376 {
377 SDL_free(mididata);
378 return NULL;
379 }
380
381 if (division)
382 *division = mididata->division;
383
384 eventList = MIDItoStream(mididata);
385 if (eventList == NULL)
386 {
387 SDL_free(mididata);
388 return NULL;
389 }
390 for(trackID = 0; trackID < mididata->nTracks; trackID++)
391 {
392 if (mididata->track[trackID].data)
393 SDL_free(mididata->track[trackID].data);
394 }
395 SDL_free(mididata->track);
396 SDL_free(mididata);
397
398 return eventList;
399 }
400
401 void FreeMIDIEventList(MIDIEvent *head)
402 {
403 MIDIEvent *cur, *next;
404
405 cur = head;
406
407 while (cur)
408 {
409 next = cur->next;
410 if (cur->extraData)
411 SDL_free (cur->extraData);
412 SDL_free (cur);
413 cur = next;
414 }
415 }
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef _NATIVE_MIDI_COMMON_H_
22 #define _NATIVE_MIDI_COMMON_H_
23
24 #include "SDL.h"
25
26 /* Midi Status Bytes */
27 #define MIDI_STATUS_NOTE_OFF 0x8
28 #define MIDI_STATUS_NOTE_ON 0x9
29 #define MIDI_STATUS_AFTERTOUCH 0xA
30 #define MIDI_STATUS_CONTROLLER 0xB
31 #define MIDI_STATUS_PROG_CHANGE 0xC
32 #define MIDI_STATUS_PRESSURE 0xD
33 #define MIDI_STATUS_PITCH_WHEEL 0xE
34 #define MIDI_STATUS_SYSEX 0xF
35
36 /* We store the midi events in a linked list; this way it is
37 easy to shuffle the tracks together later on; and we are
38 flexible in the size of each elemnt.
39 */
40 typedef struct MIDIEvent
41 {
42 Uint32 time; /* Time at which this midi events occurs */
43 Uint8 status; /* Status byte */
44 Uint8 data[2]; /* 1 or 2 bytes additional data for most events */
45
46 Uint32 extraLen; /* For some SysEx events, we need additional storage */
47 Uint8 *extraData;
48
49 struct MIDIEvent *next;
50 } MIDIEvent;
51
52
53 /* Load a midifile to memory, converting it to a list of MIDIEvents.
54 This function returns a linked lists of MIDIEvents, 0 if an error occured.
55 */
56 MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division);
57
58 /* Release a MIDIEvent list after usage. */
59 void FreeMIDIEventList(MIDIEvent *head);
60
61
62 #endif /* _NATIVE_MIDI_COMMON_H_ */
0 /*
1 native_midi_haiku: Native Midi support on Haiku for the SDL_mixer library
2 Copyright (C) 2010 Egor Suvorov <egor_suvorov@mail.ru>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 #ifdef __HAIKU__
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <MidiStore.h>
27 #include <MidiDefs.h>
28 #include <MidiSynthFile.h>
29 #include <algorithm>
30 #include <assert.h>
31 extern "C" {
32 #include "native_midi.h"
33 #include "native_midi_common.h"
34 }
35
36 bool compareMIDIEvent(const MIDIEvent &a, const MIDIEvent &b)
37 {
38 return a.time < b.time;
39 }
40
41 class MidiEventsStore : public BMidi
42 {
43 public:
44 MidiEventsStore()
45 {
46 fPlaying = false;
47 fLoops = 0;
48 }
49 virtual status_t Import(SDL_RWops *src)
50 {
51 fEvs = CreateMIDIEventList(src, &fDivision);
52 if (!fEvs) {
53 return B_BAD_MIDI_DATA;
54 }
55 fTotal = 0;
56 for (MIDIEvent *x = fEvs; x; x = x->next) fTotal++;
57 fPos = fTotal;
58
59 sort_events();
60 return B_OK;
61 }
62 virtual void Run()
63 {
64 fPlaying = true;
65 fPos = 0;
66 MIDIEvent *ev = fEvs;
67
68 uint32 startTime = B_NOW;
69 while (KeepRunning())
70 {
71 if (!ev) {
72 if (fLoops && fEvs) {
73 if (fLoops > 0) --fLoops;
74 fPos = 0;
75 ev = fEvs;
76 } else
77 break;
78 }
79 SprayEvent(ev, ev->time + startTime);
80 ev = ev->next;
81 fPos++;
82 }
83 fPos = fTotal;
84 fPlaying = false;
85 }
86 virtual ~MidiEventsStore()
87 {
88 if (!fEvs) return;
89 FreeMIDIEventList(fEvs);
90 fEvs = 0;
91 }
92
93 bool IsPlaying()
94 {
95 return fPlaying;
96 }
97
98 void SetLoops(int loops)
99 {
100 fLoops = loops;
101 }
102
103 protected:
104 MIDIEvent *fEvs;
105 Uint16 fDivision;
106
107 int fPos, fTotal;
108 int fLoops;
109 bool fPlaying;
110
111 void SprayEvent(MIDIEvent *ev, uint32 time)
112 {
113 switch (ev->status & 0xF0)
114 {
115 case B_NOTE_OFF:
116 SprayNoteOff((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
117 break;
118 case B_NOTE_ON:
119 SprayNoteOn((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
120 break;
121 case B_KEY_PRESSURE:
122 SprayKeyPressure((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
123 break;
124 case B_CONTROL_CHANGE:
125 SprayControlChange((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
126 break;
127 case B_PROGRAM_CHANGE:
128 SprayProgramChange((ev->status & 0x0F) + 1, ev->data[0], time);
129 break;
130 case B_CHANNEL_PRESSURE:
131 SprayChannelPressure((ev->status & 0x0F) + 1, ev->data[0], time);
132 break;
133 case B_PITCH_BEND:
134 SprayPitchBend((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time);
135 break;
136 case 0xF:
137 switch (ev->status)
138 {
139 case B_SYS_EX_START:
140 SpraySystemExclusive(ev->extraData, ev->extraLen, time);
141 break;
142 case B_MIDI_TIME_CODE:
143 case B_SONG_POSITION:
144 case B_SONG_SELECT:
145 case B_CABLE_MESSAGE:
146 case B_TUNE_REQUEST:
147 case B_SYS_EX_END:
148 SpraySystemCommon(ev->status, ev->data[0], ev->data[1], time);
149 break;
150 case B_TIMING_CLOCK:
151 case B_START:
152 case B_STOP:
153 case B_CONTINUE:
154 case B_ACTIVE_SENSING:
155 SpraySystemRealTime(ev->status, time);
156 break;
157 case B_SYSTEM_RESET:
158 if (ev->data[0] == 0x51 && ev->data[1] == 0x03)
159 {
160 assert(ev->extraLen == 3);
161 int val = (ev->extraData[0] << 16) | (ev->extraData[1] << 8) | ev->extraData[2];
162 int tempo = 60000000 / val;
163 SprayTempoChange(tempo, time);
164 }
165 else
166 {
167 SpraySystemRealTime(ev->status, time);
168 }
169 }
170 break;
171 }
172 }
173
174 void sort_events()
175 {
176 MIDIEvent *items = new MIDIEvent[fTotal];
177 MIDIEvent *x = fEvs;
178 for (int i = 0; i < fTotal; i++)
179 {
180 memcpy(items + i, x, sizeof(MIDIEvent));
181 x = x->next;
182 }
183 std::sort(items, items + fTotal, compareMIDIEvent);
184
185 x = fEvs;
186 for (int i = 0; i < fTotal; i++)
187 {
188 MIDIEvent *ne = x->next;
189 memcpy(x, items + i, sizeof(MIDIEvent));
190 x->next = ne;
191 x = ne;
192 }
193
194 for (x = fEvs; x && x->next; x = x->next)
195 assert(x->time <= x->next->time);
196
197 delete[] items;
198 }
199 };
200
201 BMidiSynth synth;
202 struct _NativeMidiSong {
203 MidiEventsStore *store;
204 } *currentSong = NULL;
205
206 char lasterr[1024];
207
208 int native_midi_detect(void)
209 {
210 status_t res = synth.EnableInput(true, false);
211 return res == B_OK;
212 }
213
214 void native_midi_setvolume(int volume)
215 {
216 if (volume < 0) volume = 0;
217 if (volume > 128) volume = 128;
218 synth.SetVolume(volume / 128.0);
219 }
220
221 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
222 {
223 NativeMidiSong *song = new NativeMidiSong;
224 song->store = new MidiEventsStore;
225 status_t res = song->store->Import(src);
226
227 if (res != B_OK)
228 {
229 snprintf(lasterr, sizeof lasterr, "Cannot Import() midi file: status_t=%d", res);
230 delete song->store;
231 delete song;
232 return NULL;
233 }
234 else
235 {
236 if (freesrc) {
237 SDL_RWclose(src);
238 }
239 }
240 return song;
241 }
242
243 void native_midi_freesong(NativeMidiSong *song)
244 {
245 if (song == NULL) return;
246 song->store->Stop();
247 song->store->Disconnect(&synth);
248 if (currentSong == song)
249 {
250 currentSong = NULL;
251 }
252 delete song->store;
253 delete song; song = 0;
254 }
255
256 void native_midi_start(NativeMidiSong *song, int loops)
257 {
258 native_midi_stop();
259 song->store->Connect(&synth);
260 song->store->SetLoops(loops);
261 song->store->Start();
262 currentSong = song;
263 }
264
265 void native_midi_pause(void)
266 {
267 }
268
269 void native_midi_resume(void)
270 {
271 }
272
273 void native_midi_stop(void)
274 {
275 if (currentSong == NULL) return;
276 currentSong->store->Stop();
277 currentSong->store->Disconnect(&synth);
278 while (currentSong->store->IsPlaying())
279 usleep(1000);
280 currentSong = NULL;
281 }
282
283 int native_midi_active(void)
284 {
285 if (currentSong == NULL) return 0;
286 return currentSong->store->IsPlaying();
287 }
288
289 const char* native_midi_error(void)
290 {
291 return lasterr;
292 }
293
294 #endif /* __HAIKU__ */
0 /*
1 native_midi_macosx: Native Midi support on Mac OS X for the SDL_mixer library
2 Copyright (C) 2009 Ryan C. Gordon <icculus@icculus.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #include "SDL_config.h"
22
23 #if __MACOSX__
24
25 /* Mac OS X 10.6+, using Core MIDI. */
26
27 #include "SDL_stdinc.h"
28
29 #include <AudioUnit/AudioUnit.h>
30 #include <AudioToolbox/AudioToolbox.h>
31 #include <AvailabilityMacros.h>
32
33 #include "SDL_endian.h"
34 #include "SDL_mixer.h"
35 #include "../../mixer.h"
36 #include "native_midi.h"
37
38 /* Native Midi song */
39 struct _NativeMidiSong
40 {
41 MusicPlayer player;
42 MusicSequence sequence;
43 MusicTimeStamp endTime;
44 AudioUnit audiounit;
45 int loops;
46 };
47
48 static NativeMidiSong *currentsong = NULL;
49 static int latched_volume = MIX_MAX_VOLUME;
50
51 static OSStatus
52 GetSequenceLength(MusicSequence sequence, MusicTimeStamp *_sequenceLength)
53 {
54 /* http://lists.apple.com/archives/Coreaudio-api/2003/Jul/msg00370.html
55 * figure out sequence length */
56 UInt32 ntracks, i;
57 MusicTimeStamp sequenceLength = 0;
58 OSStatus err;
59
60 err = MusicSequenceGetTrackCount(sequence, &ntracks);
61 if (err != noErr)
62 return err;
63
64 for (i = 0; i < ntracks; ++i)
65 {
66 MusicTrack track;
67 MusicTimeStamp tracklen = 0;
68 UInt32 tracklenlen = sizeof (tracklen);
69
70 err = MusicSequenceGetIndTrack(sequence, i, &track);
71 if (err != noErr)
72 return err;
73
74 err = MusicTrackGetProperty(track, kSequenceTrackProperty_TrackLength,
75 &tracklen, &tracklenlen);
76 if (err != noErr)
77 return err;
78
79 if (sequenceLength < tracklen)
80 sequenceLength = tracklen;
81 }
82
83 *_sequenceLength = sequenceLength;
84
85 return noErr;
86 }
87
88 static OSStatus
89 GetSequenceAudioUnitMatching(MusicSequence sequence, AudioUnit *aunit,
90 OSType type, OSType subtype)
91 {
92 AUGraph graph;
93 UInt32 nodecount, i;
94 OSStatus err;
95
96 err = MusicSequenceGetAUGraph(sequence, &graph);
97 if (err != noErr)
98 return err;
99
100 err = AUGraphGetNodeCount(graph, &nodecount);
101 if (err != noErr)
102 return err;
103
104 for (i = 0; i < nodecount; i++) {
105 AUNode node;
106 AudioComponentDescription desc;
107
108 if (AUGraphGetIndNode(graph, i, &node) != noErr)
109 continue; /* better luck next time. */
110
111 if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr)
112 continue;
113 else if (desc.componentType != type)
114 continue;
115 else if (desc.componentSubType != subtype)
116 continue;
117
118 return noErr; /* found it! */
119 }
120
121 *aunit = NULL;
122 return kAUGraphErr_NodeNotFound;
123 }
124
125 typedef struct {
126 AudioUnit aunit;
127 SDL_bool soundfont_set;
128 CFURLRef default_url;
129 } macosx_load_soundfont_ctx;
130
131 static int SDLCALL
132 macosx_load_soundfont(const char *path, void *data)
133 {
134 CFURLRef url;
135 OSStatus err;
136 macosx_load_soundfont_ctx *ctx = data;
137 if (ctx->soundfont_set)
138 return SDL_FALSE;
139
140 url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
141 (const UInt8*)path,
142 strlen(path), false);
143 if (!url)
144 return SDL_FALSE;
145
146 err = AudioUnitSetProperty(ctx->aunit, kMusicDeviceProperty_SoundBankURL,
147 kAudioUnitScope_Global, 0, &url, sizeof(url));
148 CFRelease(url);
149 if (err != noErr) {
150 if (ctx->default_url)
151 err = AudioUnitSetProperty(ctx->aunit,
152 kMusicDeviceProperty_SoundBankURL,
153 kAudioUnitScope_Global, 0,
154 &ctx->default_url, sizeof(CFURLRef));
155 if (err != noErr) {
156 /* uh-oh, this might leave the audio unit in an unusable state
157 (e.g. if the soundfont was an incompatible file type) */
158 }
159 return SDL_FALSE;
160 }
161
162 ctx->soundfont_set = SDL_TRUE;
163 return SDL_TRUE;
164 }
165
166 static void
167 SetSequenceSoundFont(MusicSequence sequence)
168 {
169 OSStatus err;
170 macosx_load_soundfont_ctx ctx;
171 ctx.soundfont_set = SDL_FALSE;
172 ctx.default_url = NULL;
173
174 CFBundleRef bundle = CFBundleGetBundleWithIdentifier(
175 CFSTR("com.apple.audio.units.Components"));
176 if (bundle)
177 ctx.default_url = CFBundleCopyResourceURL(bundle,
178 CFSTR("gs_instruments"),
179 CFSTR("dls"), NULL);
180
181 err = GetSequenceAudioUnitMatching(sequence, &ctx.aunit,
182 kAudioUnitType_MusicDevice,
183 kAudioUnitSubType_DLSSynth);
184 if (err != noErr)
185 return;
186
187 Mix_EachSoundFont(macosx_load_soundfont, &ctx);
188 if (ctx.default_url)
189 CFRelease(ctx.default_url);
190 return;
191 }
192
193 int native_midi_detect(void)
194 {
195 return 1; /* always available. */
196 }
197
198 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
199 {
200 NativeMidiSong *retval = NULL;
201 void *buf = NULL;
202 Sint64 len = 0;
203 CFDataRef data = NULL;
204
205 if (SDL_RWseek(src, 0, RW_SEEK_END) < 0)
206 goto fail;
207 len = SDL_RWtell(src);
208 if (len < 0)
209 goto fail;
210 if (SDL_RWseek(src, 0, RW_SEEK_SET) < 0)
211 goto fail;
212
213 buf = SDL_malloc(len);
214 if (buf == NULL)
215 goto fail;
216
217 if (SDL_RWread(src, buf, len, 1) != 1)
218 goto fail;
219
220 retval = SDL_malloc(sizeof(NativeMidiSong));
221 if (retval == NULL)
222 goto fail;
223
224 SDL_memset(retval, '\0', sizeof (*retval));
225
226 if (NewMusicPlayer(&retval->player) != noErr)
227 goto fail;
228 if (NewMusicSequence(&retval->sequence) != noErr)
229 goto fail;
230
231 data = CFDataCreate(NULL, (const UInt8 *) buf, len);
232 if (data == NULL)
233 goto fail;
234
235 SDL_free(buf);
236 buf = NULL;
237
238 if (MusicSequenceFileLoadData(retval->sequence, data, 0, 0) != noErr)
239 goto fail;
240
241 CFRelease(data);
242 data = NULL;
243
244 if (GetSequenceLength(retval->sequence, &retval->endTime) != noErr)
245 goto fail;
246
247 if (MusicPlayerSetSequence(retval->player, retval->sequence) != noErr)
248 goto fail;
249
250 if (freesrc)
251 SDL_RWclose(src);
252
253 return retval;
254
255 fail:
256 if (retval) {
257 if (retval->sequence)
258 DisposeMusicSequence(retval->sequence);
259 if (retval->player)
260 DisposeMusicPlayer(retval->player);
261 SDL_free(retval);
262 }
263
264 if (data)
265 CFRelease(data);
266
267 if (buf)
268 SDL_free(buf);
269
270 return NULL;
271 }
272
273 void native_midi_freesong(NativeMidiSong *song)
274 {
275 if (song != NULL) {
276 if (currentsong == song)
277 currentsong = NULL;
278 MusicPlayerStop(song->player);
279
280 /* needed to prevent error and memory leak when disposing sequence */
281 MusicPlayerSetSequence(song->player, NULL);
282
283 DisposeMusicSequence(song->sequence);
284 DisposeMusicPlayer(song->player);
285 SDL_free(song);
286 }
287 }
288
289 void native_midi_start(NativeMidiSong *song, int loops)
290 {
291 int vol;
292
293 if (song == NULL)
294 return;
295
296 SDL_PauseAudio(1);
297 Mix_UnlockAudio();
298
299 if (currentsong)
300 MusicPlayerStop(currentsong->player);
301
302 currentsong = song;
303 currentsong->loops = loops;
304
305 MusicPlayerPreroll(song->player);
306 GetSequenceAudioUnitMatching(song->sequence, &song->audiounit,
307 kAudioUnitType_Output,
308 kAudioUnitSubType_DefaultOutput);
309 SetSequenceSoundFont(song->sequence);
310
311 vol = latched_volume;
312 latched_volume++; /* just make this not match. */
313 native_midi_setvolume(vol);
314
315 MusicPlayerSetTime(song->player, 0);
316 MusicPlayerStart(song->player);
317
318 Mix_LockAudio();
319 SDL_PauseAudio(0);
320 }
321
322 void native_midi_pause(void)
323 {
324 }
325
326 void native_midi_resume(void)
327 {
328 }
329
330 void native_midi_stop(void)
331 {
332 if (currentsong) {
333 SDL_PauseAudio(1);
334 Mix_UnlockAudio();
335 MusicPlayerStop(currentsong->player);
336 currentsong = NULL;
337 Mix_LockAudio();
338 SDL_PauseAudio(0);
339 }
340 }
341
342 int native_midi_active(void)
343 {
344 MusicTimeStamp currentTime = 0;
345 if (currentsong == NULL)
346 return 0;
347
348 MusicPlayerGetTime(currentsong->player, &currentTime);
349 if ((currentTime < currentsong->endTime) ||
350 (currentTime >= kMusicTimeStamp_EndOfTrack)) {
351 return 1;
352 } else if (currentsong->loops) {
353 --currentsong->loops;
354 MusicPlayerSetTime(currentsong->player, 0);
355 return 1;
356 }
357 return 0;
358 }
359
360 void native_midi_setvolume(int volume)
361 {
362 if (latched_volume == volume)
363 return;
364
365 latched_volume = volume;
366 if ((currentsong) && (currentsong->audiounit)) {
367 const float floatvol = ((float) volume) / ((float) MIX_MAX_VOLUME);
368 AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume,
369 kAudioUnitScope_Global, 0, floatvol, 0);
370 }
371 }
372
373 const char *native_midi_error(void)
374 {
375 return ""; /* !!! FIXME */
376 }
377
378 #endif /* Mac OS X native MIDI support */
0 /*
1 native_midi: Hardware Midi support for the SDL_mixer library
2 Copyright (C) 2000,2001 Florian 'Proff' Schulze <florian.proff.schulze@gmx.net>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_config.h"
21
22 /* everything below is currently one very big bad hack ;) Proff */
23
24 #if __WIN32__
25 #define WIN32_LEAN_AND_MEAN
26
27 #include <windows.h>
28 #include <mmsystem.h>
29
30 #include "native_midi.h"
31 #include "native_midi_common.h"
32
33 struct _NativeMidiSong {
34 int MusicLoaded;
35 int MusicPlaying;
36 int Loops;
37 int CurrentHdr;
38 MIDIHDR MidiStreamHdr[2];
39 MIDIEVENT *NewEvents;
40 Uint16 ppqn;
41 int Size;
42 int NewPos;
43 };
44
45 static UINT MidiDevice=MIDI_MAPPER;
46 static HMIDISTRM hMidiStream;
47 static NativeMidiSong *currentsong;
48
49 static int BlockOut(NativeMidiSong *song)
50 {
51 MMRESULT err;
52 int BlockSize;
53 MIDIHDR *hdr;
54
55 if ((song->MusicLoaded) && (song->NewEvents))
56 {
57 /* proff 12/8/98: Added for safety*/
58 song->CurrentHdr = !song->CurrentHdr;
59 hdr = &song->MidiStreamHdr[song->CurrentHdr];
60 midiOutUnprepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR));
61 if (song->NewPos>=song->Size)
62 return 0;
63 BlockSize=(song->Size-song->NewPos);
64 if (BlockSize<=0)
65 return 0;
66 if (BlockSize>36000)
67 BlockSize=36000;
68 hdr->lpData=(void *)((unsigned char *)song->NewEvents+song->NewPos);
69 song->NewPos+=BlockSize;
70 hdr->dwBufferLength=BlockSize;
71 hdr->dwBytesRecorded=BlockSize;
72 hdr->dwFlags=0;
73 hdr->dwOffset=0;
74 err=midiOutPrepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR));
75 if (err!=MMSYSERR_NOERROR)
76 return 0;
77 err=midiStreamOut(hMidiStream,hdr,sizeof(MIDIHDR));
78 return 0;
79 }
80 return 1;
81 }
82
83 static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist)
84 {
85 int eventcount;
86 MIDIEvent *event;
87 MIDIEVENT *newevent;
88
89 eventcount=0;
90 event=evntlist;
91 while (event)
92 {
93 eventcount++;
94 event=event->next;
95 }
96 song->NewEvents = SDL_malloc(eventcount*3*sizeof(DWORD));
97 if (!song->NewEvents)
98 return;
99 SDL_memset(song->NewEvents,0,(eventcount*3*sizeof(DWORD)));
100
101 eventcount=0;
102 event=evntlist;
103 newevent=song->NewEvents;
104 while (event)
105 {
106 int status = (event->status&0xF0)>>4;
107 switch (status)
108 {
109 case MIDI_STATUS_NOTE_OFF:
110 case MIDI_STATUS_NOTE_ON:
111 case MIDI_STATUS_AFTERTOUCH:
112 case MIDI_STATUS_CONTROLLER:
113 case MIDI_STATUS_PROG_CHANGE:
114 case MIDI_STATUS_PRESSURE:
115 case MIDI_STATUS_PITCH_WHEEL:
116 newevent->dwDeltaTime=event->time;
117 newevent->dwEvent=(event->status|0x80)|(event->data[0]<<8)|(event->data[1]<<16)|(MEVT_SHORTMSG<<24);
118 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
119 eventcount++;
120 break;
121
122 case MIDI_STATUS_SYSEX:
123 if (event->status == 0xFF && event->data[0] == 0x51) /* Tempo change */
124 {
125 int tempo = (event->extraData[0] << 16) |
126 (event->extraData[1] << 8) |
127 event->extraData[2];
128 newevent->dwDeltaTime=event->time;
129 newevent->dwEvent=(MEVT_TEMPO<<24) | tempo;
130 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
131 eventcount++;
132 }
133 break;
134 }
135
136 event=event->next;
137 }
138
139 song->Size=eventcount*3*sizeof(DWORD);
140
141 {
142 int time;
143 int temptime;
144
145 song->NewPos=0;
146 time=0;
147 newevent=song->NewEvents;
148 while (song->NewPos<song->Size)
149 {
150 temptime=newevent->dwDeltaTime;
151 newevent->dwDeltaTime-=time;
152 time=temptime;
153 if ((song->NewPos+12)>=song->Size)
154 newevent->dwEvent |= MEVT_F_CALLBACK;
155 newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
156 song->NewPos+=12;
157 }
158 }
159 song->NewPos=0;
160 song->MusicLoaded=1;
161 }
162
163 void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance,
164 DWORD_PTR dwParam1, DWORD_PTR dwParam2 )
165 {
166 (void)hMidi;
167 (void)dwInstance;
168 (void)dwParam2;
169
170 switch( uMsg )
171 {
172 case MOM_DONE:
173 if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)&currentsong->MidiStreamHdr[currentsong->CurrentHdr]))
174 BlockOut(currentsong);
175 break;
176 case MOM_POSITIONCB:
177 if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)&currentsong->MidiStreamHdr[currentsong->CurrentHdr])) {
178 if (currentsong->Loops) {
179 if (currentsong->Loops > 0)
180 --currentsong->Loops;
181 currentsong->NewPos=0;
182 BlockOut(currentsong);
183 } else {
184 currentsong->MusicPlaying=0;
185 }
186 }
187 break;
188 default:
189 break;
190 }
191 }
192
193 int native_midi_detect(void)
194 {
195 MMRESULT merr;
196 HMIDISTRM MidiStream;
197
198 merr=midiStreamOpen(&MidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION);
199 if (merr!=MMSYSERR_NOERROR)
200 return 0;
201 midiStreamClose(MidiStream);
202 return 1;
203 }
204
205 NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
206 {
207 NativeMidiSong *newsong;
208 MIDIEvent *evntlist = NULL;
209
210 newsong = SDL_malloc(sizeof(NativeMidiSong));
211 if (!newsong) {
212 return NULL;
213 }
214 SDL_memset(newsong,0,sizeof(NativeMidiSong));
215
216 /* Attempt to load the midi file */
217 evntlist = CreateMIDIEventList(src, &newsong->ppqn);
218 if (!evntlist)
219 {
220 SDL_free(newsong);
221 return NULL;
222 }
223
224 MIDItoStream(newsong, evntlist);
225
226 FreeMIDIEventList(evntlist);
227
228 if (freesrc) {
229 SDL_RWclose(src);
230 }
231 return newsong;
232 }
233
234 void native_midi_freesong(NativeMidiSong *song)
235 {
236 if (hMidiStream)
237 {
238 midiStreamStop(hMidiStream);
239 midiStreamClose(hMidiStream);
240 }
241 if (song)
242 {
243 if (song->NewEvents)
244 SDL_free(song->NewEvents);
245 SDL_free(song);
246 }
247 }
248
249 void native_midi_start(NativeMidiSong *song, int loops)
250 {
251 MMRESULT merr;
252 MIDIPROPTIMEDIV mptd;
253
254 native_midi_stop();
255 if (!hMidiStream)
256 {
257 merr=midiStreamOpen(&hMidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION);
258 if (merr!=MMSYSERR_NOERROR)
259 {
260 hMidiStream = NULL; /* should I do midiStreamClose(hMidiStream) before? */
261 return;
262 }
263 /* midiStreamStop(hMidiStream); */
264 currentsong=song;
265 currentsong->NewPos=0;
266 currentsong->MusicPlaying=1;
267 currentsong->Loops=loops;
268 mptd.cbStruct=sizeof(MIDIPROPTIMEDIV);
269 mptd.dwTimeDiv=currentsong->ppqn;
270 merr=midiStreamProperty(hMidiStream,(LPBYTE)&mptd,MIDIPROP_SET | MIDIPROP_TIMEDIV);
271 BlockOut(song);
272 merr=midiStreamRestart(hMidiStream);
273 }
274 }
275
276 void native_midi_pause(void)
277 {
278 if (!hMidiStream)
279 return;
280 midiStreamPause(hMidiStream);
281 }
282
283 void native_midi_resume(void)
284 {
285 if (!hMidiStream)
286 return;
287 midiStreamRestart(hMidiStream);
288 }
289
290 void native_midi_stop(void)
291 {
292 if (!hMidiStream)
293 return;
294 midiStreamStop(hMidiStream);
295 midiStreamClose(hMidiStream);
296 currentsong=NULL;
297 hMidiStream = NULL;
298 }
299
300 int native_midi_active(void)
301 {
302 if (!hMidiStream)
303 return 0;
304 if (!currentsong)
305 return 0;
306 return currentsong->MusicPlaying;
307 }
308
309 void native_midi_setvolume(int volume)
310 {
311 int calcVolume;
312 if (volume > 128)
313 volume = 128;
314 if (volume < 0)
315 volume = 0;
316 calcVolume = (65535 * volume / 128);
317
318 midiOutSetVolume((HMIDIOUT)hMidiStream, MAKELONG(calcVolume , calcVolume));
319 }
320
321 const char *native_midi_error(void)
322 {
323 return "";
324 }
325
326 #endif /* Windows native MIDI support */
0 LOCAL_PATH := $(call my-dir)
1
2 include $(CLEAR_VARS)
3
4 LOCAL_MODULE := timidity
5
6 LOCAL_C_INCLUDES :=
7
8 LOCAL_CFLAGS :=
9
10 LOCAL_SRC_FILES += \
11 common.c \
12 instrum.c \
13 mix.c \
14 output.c \
15 playmidi.c \
16 readmidi.c \
17 resample.c \
18 tables.c \
19 timidity.c
20
21 LOCAL_SHARED_LIBRARIES := SDL2
22
23 include $(BUILD_STATIC_LIBRARY)
0 This version of TiMidity should contain all the fixes from the
1 September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some
2 changes of my own, e.g.:
3
4 * All file access is done through SDL_RWops. This means the MIDI
5 stream no longer has to be a file. (The config file and instruments
6 still have to be though.)
7
8 * Replacing of TiMidity's endian-handling with SDL's.
9
10 * Removal of much unused or unnecessary code, such as
11
12 + The "hooks" for putting a user interface onto TiMidity.
13 + The antialias filter. It wasn't active, and even at 4 kHz I
14 couldn't hear any difference when activating it.
15 + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION.
16 According to the code comments they weren't very good anyway.
17 ("degrades sound quality noticeably"). I also removed the
18 disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM
19 to 8-bit uLaw tables" disclaimer, since I believe those were the
20 tables I removed.
21 + Removed LOOKUP_SINE since it was already commented out. I think we
22 can count on our target audience having math co-processors
23 nowadays.
24 + Removed USE_LDEXP since it wasn't being used and "it doesn't make
25 much of a difference either way".
26 + Removed decompress hack from open_file() since it didn't look very
27 portable.
28 + Removed heaps of unnecessary constants.
29 + Removed unused functions.
30 + Assume that LINEAR_INTERPOLATION is always used, so remove all
31 code dealing with it not being so. It's not that I think the
32 difference in audio quality is that great, but since it wouldn't
33 compile without code changes I assume no one's used it for quite
34 some time...
35 + Assume PRECALC_LOOPS is always defined. Judging by the comments it
36 may not make much of a difference either way, so why maintain two
37 versions of the same code?
38
39 * Moving several static globals into the MidiSong struct. This
40 includes sample rate, formate, etc. which are now all per-song.
41
42 * Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion
43 into the MIDI decoder.
44
45 * Added free_pathlist().
46
47 * Replaced TiMidity's own 8, 16 and 32-bit types with SDL's.
48
49 * Made TiMidity look for its configuration file in both /etc and
50 /usr/local/lib/timidity. (Windows version remains unchanged.)
51
52 * Timidity_PlaySome() now takes three arguments. A MidiSong, a decode
53 buffer and decode buffer size in bytes. (MidiSong is a new argument,
54 and buffer size used to be in samples.)
55
56 In addition, it will return the number of bytes decoded.
57
58 * Added Timidity_Exit().
59
60 * Removed Timidity_Stop() and Timidity_Active(). Stopping playback
61 should be handled by SDL_sound, and Timidity_PlaySome() will return
62 0 when the MIDI stream is finished.
63
64 * Modified the ToneBank stuff to allow some data to be shared between
65 MidiSongs.
66
67 * The following files have been removed: controls.c, controls.h,
68 filter.c, filter.h, sdl_a.c, sdl_c.c
69
70 * config.h has been renamed as options.h to avoid confusion with the
71 automatically generated config.h for SDL_sound.
72
73 * Added support for loading DLS format instruments:
74 Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong()
75
76 * Added Timidity_Init_NoConfig()
0 cmake_minimum_required(VERSION 2.8.11)
1 project(timidity_sdl C)
2
3 include(${CMAKE_CURRENT_SOURCE_DIR}/../../../external/audio_codec_common.cmake)
4
5 find_package(SDL2 REQUIRED)
6
7 add_library(timidity STATIC
8 common.c
9 instrum.c
10 mix.c
11 output.c
12 playmidi.c
13 readmidi.c
14 resample.c
15 tables.c
16 timidity.c
17 )
18
19 target_include_directories(timidity PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
20 target_include_directories(timidity PUBLIC ${SDL2_INCLUDE_DIRS})
21
22 install(TARGETS timidity
23 LIBRARY DESTINATION "lib"
24 ARCHIVE DESTINATION "lib"
25 INCLUDES DESTINATION "include")
26
27 install(FILES
28 timidity.h
29 DESTINATION include/)
0 The "Artistic License"
1
2 Preamble
3
4 The intent of this document is to state the conditions under which a
5 Package may be copied, such that the Copyright Holder maintains some
6 semblance of artistic control over the development of the package,
7 while giving the users of the package the right to use and distribute
8 the Package in a more-or-less customary fashion, plus the right to make
9 reasonable modifications.
10
11 Definitions:
12
13 "Package" refers to the collection of files distributed by the
14 Copyright Holder, and derivatives of that collection of files
15 created through textual modification.
16
17 "Standard Version" refers to such a Package if it has not been
18 modified, or has been modified in accordance with the wishes
19 of the Copyright Holder as specified below.
20
21 "Copyright Holder" is whoever is named in the copyright or
22 copyrights for the package.
23
24 "You" is you, if you're thinking about copying or distributing
25 this Package.
26
27 "Reasonable copying fee" is whatever you can justify on the
28 basis of media cost, duplication charges, time of people involved,
29 and so on. (You will not be required to justify it to the
30 Copyright Holder, but only to the computing community at large
31 as a market that must bear the fee.)
32
33 "Freely Available" means that no fee is charged for the item
34 itself, though there may be fees involved in handling the item.
35 It also means that recipients of the item may redistribute it
36 under the same conditions they received it.
37
38 1. You may make and give away verbatim copies of the source form of the
39 Standard Version of this Package without restriction, provided that you
40 duplicate all of the original copyright notices and associated disclaimers.
41
42 2. You may apply bug fixes, portability fixes and other modifications
43 derived from the Public Domain or from the Copyright Holder. A Package
44 modified in such a way shall still be considered the Standard Version.
45
46 3. You may otherwise modify your copy of this Package in any way, provided
47 that you insert a prominent notice in each changed file stating how and
48 when you changed that file, and provided that you do at least ONE of the
49 following:
50
51 a) place your modifications in the Public Domain or otherwise make them
52 Freely Available, such as by posting said modifications to Usenet or
53 an equivalent medium, or placing the modifications on a major archive
54 site such as uunet.uu.net, or by allowing the Copyright Holder to include
55 your modifications in the Standard Version of the Package.
56
57 b) use the modified Package only within your corporation or organization.
58
59 c) rename any non-standard executables so the names do not conflict
60 with standard executables, which must also be provided, and provide
61 a separate manual page for each non-standard executable that clearly
62 documents how it differs from the Standard Version.
63
64 d) make other distribution arrangements with the Copyright Holder.
65
66 4. You may distribute the programs of this Package in object code or
67 executable form, provided that you do at least ONE of the following:
68
69 a) distribute a Standard Version of the executables and library files,
70 together with instructions (in the manual page or equivalent) on where
71 to get the Standard Version.
72
73 b) accompany the distribution with the machine-readable source of
74 the Package with your modifications.
75
76 c) give non-standard executables non-standard names, and clearly
77 document the differences in manual pages (or equivalent), together
78 with instructions on where to get the Standard Version.
79
80 d) make other distribution arrangements with the Copyright Holder.
81
82 5. You may charge a reasonable copying fee for any distribution of this
83 Package. You may charge any fee you choose for support of this
84 Package. You may not charge a fee for this Package itself. However,
85 you may distribute this Package in aggregate with other (possibly
86 commercial) programs as part of a larger (possibly commercial) software
87 distribution provided that you do not advertise this Package as a
88 product of your own. You may embed this Package's interpreter within
89 an executable of yours (by linking); this shall be construed as a mere
90 form of aggregation, provided that the complete Standard Version of the
91 interpreter is so embedded.
92
93 6. The scripts and library files supplied as input to or produced as
94 output from the programs of this Package do not automatically fall
95 under the copyright of this Package, but belong to whoever generated
96 them, and may be sold commercially, and may be aggregated with this
97 Package. If such scripts or library files are aggregated with this
98 Package via the so-called "undump" or "unexec" methods of producing a
99 binary executable image, then distribution of such an image shall
100 neither be construed as a distribution of this Package nor shall it
101 fall under the restrictions of Paragraphs 3 and 4, provided that you do
102 not represent such an executable image as a Standard Version of this
103 Package.
104
105 7. C subroutines (or comparably compiled subroutines in other
106 languages) supplied by you and linked into this Package in order to
107 emulate subroutines and variables of the language defined by this
108 Package shall not be considered part of this Package, but are the
109 equivalent of input as in Paragraph 6, provided these subroutines do
110 not change the language in any way that would cause it to fail the
111 regression tests for the language.
112
113 8. Aggregation of this Package with a commercial distribution is always
114 permitted provided that the use of this Package is embedded; that is,
115 when no overt attempt is made to make this Package's interfaces visible
116 to the end user of the commercial distribution. Such use shall not be
117 construed as a distribution of this Package.
118
119 9. The name of the Copyright Holder may not be used to endorse or promote
120 products derived from this software without specific prior written permission.
121
122 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
123 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
124 WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
125
126 The End
0 ---------------------------*-indented-text-*------------------------------
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 --------------------------------------------------------------------------
6
7 Frequently Asked Questions with answers:
8
9 --------------------------------------------------------------------------
10 Q: What is it?
11
12 A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI
13 renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines,
14 even (I've heard) a Netscape helper application. It takes a MIDI file
15 and writes a WAVE or raw PCM data or plays it on your digital audio
16 device. It sounds much more realistic than FM synthesis, but you need a
17 ~100Mhz processor to listen to 32kHz stereo music in the background while
18 you work. 11kHz mono can be played on a low-end 486, and, to some, it
19 still sounds better than FM.
20
21 --------------------------------------------------------------------------
22 Q: I don't have a GUS, can I use TiMidity?
23
24 A: Yes. That's the point. You don't need a Gravis Ultrasound to use
25 TiMidity, you just need GUS-compatible patches, which are freely
26 available on the Internet. See below for pointers.
27
28 --------------------------------------------------------------------------
29 Q: I have a GUS, can I use TiMidity?
30
31 A: The DOS port doesn't have GUS support, and TiMidity won't be taking
32 advantage of the board's internal synthesizer under other operating
33 systems either. So it kind of defeats the purpose. But you can use it.
34
35 --------------------------------------------------------------------------
36 Q: I tried playing a MIDI file I got off the Net but all I got was a
37 dozen warnings saying "No instrument mapped to tone bank 0, program
38 xx - this instrument will not be heard". What's wrong?
39
40 A: The General MIDI standard specifies 128 melodic instruments and
41 some sixty percussion sounds. If you wish to play arbitrary General
42 MIDI files, you'll need to get more patch files.
43
44 There's a program called Midia for SGI's, which also plays MIDI
45 files and has a lot more bells and whistles than TiMidity. It uses
46 GUS-compatible patches, too -- so you can get the 8 MB set at
47 ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility.
48
49 There are also many excellent patches on the Ultrasound FTP sites.
50 I can recommend Dustin McCartney's collections gsdrum*.zip and
51 wow*.zip in the "[.../]sound/patches/files" directory. The huge
52 ProPats series (pp3-*.zip) contains good patches as well. General
53 MIDI files can also be found on these sites.
54
55 This site list is from the GUS FAQ:
56
57 > FTP Sites Archive Directories
58 > --------- -------------------
59 > Main N.American Site: archive.orst.edu pub/packages/gravis
60 > wuarchive.wustl.edu systems/ibmpc/ultrasound
61 > Main Asian Site: nctuccca.edu.tw PC/ultrasound
62 > Main European Site: src.doc.ic.ac.uk packages/ultrasound
63 > Main Australian Site: ftp.mpx.com.au /ultrasound/general
64 > /ultrasound/submit
65 > South African Site: ftp.sun.ac.za /pub/packages/ultrasound
66 > Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit
67 > Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound
68 >
69 > Mirrors: garbo.uwasa.fi mirror/ultrasound
70 > ftp.st.nepean.uws.edu.au pc/ultrasound
71 > ftp.luth.se pub/msdos/ultrasound
72
73 --------------------------------------------------------------------------
74 Q: Some files have awful clicks and pops.
75
76 A: Find out which patch is responsible for the clicking (try "timidity
77 -P<patch> <midi/test-decay|midi/test-panning>". Add "strip=tail" in
78 the config file after its name. If this doesn't fix it, mail me the
79 patch.
80
81 --------------------------------------------------------------------------
82 Q: I'm playing Fantasie Impromptu in the background. When I run Netscape,
83 the sound gets choppy and it takes ten minutes to load. What can I do?
84
85 A: Here are some things to try:
86
87 - Use a lower sampling rate.
88
89 - Use mono output. This can improve performance by 10-30%.
90 (Using 8-bit instead of 16-bit output makes no difference.)
91
92 - Use a smaller number of simultaneous voices.
93
94 - Make sure you compiled with FAST_DECAY enabled in options.h
95
96 - Recompile with an Intel-optimized gcc for a 5-15%
97 performance increase.
98
99 --------------------------------------------------------------------------
0 [This version of timidity has been stripped for simplicity in porting to SDL,
1 and then even further for SDL_sound]
2 ---------------------------------*-text-*---------------------------------
3
4 From http://www.cgs.fi/~tt/discontinued.html :
5
6 If you'd like to continue hacking on TiMidity, feel free. I'm
7 hereby extending the TiMidity license agreement: you can now
8 select the most convenient license for your needs from (1) the
9 GNU GPL, (2) the GNU LGPL, or (3) the Perl Artistic License.
10
11 --------------------------------------------------------------------------
12
13 This is the README file for TiMidity v0.2i
14
15 TiMidity is a MIDI to WAVE converter that uses Gravis
16 Ultrasound(*)-compatible patch files to generate digital audio data
17 from General MIDI files. The audio data can be played through any
18 sound device or stored on disk. On a fast machine, music can be
19 played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and
20 Win32, and porting to other systems with gcc should be easy.
21
22 TiMidity Features:
23
24 * 32 or more dynamically allocated fully independent voices
25 * Compatibility with GUS patch files
26 * Output to 16- or 8-bit PCM or uLaw audio device, file, or
27 stdout at any sampling rate
28 * Optional interactive mode with real-time status display
29 under ncurses and SLang terminal control libraries. Also
30 a user friendly motif interface since version 0.2h
31 * Support for transparent loading of compressed MIDI files and
32 patch files
33
34 * Support for the following MIDI events:
35 - Program change
36 - Key pressure
37 - Channel main volume
38 - Tempo
39 - Panning
40 - Damper pedal (Sustain)
41 - Pitch wheel
42 - Pitch wheel sensitivity
43 - Change drum set
44
45 * TiMidity requires sampled instruments (patches) to play MIDI files. You
46 should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same
47 directory where you unpacked the source code archive. You'll want more
48 patches later -- read the file "FAQ" for pointers.
49
50 * Timidity is no longer supported, but can be found by searching the web.
51
52
53 Tuukka Toivonen <toivonen@clinet.fi>
54
55 [(*) Any Registered Trademarks used anywhere in the documentation or
56 source code for TiMidity are acknowledged as belonging to their
57 respective owners.]
0 * I don't like the indentation style at all, but for the most part
1 I've left it alone.
2
3 * Much of the code looks ugly to me.
4
5 * The return value from SDL_RWread() is checked inconsistenly.
6
7 * Group the members of MidiSong into logical units, i.e. structs?
8
9 * The debug messages are probably a bit too noisy. I've removed one
10 particularly annoying one, but...
11
12 Some of them should be turned into error messages instead.
13
14 * Can the instrument handling be made more efficient? At the moment
15 different MidiSongs may separately load the same instrument.
16
17 Note that the MidiSong's audio format affects how the instrument is
18 loaded, so it's not as easy as just letting all MidiSongs share tone
19 and drum banks.
20
21 At the moment they do share the data that is simply read from the
22 config file, but that's just a quick hack to avoid having to read
23 the config file every time a MIDI song is loaded.
24
25 * Check if any of MidiStruct's members can safely be made into static
26 globals again.
27
28 * TiMidity++ adds a number of undocumented (?) extensions to the
29 configuration syntax. These are not implemented here. In particular,
30 the "map" keyword used by the "eawpats".
31
32 * The other decoders generally only read as much of the file as is
33 necessary. Could we do that in this decoder as well? (Currently it
34 seems to convert the entire file into MIDI events first.)
35
36 * Can it be optimized?
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 common.c
8 */
9
10 #include "SDL.h"
11
12 #include "options.h"
13 #include "common.h"
14
15 #if defined(__WIN32__) || defined(__OS2__)
16 #define CHAR_DIRSEP '\\'
17 #define is_dirsep(c) ((c) == '/' || (c) == '\\')
18 #define is_abspath(p) ((p)[0] == '/' || (p)[0] == '\\' || ((p)[0] && (p)[1] == ':'))
19 #else /* unix: */
20 #define CHAR_DIRSEP '/'
21 #define is_dirsep(c) ((c) == '/')
22 #define is_abspath(p) ((p)[0] == '/')
23 #endif
24
25 /* The paths in this list will be tried whenever we're reading a file */
26 typedef struct _PathList {
27 char *path;
28 struct _PathList *next;
29 } PathList;
30
31 static PathList *pathlist = NULL;
32
33 /* This is meant to find and open files for reading */
34 SDL_RWops *timi_openfile(const char *name)
35 {
36 SDL_RWops *rw;
37
38 if (!name || !(*name)) {
39 SNDDBG(("Attempted to open nameless file.\n"));
40 return NULL;
41 }
42
43 /* First try the given name */
44
45 SNDDBG(("Trying to open %s\n", name));
46 if ((rw = SDL_RWFromFile(name, "rb")) != NULL)
47 return rw;
48
49 if (!is_abspath(name))
50 {
51 char current_filename[1024];
52 PathList *plp = pathlist;
53 char *p;
54 size_t l;
55
56 while (plp) { /* Try along the path then */
57 *current_filename = 0;
58 p = current_filename;
59 l = SDL_strlen(plp->path);
60 if(l >= sizeof(current_filename) - 3) l = 0;
61 if(l) {
62 SDL_memcpy(current_filename, plp->path, l);
63 p += l;
64 if(!is_dirsep(p[-1])) {
65 *p++ = CHAR_DIRSEP;
66 l++;
67 }
68 }
69 SDL_strlcpy(p, name, sizeof(current_filename) - l);
70 SNDDBG(("Trying to open %s\n", current_filename));
71 if ((rw = SDL_RWFromFile(current_filename, "rb")))
72 return rw;
73 plp = plp->next;
74 }
75 }
76
77 /* Nothing could be opened. */
78 SNDDBG(("Could not open %s\n", name));
79 return NULL;
80 }
81
82 /* This adds a directory to the path list */
83 int timi_add_pathlist(const char *s, size_t l)
84 {
85 PathList *plp = SDL_malloc(sizeof(PathList));
86 if (plp == NULL) return -2;
87 plp->path = SDL_malloc(l + 1);
88 if (plp->path == NULL) {
89 SDL_free (plp);
90 return -2;
91 }
92 SDL_memcpy(plp->path, s, l);
93 plp->path[l] = 0;
94 plp->next = pathlist;
95 pathlist = plp;
96 return 0;
97 }
98
99 void timi_free_pathlist(void)
100 {
101 PathList *plp = pathlist;
102 PathList *next;
103
104 while (plp) {
105 next = plp->next;
106 SDL_free(plp->path);
107 SDL_free(plp);
108 plp = next;
109 }
110 pathlist = NULL;
111 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 common.h
8 */
9
10 #ifndef TIMIDITY_COMMON_H
11 #define TIMIDITY_COMMON_H
12
13 extern SDL_RWops *timi_openfile(const char *name);
14
15 /* pathlist funcs only to be used during Timidity_Init/Timidity_Exit */
16 extern int timi_add_pathlist(const char *s, size_t len);
17 extern void timi_free_pathlist(void);
18
19 /* hide private symbols by prefixing with "_timi_" */
20 #undef TIMI_NAMESPACE
21 #define TIMI_NAMESPACE(x) _timi_ ## x
22
23 /* debug output */
24 #ifdef DEBUG_CHATTER
25 #define SNDDBG(X) SDL_Log X
26 #else
27 #define SNDDBG(X)
28 #endif
29
30 #endif /* TIMIDITY_COMMON_H */
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 instrum.c
9
10 Code to load and unload GUS-compatible instrument patches.
11
12 */
13
14 #include "SDL.h"
15
16 #include "timidity.h"
17 #include "options.h"
18 #include "common.h"
19 #include "instrum.h"
20 #include "resample.h"
21 #include "tables.h"
22
23 static void free_instrument(Instrument *ip)
24 {
25 Sample *sp;
26 int i;
27 if (!ip) return;
28 if (ip->sample) {
29 for (i=0; i<ip->samples; i++) {
30 sp=&(ip->sample[i]);
31 SDL_free(sp->data);
32 }
33 SDL_free(ip->sample);
34 }
35 SDL_free(ip);
36 }
37
38 static void free_bank(MidiSong *song, int dr, int b)
39 {
40 int i;
41 ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]);
42 for (i=0; i<MAXBANK; i++)
43 if (bank->instrument[i])
44 {
45 if (bank->instrument[i] != MAGIC_LOAD_INSTRUMENT)
46 free_instrument(bank->instrument[i]);
47 bank->instrument[i] = NULL;
48 }
49 }
50
51 static Sint32 convert_envelope_rate(MidiSong *song, Uint8 rate)
52 {
53 Sint32 r;
54
55 r = 3 - ((rate >> 6) & 0x3);
56 r *= 3;
57 r = (Sint32) (rate & 0x3f) << r; /* 6.9 fixed point */
58
59 /* 15.15 fixed point. */
60 r = ((r * 44100) / song->rate) * song->control_ratio;
61
62 #ifdef FAST_DECAY
63 return r << 10;
64 #else
65 return r << 9;
66 #endif
67 }
68
69 static Sint32 convert_envelope_offset(Uint8 offset)
70 {
71 /* This is not too good... Can anyone tell me what these values mean?
72 Are they GUS-style "exponential" volumes? And what does that mean? */
73
74 /* 15.15 fixed point */
75 return offset << (7+15);
76 }
77
78 static Sint32 convert_tremolo_sweep(MidiSong *song, Uint8 sweep)
79 {
80 if (!sweep)
81 return 0;
82
83 return
84 ((song->control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) /
85 (song->rate * sweep);
86 }
87
88 static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep,
89 Sint32 vib_control_ratio)
90 {
91 if (!sweep)
92 return 0;
93
94 return
95 (Sint32) (TIM_FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT)
96 / (double)(song->rate * sweep));
97
98 /* this was overflowing with seashore.pat
99
100 ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) /
101 (song->rate * sweep); */
102 }
103
104 static Sint32 convert_tremolo_rate(MidiSong *song, Uint8 rate)
105 {
106 return
107 ((SINE_CYCLE_LENGTH * song->control_ratio * rate) << RATE_SHIFT) /
108 (TREMOLO_RATE_TUNING * song->rate);
109 }
110
111 static Sint32 convert_vibrato_rate(MidiSong *song, Uint8 rate)
112 {
113 /* Return a suitable vibrato_control_ratio value */
114 return
115 (VIBRATO_RATE_TUNING * song->rate) /
116 (rate * 2 * VIBRATO_SAMPLE_INCREMENTS);
117 }
118
119 static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le)
120 {
121 Sint16 s, *ep=sp+le;
122 sp+=ls;
123 le-=ls;
124 le/=2;
125 while (le--)
126 {
127 s=*sp;
128 *sp++=*ep;
129 *ep--=s;
130 }
131 }
132
133 /*
134 If panning or note_to_use != -1, it will be used for all samples,
135 instead of the sample-specific values in the instrument file.
136
137 For note_to_use, any value <0 or >127 will be forced to 0.
138
139 For other parameters, 1 means yes, 0 means no, other values are
140 undefined.
141
142 TODO: do reverse loops right */
143 static void load_instrument(MidiSong *song, const char *name,
144 Instrument **out,
145 int percussion, int panning,
146 int amp, int note_to_use,
147 int strip_loop, int strip_envelope,
148 int strip_tail)
149 {
150 Instrument *ip;
151 Sample *sp;
152 SDL_RWops *rw;
153 char tmp[1024];
154 int i,j;
155 static char *patch_ext[] = PATCH_EXT_LIST;
156
157 (void)percussion; /* unused */
158 *out = NULL;
159 if (!name) return;
160
161 /* Open patch file */
162 i = -1;
163 if ((rw=timi_openfile(name)) == NULL)
164 {
165 /* Try with various extensions */
166 for (i=0; patch_ext[i]; i++)
167 {
168 SDL_snprintf(tmp, sizeof(tmp), "%s%s", name, patch_ext[i]);
169 if ((rw=timi_openfile(tmp)) != NULL)
170 break;
171 }
172 }
173
174 if (rw == NULL)
175 {
176 SNDDBG(("Instrument `%s' can't be found.\n", name));
177 return;
178 }
179
180 SNDDBG(("Loading instrument %s\n", (i < 0)? name : tmp));
181
182 /* Read some headers and do cursory sanity checks. There are loads
183 of magic offsets. This could be rewritten... */
184
185 if ((239 != SDL_RWread(rw, tmp, 1, 239)) ||
186 (SDL_memcmp(tmp, "GF1PATCH110\0ID#000002", 22) &&
187 SDL_memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the
188 differences are */
189 {
190 SNDDBG(("%s: not an instrument\n", name));
191 goto badpat;
192 }
193
194 if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers,
195 0 means 1 */
196 {
197 SNDDBG(("Can't handle patches with %d instruments\n", tmp[82]));
198 goto badpat;
199 }
200
201 if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */
202 {
203 SNDDBG(("Can't handle instruments with %d layers\n", tmp[151]));
204 goto badpat;
205 }
206
207 *out=SDL_malloc(sizeof(Instrument));
208 ip = *out;
209 if (!ip) goto nomem;
210
211 ip->samples = tmp[198];
212 ip->sample = SDL_malloc(sizeof(Sample) * ip->samples);
213 if (!ip->sample) goto nomem;
214
215 for (i=0; i<ip->samples; i++)
216 {
217 Uint8 fractions;
218 Sint32 tmplong;
219 Uint16 tmpshort;
220 Uint8 tmpchar;
221
222 #define READ_CHAR(thing) \
223 if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto badread; \
224 thing = tmpchar;
225 #define READ_SHORT(thing) \
226 if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto badread; \
227 thing = SDL_SwapLE16(tmpshort);
228 #define READ_LONG(thing) \
229 if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto badread; \
230 thing = (Sint32)SDL_SwapLE32((Uint32)tmplong);
231
232 SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */
233
234 if (1 != SDL_RWread(rw, &fractions, 1, 1))
235 goto badread;
236
237 sp=&(ip->sample[i]);
238
239 READ_LONG(sp->data_length);
240 READ_LONG(sp->loop_start);
241 READ_LONG(sp->loop_end);
242 READ_SHORT(sp->sample_rate);
243 READ_LONG(sp->low_freq);
244 READ_LONG(sp->high_freq);
245 READ_LONG(sp->root_freq);
246 SDL_RWseek(rw, 2, RW_SEEK_CUR); /* Why have a "root frequency" and then
247 * "tuning"?? */
248
249 READ_CHAR(tmp[0]);
250
251 if (panning==-1)
252 sp->panning = (tmp[0] * 8 + 4) & 0x7f;
253 else
254 sp->panning=(Uint8)(panning & 0x7F);
255
256 /* envelope, tremolo, and vibrato */
257 if (18 != SDL_RWread(rw, tmp, 1, 18))
258 goto badread;
259
260 if (!tmp[13] || !tmp[14])
261 {
262 sp->tremolo_sweep_increment=
263 sp->tremolo_phase_increment=sp->tremolo_depth=0;
264 SNDDBG((" * no tremolo\n"));
265 }
266 else
267 {
268 sp->tremolo_sweep_increment=convert_tremolo_sweep(song, tmp[12]);
269 sp->tremolo_phase_increment=convert_tremolo_rate(song, tmp[13]);
270 sp->tremolo_depth=tmp[14];
271 SNDDBG((" * tremolo: sweep %d, phase %d, depth %d\n",
272 sp->tremolo_sweep_increment, sp->tremolo_phase_increment,
273 sp->tremolo_depth));
274 }
275
276 if (!tmp[16] || !tmp[17])
277 {
278 sp->vibrato_sweep_increment=
279 sp->vibrato_control_ratio=sp->vibrato_depth=0;
280 SNDDBG((" * no vibrato\n"));
281 }
282 else
283 {
284 sp->vibrato_control_ratio=convert_vibrato_rate(song, tmp[16]);
285 sp->vibrato_sweep_increment=
286 convert_vibrato_sweep(song, tmp[15], sp->vibrato_control_ratio);
287 sp->vibrato_depth=tmp[17];
288 SNDDBG((" * vibrato: sweep %d, ctl %d, depth %d\n",
289 sp->vibrato_sweep_increment, sp->vibrato_control_ratio,
290 sp->vibrato_depth));
291 }
292
293 READ_CHAR(sp->modes);
294
295 SDL_RWseek(rw, 40, RW_SEEK_CUR); /* skip the useless scale frequency, scale
296 factor (what's it mean?), and reserved
297 space */
298
299 /* Mark this as a fixed-pitch instrument if such a deed is desired. */
300 if (note_to_use!=-1)
301 sp->note_to_use=(Uint8)(note_to_use);
302 else
303 sp->note_to_use=0;
304
305 /* seashore.pat in the Midia patch set has no Sustain. I don't
306 understand why, and fixing it by adding the Sustain flag to
307 all looped patches probably breaks something else. We do it
308 anyway. */
309 if (sp->modes & MODES_LOOPING)
310 sp->modes |= MODES_SUSTAIN;
311
312 /* Strip any loops and envelopes we're permitted to */
313 if ((strip_loop==1) &&
314 (sp->modes & (MODES_SUSTAIN | MODES_LOOPING |
315 MODES_PINGPONG | MODES_REVERSE)))
316 {
317 SNDDBG((" - Removing loop and/or sustain\n"));
318 sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING |
319 MODES_PINGPONG | MODES_REVERSE);
320 }
321
322 if (strip_envelope==1)
323 {
324 if (sp->modes & MODES_ENVELOPE) {
325 SNDDBG((" - Removing envelope\n"));
326 }
327 sp->modes &= ~MODES_ENVELOPE;
328 }
329 else if (strip_envelope != 0)
330 {
331 /* Have to make a guess. */
332 if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE)))
333 {
334 /* No loop? Then what's there to sustain? No envelope needed
335 either... */
336 sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE);
337 SNDDBG((" - No loop, removing sustain and envelope\n"));
338 }
339 else if (!SDL_memcmp(tmp, "??????", 6) || tmp[11] >= 100)
340 {
341 /* Envelope rates all maxed out? Envelope end at a high "offset"?
342 That's a weird envelope. Take it out. */
343 sp->modes &= ~MODES_ENVELOPE;
344 SNDDBG((" - Weirdness, removing envelope\n"));
345 }
346 else if (!(sp->modes & MODES_SUSTAIN))
347 {
348 /* No sustain? Then no envelope. I don't know if this is
349 justified, but patches without sustain usually don't need the
350 envelope either... at least the Gravis ones. They're mostly
351 drums. I think. */
352 sp->modes &= ~MODES_ENVELOPE;
353 SNDDBG((" - No sustain, removing envelope\n"));
354 }
355 }
356
357 for (j=0; j<6; j++)
358 {
359 sp->envelope_rate[j]=
360 convert_envelope_rate(song, tmp[j]);
361 sp->envelope_offset[j]=
362 convert_envelope_offset(tmp[6+j]);
363 }
364
365 /* Then read the sample data */
366 sp->data = (sample_t *) SDL_malloc(sp->data_length+4);
367 if (!sp->data) goto nomem;
368
369 if (1 != SDL_RWread(rw, sp->data, sp->data_length, 1))
370 goto badread;
371
372 if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */
373 {
374 Sint32 k=sp->data_length;
375 Uint8 *cp=(Uint8 *)(sp->data);
376 Uint16 *tmp16,*new16;
377 sp->data_length *= 2;
378 sp->loop_start *= 2;
379 sp->loop_end *= 2;
380 tmp16 = new16 = (Uint16 *) SDL_malloc(sp->data_length+4);
381 if (!new16) goto nomem;
382 while (k--)
383 *tmp16++ = (Uint16)(*cp++) << 8;
384 SDL_free(sp->data);
385 sp->data = (sample_t *)new16;
386 }
387 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
388 else
389 /* convert to machine byte order */
390 {
391 Sint32 k=sp->data_length/2;
392 Sint16 *tmp16=(Sint16 *)sp->data,s;
393 while (k--)
394 {
395 s=SDL_SwapLE16(*tmp16);
396 *tmp16++=s;
397 }
398 }
399 #endif
400
401 if (sp->modes & MODES_UNSIGNED) /* convert to signed data */
402 {
403 Sint32 k=sp->data_length/2;
404 Sint16 *tmp16=(Sint16 *)sp->data;
405 while (k--)
406 *tmp16++ ^= 0x8000;
407 }
408
409 /* Reverse reverse loops and pass them off as normal loops */
410 if (sp->modes & MODES_REVERSE)
411 {
412 Sint32 t;
413 /* The GUS apparently plays reverse loops by reversing the
414 whole sample. We do the same because the GUS does not SUCK. */
415
416 SNDDBG(("Reverse loop in %s\n", name));
417 reverse_data((Sint16 *)sp->data, 0, sp->data_length/2);
418
419 t=sp->loop_start;
420 sp->loop_start=sp->data_length - sp->loop_end;
421 sp->loop_end=sp->data_length - t;
422
423 sp->modes &= ~MODES_REVERSE;
424 sp->modes |= MODES_LOOPING; /* just in case */
425 }
426
427 #ifdef ADJUST_SAMPLE_VOLUMES
428 if (amp!=-1)
429 sp->volume=(float)((amp) / 100.0);
430 else
431 {
432 /* Try to determine a volume scaling factor for the sample.
433 This is a very crude adjustment, but things sound more
434 balanced with it. Still, this should be a runtime option. */
435 Sint32 k=sp->data_length/2;
436 Sint16 maxamp=0,a;
437 Sint16 *tmp16=(Sint16 *)sp->data;
438 while (k--)
439 {
440 a=*tmp16++;
441 if (a<0) a=-a;
442 if (a>maxamp)
443 maxamp=a;
444 }
445 sp->volume=(float)(32768.0 / maxamp);
446 SNDDBG((" * volume comp: %f\n", sp->volume));
447 }
448 #else
449 if (amp!=-1)
450 sp->volume=(double)(amp) / 100.0;
451 else
452 sp->volume=1.0;
453 #endif
454
455 sp->data_length /= 2; /* These are in bytes. Convert into samples. */
456 sp->loop_start /= 2;
457 sp->loop_end /= 2;
458
459 /* initialize the added extra sample space (see the +4 bytes) */
460 sp->data[sp->data_length] = sp->data[sp->data_length+1] = 0;
461
462 /* Then fractional samples */
463 sp->data_length <<= FRACTION_BITS;
464 sp->loop_start <<= FRACTION_BITS;
465 sp->loop_end <<= FRACTION_BITS;
466
467 /* Adjust for fractional loop points. This is a guess. Does anyone
468 know what "fractions" really stands for? */
469 sp->loop_start |=
470 (fractions & 0x0F) << (FRACTION_BITS-4);
471 sp->loop_end |=
472 ((fractions>>4) & 0x0F) << (FRACTION_BITS-4);
473
474 /* If this instrument will always be played on the same note,
475 and it's not looped, we can resample it now. */
476 if (sp->note_to_use && !(sp->modes & MODES_LOOPING)) {
477 pre_resample(song, sp);
478 if (song->oom) goto fail;
479 }
480
481 if (strip_tail==1)
482 {
483 /* Let's not really, just say we did. */
484 SNDDBG((" - Stripping tail\n"));
485 sp->data_length = sp->loop_end;
486 }
487 }
488
489 SDL_RWclose(rw);
490 return;
491
492 nomem:
493 song->oom=1;
494 goto fail;
495 badread:
496 SNDDBG(("Error reading sample %d\n", i));
497 fail:
498 free_instrument (ip);
499 badpat:
500 SDL_RWclose(rw);
501 *out = NULL;
502 }
503
504 static int fill_bank(MidiSong *song, int dr, int b)
505 {
506 int i, errors=0;
507 ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]);
508 if (!bank)
509 {
510 SNDDBG(("Huh. Tried to load instruments in non-existent %s %d\n",
511 (dr) ? "drumset" : "tone bank", b));
512 return 0;
513 }
514 for (i=0; i<MAXBANK; i++)
515 {
516 if (bank->instrument[i]==MAGIC_LOAD_INSTRUMENT)
517 {
518 if (!(bank->tone[i].name))
519 {
520 SNDDBG(("No instrument mapped to %s %d, program %d%s\n",
521 (dr)? "drum set" : "tone bank", b, i,
522 (b!=0) ? "" : " - this instrument will not be heard"));
523 if (b!=0)
524 {
525 /* Mark the corresponding instrument in the default
526 bank / drumset for loading (if it isn't already) */
527 if (!dr)
528 {
529 if (!(song->tonebank[0]->instrument[i]))
530 song->tonebank[0]->instrument[i] =
531 MAGIC_LOAD_INSTRUMENT;
532 }
533 else
534 {
535 if (!(song->drumset[0]->instrument[i]))
536 song->drumset[0]->instrument[i] =
537 MAGIC_LOAD_INSTRUMENT;
538 }
539 }
540 bank->instrument[i] = NULL;
541 errors++;
542 }
543 else
544 {
545 load_instrument(song,
546 bank->tone[i].name,
547 &bank->instrument[i],
548 (dr) ? 1 : 0,
549 bank->tone[i].pan,
550 bank->tone[i].amp,
551 (bank->tone[i].note!=-1) ?
552 bank->tone[i].note :
553 ((dr) ? i : -1),
554 (bank->tone[i].strip_loop!=-1) ?
555 bank->tone[i].strip_loop :
556 ((dr) ? 1 : -1),
557 (bank->tone[i].strip_envelope != -1) ?
558 bank->tone[i].strip_envelope :
559 ((dr) ? 1 : -1),
560 bank->tone[i].strip_tail);
561 if (!bank->instrument[i]) {
562 SNDDBG(("Couldn't load instrument %s (%s %d, program %d)\n",
563 bank->tone[i].name,
564 (dr)? "drum set" : "tone bank", b, i));
565 errors++;
566 }
567 }
568 }
569 }
570 return errors;
571 }
572
573 int load_missing_instruments(MidiSong *song)
574 {
575 int i=MAXBANK,errors=0;
576 while (i--)
577 {
578 if (song->tonebank[i])
579 errors+=fill_bank(song,0,i);
580 if (song->drumset[i])
581 errors+=fill_bank(song,1,i);
582 }
583 return errors;
584 }
585
586 void free_instruments(MidiSong *song)
587 {
588 int i=MAXBANK;
589 while(i--)
590 {
591 if (song->tonebank[i])
592 free_bank(song, 0, i);
593 if (song->drumset[i])
594 free_bank(song, 1, i);
595 }
596 }
597
598 int set_default_instrument(MidiSong *song, const char *name)
599 {
600 load_instrument(song, name, &song->default_instrument, 0, -1, -1, -1, 0, 0, 0);
601 if (!song->default_instrument)
602 return -1;
603 song->default_program = SPECIAL_PROGRAM;
604 return 0;
605 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 instrum.h
8 */
9
10 #ifndef TIMIDITY_INSTRUM_H
11 #define TIMIDITY_INSTRUM_H
12
13 /* Bits in modes: */
14 #define MODES_16BIT (1<<0)
15 #define MODES_UNSIGNED (1<<1)
16 #define MODES_LOOPING (1<<2)
17 #define MODES_PINGPONG (1<<3)
18 #define MODES_REVERSE (1<<4)
19 #define MODES_SUSTAIN (1<<5)
20 #define MODES_ENVELOPE (1<<6)
21
22 /* A hack to delay instrument loading until after reading the
23 entire MIDI file. */
24 #define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1))
25
26 #define SPECIAL_PROGRAM -1
27
28 #define load_missing_instruments TIMI_NAMESPACE(load_missing_instruments)
29 #define free_instruments TIMI_NAMESPACE(free_instruments)
30 #define set_default_instrument TIMI_NAMESPACE(set_default_instrument)
31
32 extern int load_missing_instruments(MidiSong *song);
33 extern void free_instruments(MidiSong *song);
34 extern int set_default_instrument(MidiSong *song, const char *name);
35
36 #endif /* TIMIDITY_INSTRUM_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 mix.c */
8
9 #include "SDL.h"
10
11 #include "timidity.h"
12 #include "options.h"
13 #include "common.h"
14 #include "instrum.h"
15 #include "playmidi.h"
16 #include "output.h"
17 #include "tables.h"
18 #include "resample.h"
19 #include "mix.h"
20
21 /* Returns 1 if envelope runs out */
22 int recompute_envelope(MidiSong *song, int v)
23 {
24 int stage;
25
26 stage = song->voice[v].envelope_stage;
27
28 if (stage>5)
29 {
30 /* Envelope ran out. */
31 song->voice[v].status = VOICE_FREE;
32 return 1;
33 }
34
35 if (song->voice[v].sample->modes & MODES_ENVELOPE)
36 {
37 if (song->voice[v].status==VOICE_ON || song->voice[v].status==VOICE_SUSTAINED)
38 {
39 if (stage>2)
40 {
41 /* Freeze envelope until note turns off. Trumpets want this. */
42 song->voice[v].envelope_increment=0;
43 return 0;
44 }
45 }
46 }
47 song->voice[v].envelope_stage=stage+1;
48
49 if (song->voice[v].envelope_volume==song->voice[v].sample->envelope_offset[stage] ||
50 (stage > 2 && song->voice[v].envelope_volume <
51 song->voice[v].sample->envelope_offset[stage]))
52 return recompute_envelope(song, v);
53 song->voice[v].envelope_target = song->voice[v].sample->envelope_offset[stage];
54 song->voice[v].envelope_increment = song->voice[v].sample->envelope_rate[stage];
55 if (song->voice[v].envelope_target < song->voice[v].envelope_volume)
56 song->voice[v].envelope_increment = -song->voice[v].envelope_increment;
57 return 0;
58 }
59
60 void apply_envelope_to_amp(MidiSong *song, int v)
61 {
62 float lamp = song->voice[v].left_amp, ramp;
63 Sint32 la,ra;
64 if (song->voice[v].panned == PANNED_MYSTERY)
65 {
66 ramp = song->voice[v].right_amp;
67 if (song->voice[v].tremolo_phase_increment)
68 {
69 lamp *= song->voice[v].tremolo_volume;
70 ramp *= song->voice[v].tremolo_volume;
71 }
72 if (song->voice[v].sample->modes & MODES_ENVELOPE)
73 {
74 lamp *= (float)vol_table[song->voice[v].envelope_volume>>23];
75 ramp *= (float)vol_table[song->voice[v].envelope_volume>>23];
76 }
77
78 la = (Sint32)TIM_FSCALE(lamp,AMP_BITS);
79
80 if (la>MAX_AMP_VALUE)
81 la=MAX_AMP_VALUE;
82
83 ra = (Sint32)TIM_FSCALE(ramp,AMP_BITS);
84 if (ra>MAX_AMP_VALUE)
85 ra=MAX_AMP_VALUE;
86
87 song->voice[v].left_mix = la;
88 song->voice[v].right_mix = ra;
89 }
90 else
91 {
92 if (song->voice[v].tremolo_phase_increment)
93 lamp *= song->voice[v].tremolo_volume;
94 if (song->voice[v].sample->modes & MODES_ENVELOPE)
95 lamp *= (float)vol_table[song->voice[v].envelope_volume>>23];
96
97 la = (Sint32)TIM_FSCALE(lamp,AMP_BITS);
98
99 if (la>MAX_AMP_VALUE)
100 la=MAX_AMP_VALUE;
101
102 song->voice[v].left_mix = la;
103 }
104 }
105
106 static int update_envelope(MidiSong *song, int v)
107 {
108 song->voice[v].envelope_volume += song->voice[v].envelope_increment;
109 /* Why is there no ^^ operator?? */
110 if (((song->voice[v].envelope_increment < 0) &&
111 (song->voice[v].envelope_volume <= song->voice[v].envelope_target)) ||
112 ((song->voice[v].envelope_increment > 0) &&
113 (song->voice[v].envelope_volume >= song->voice[v].envelope_target)))
114 {
115 song->voice[v].envelope_volume = song->voice[v].envelope_target;
116 if (recompute_envelope(song, v))
117 return 1;
118 }
119 return 0;
120 }
121
122 static void update_tremolo(MidiSong *song, int v)
123 {
124 Sint32 depth = song->voice[v].sample->tremolo_depth << 7;
125
126 if (song->voice[v].tremolo_sweep)
127 {
128 /* Update sweep position */
129
130 song->voice[v].tremolo_sweep_position += song->voice[v].tremolo_sweep;
131 if (song->voice[v].tremolo_sweep_position >= (1 << SWEEP_SHIFT))
132 song->voice[v].tremolo_sweep=0; /* Swept to max amplitude */
133 else
134 {
135 /* Need to adjust depth */
136 depth *= song->voice[v].tremolo_sweep_position;
137 depth >>= SWEEP_SHIFT;
138 }
139 }
140
141 song->voice[v].tremolo_phase += song->voice[v].tremolo_phase_increment;
142
143 /* if (song->voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<<RATE_SHIFT))
144 song->voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<<RATE_SHIFT; */
145
146 song->voice[v].tremolo_volume = (float)
147 (1.0 - TIM_FSCALENEG((timi_sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0)
148 * depth * TREMOLO_AMPLITUDE_TUNING,
149 17));
150
151 /* I'm not sure about the +1.0 there -- it makes tremoloed voices'
152 volumes on average the lower the higher the tremolo amplitude. */
153 }
154
155 /* Returns 1 if the note died */
156 static int update_signal(MidiSong *song, int v)
157 {
158 if (song->voice[v].envelope_increment && update_envelope(song, v))
159 return 1;
160
161 if (song->voice[v].tremolo_phase_increment)
162 update_tremolo(song, v);
163
164 apply_envelope_to_amp(song, v);
165 return 0;
166 }
167
168 #define MIXATION(a) *lp++ += (a)*s;
169
170 static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
171 int count)
172 {
173 Voice *vp = song->voice + v;
174 final_volume_t
175 left=vp->left_mix,
176 right=vp->right_mix;
177 int cc;
178 sample_t s;
179
180 if (!(cc = vp->control_counter))
181 {
182 cc = song->control_ratio;
183 if (update_signal(song, v))
184 return; /* Envelope ran out */
185 left = vp->left_mix;
186 right = vp->right_mix;
187 }
188
189 while (count)
190 if (cc < count)
191 {
192 count -= cc;
193 while (cc--)
194 {
195 s = *sp++;
196 MIXATION(left);
197 MIXATION(right);
198 }
199 cc = song->control_ratio;
200 if (update_signal(song, v))
201 return; /* Envelope ran out */
202 left = vp->left_mix;
203 right = vp->right_mix;
204 }
205 else
206 {
207 vp->control_counter = cc - count;
208 while (count--)
209 {
210 s = *sp++;
211 MIXATION(left);
212 MIXATION(right);
213 }
214 return;
215 }
216 }
217
218 static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
219 int count)
220 {
221 Voice *vp = song->voice + v;
222 final_volume_t
223 left=vp->left_mix;
224 int cc;
225 sample_t s;
226
227 if (!(cc = vp->control_counter))
228 {
229 cc = song->control_ratio;
230 if (update_signal(song, v))
231 return; /* Envelope ran out */
232 left = vp->left_mix;
233 }
234
235 while (count)
236 if (cc < count)
237 {
238 count -= cc;
239 while (cc--)
240 {
241 s = *sp++;
242 MIXATION(left);
243 MIXATION(left);
244 }
245 cc = song->control_ratio;
246 if (update_signal(song, v))
247 return; /* Envelope ran out */
248 left = vp->left_mix;
249 }
250 else
251 {
252 vp->control_counter = cc - count;
253 while (count--)
254 {
255 s = *sp++;
256 MIXATION(left);
257 MIXATION(left);
258 }
259 return;
260 }
261 }
262
263 static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
264 int count)
265 {
266 Voice *vp = song->voice + v;
267 final_volume_t
268 left=vp->left_mix;
269 int cc;
270 sample_t s;
271
272 if (!(cc = vp->control_counter))
273 {
274 cc = song->control_ratio;
275 if (update_signal(song, v))
276 return; /* Envelope ran out */
277 left = vp->left_mix;
278 }
279
280 while (count)
281 if (cc < count)
282 {
283 count -= cc;
284 while (cc--)
285 {
286 s = *sp++;
287 MIXATION(left);
288 lp++;
289 }
290 cc = song->control_ratio;
291 if (update_signal(song, v))
292 return; /* Envelope ran out */
293 left = vp->left_mix;
294 }
295 else
296 {
297 vp->control_counter = cc - count;
298 while (count--)
299 {
300 s = *sp++;
301 MIXATION(left);
302 lp++;
303 }
304 return;
305 }
306 }
307
308 static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
309 int count)
310 {
311 Voice *vp = song->voice + v;
312 final_volume_t
313 left=vp->left_mix;
314 int cc;
315 sample_t s;
316
317 if (!(cc = vp->control_counter))
318 {
319 cc = song->control_ratio;
320 if (update_signal(song, v))
321 return; /* Envelope ran out */
322 left = vp->left_mix;
323 }
324
325 while (count)
326 if (cc < count)
327 {
328 count -= cc;
329 while (cc--)
330 {
331 s = *sp++;
332 MIXATION(left);
333 }
334 cc = song->control_ratio;
335 if (update_signal(song, v))
336 return; /* Envelope ran out */
337 left = vp->left_mix;
338 }
339 else
340 {
341 vp->control_counter = cc - count;
342 while (count--)
343 {
344 s = *sp++;
345 MIXATION(left);
346 }
347 return;
348 }
349 }
350
351 static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
352 {
353 final_volume_t
354 left = song->voice[v].left_mix,
355 right = song->voice[v].right_mix;
356 sample_t s;
357
358 while (count--)
359 {
360 s = *sp++;
361 MIXATION(left);
362 MIXATION(right);
363 }
364 }
365
366 static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
367 {
368 final_volume_t
369 left = song->voice[v].left_mix;
370 sample_t s;
371
372 while (count--)
373 {
374 s = *sp++;
375 MIXATION(left);
376 MIXATION(left);
377 }
378 }
379
380 static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
381 {
382 final_volume_t
383 left = song->voice[v].left_mix;
384 sample_t s;
385
386 while (count--)
387 {
388 s = *sp++;
389 MIXATION(left);
390 lp++;
391 }
392 }
393
394 static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
395 {
396 final_volume_t
397 left = song->voice[v].left_mix;
398 sample_t s;
399
400 while (count--)
401 {
402 s = *sp++;
403 MIXATION(left);
404 }
405 }
406
407 /* Ramp a note out in c samples */
408 static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c)
409 {
410 /* should be final_volume_t, but Uint8 gives trouble. */
411 Sint32 left, right, li, ri;
412
413 sample_t s=0; /* silly warning about uninitialized s */
414
415 left=song->voice[v].left_mix;
416 li=-(left/c);
417 if (!li) li=-1;
418
419 /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */
420
421 if (!(song->encoding & PE_MONO))
422 {
423 if (song->voice[v].panned==PANNED_MYSTERY)
424 {
425 right=song->voice[v].right_mix;
426 ri=-(right/c);
427 while (c--)
428 {
429 left += li;
430 if (left<0)
431 left=0;
432 right += ri;
433 if (right<0)
434 right=0;
435 s=*sp++;
436 MIXATION(left);
437 MIXATION(right);
438 }
439 }
440 else if (song->voice[v].panned==PANNED_CENTER)
441 {
442 while (c--)
443 {
444 left += li;
445 if (left<0)
446 return;
447 s=*sp++;
448 MIXATION(left);
449 MIXATION(left);
450 }
451 }
452 else if (song->voice[v].panned==PANNED_LEFT)
453 {
454 while (c--)
455 {
456 left += li;
457 if (left<0)
458 return;
459 s=*sp++;
460 MIXATION(left);
461 lp++;
462 }
463 }
464 else if (song->voice[v].panned==PANNED_RIGHT)
465 {
466 while (c--)
467 {
468 left += li;
469 if (left<0)
470 return;
471 s=*sp++;
472 lp++;
473 MIXATION(left);
474 }
475 }
476 }
477 else
478 {
479 /* Mono output. */
480 while (c--)
481 {
482 left += li;
483 if (left<0)
484 return;
485 s=*sp++;
486 MIXATION(left);
487 }
488 }
489 }
490
491
492 /**************** interface function ******************/
493
494 void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c)
495 {
496 Voice *vp = song->voice + v;
497 sample_t *sp;
498 if (vp->status==VOICE_DIE)
499 {
500 if (c>=MAX_DIE_TIME)
501 c=MAX_DIE_TIME;
502 sp=resample_voice(song, v, &c);
503 if(c > 0)
504 ramp_out(song, sp, buf, v, c);
505 vp->status=VOICE_FREE;
506 }
507 else
508 {
509 sp=resample_voice(song, v, &c);
510 if (song->encoding & PE_MONO)
511 {
512 /* Mono output. */
513 if (vp->envelope_increment || vp->tremolo_phase_increment)
514 mix_mono_signal(song, sp, buf, v, c);
515 else
516 mix_mono(song, sp, buf, v, c);
517 }
518 else
519 {
520 if (vp->panned == PANNED_MYSTERY)
521 {
522 if (vp->envelope_increment || vp->tremolo_phase_increment)
523 mix_mystery_signal(song, sp, buf, v, c);
524 else
525 mix_mystery(song, sp, buf, v, c);
526 }
527 else if (vp->panned == PANNED_CENTER)
528 {
529 if (vp->envelope_increment || vp->tremolo_phase_increment)
530 mix_center_signal(song, sp, buf, v, c);
531 else
532 mix_center(song, sp, buf, v, c);
533 }
534 else
535 {
536 /* It's either full left or full right. In either case,
537 every other sample is 0. Just get the offset right: */
538 if (vp->panned == PANNED_RIGHT) buf++;
539
540 if (vp->envelope_increment || vp->tremolo_phase_increment)
541 mix_single_signal(song, sp, buf, v, c);
542 else
543 mix_single(song, sp, buf, v, c);
544 }
545 }
546 }
547 }
548
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 mix.h
8 */
9
10 #ifndef TIMIDITY_MIX_H
11 #define TIMIDITY_MIX_H
12
13 #define mix_voice TIMI_NAMESPACE(mix_voice)
14 #define recompute_envelope TIMI_NAMESPACE(recompute_envelope)
15 #define apply_envelope_to_amp TIMI_NAMESPACE(apply_envelope_to_amp)
16
17 extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c);
18 extern int recompute_envelope(MidiSong *song, int v);
19 extern void apply_envelope_to_amp(MidiSong *song, int v);
20
21 #endif /* TIMIDITY_MIX_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6 */
7
8 #ifndef TIMIDITY_OPTIONS_H
9 #define TIMIDITY_OPTIONS_H
10
11 /* When a patch file can't be opened, one of these extensions is
12 appended to the filename and the open is tried again.
13 */
14 #define PATCH_EXT_LIST { ".pat", 0 }
15
16 /* Acoustic Grand Piano seems to be the usual default instrument. */
17 #define DEFAULT_PROGRAM 0
18
19 /* 9 here is MIDI channel 10, which is the standard percussion channel.
20 Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
21 On the other hand, some files know that 16 is not a drum channel and
22 try to play music on it. This is now a runtime option, so this isn't
23 a critical choice anymore. */
24 #define DEFAULT_DRUMCHANNELS (1<<9)
25
26 /* In percent. */
27 #define DEFAULT_AMPLIFICATION 70
28
29 /* Default polyphony */
30 /* #define DEFAULT_VOICES 32 */
31 #define DEFAULT_VOICES 256
32
33 /* 1000 here will give a control ratio of 22:1 with 22 kHz output.
34 Higher CONTROLS_PER_SECOND values allow more accurate rendering
35 of envelopes and tremolo. The cost is CPU time. */
36 #define CONTROLS_PER_SECOND 1000
37
38 /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
39 faster) and sounds more like a GUS. */
40 #define FAST_DECAY
41
42 /* A somewhat arbitrary output frequency range. */
43 #define MIN_OUTPUT_RATE 4000
44 #define MAX_OUTPUT_RATE 256000
45
46 /* How many bits to use for the fractional part of sample positions.
47 This affects tonal accuracy. The entire position counter must fit
48 in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
49 a sample is 1048576 samples (2 megabytes in memory). The GUS gets
50 by with just 9 bits and a little help from its friends...
51 "The GUS does not SUCK!!!" -- a happy user :) */
52 #define FRACTION_BITS 12
53
54 /* For some reason the sample volume is always set to maximum in all
55 patch files. Define this for a crude adjustment that may help
56 equalize instrument volumes. */
57 #define ADJUST_SAMPLE_VOLUMES
58
59 /* The number of samples to use for ramping out a dying note. Affects
60 click removal. */
61 #define MAX_DIE_TIME 20
62
63 /**************************************************************************/
64 /* Anything below this shouldn't need to be changed unless you're porting
65 to a new machine with other than 32-bit, big-endian words. */
66 /**************************************************************************/
67
68 /* change FRACTION_BITS above, not these */
69 #define INTEGER_BITS (32 - FRACTION_BITS)
70 #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
71 #define FRACTION_MASK (~ INTEGER_MASK)
72
73 /* This is enforced by some computations that must fit in an int */
74 #define MAX_CONTROL_RATIO 255
75
76 #define MAX_AMPLIFICATION 800
77
78 /* The TiMidity configuration file */
79 #ifndef TIMIDITY_CFG
80 #define TIMIDITY_CFG "timidity.cfg"
81 #endif
82
83 /* These affect general volume */
84 #define GUARD_BITS 3
85 #define AMP_BITS (15-GUARD_BITS)
86
87 #define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
88
89 #define TIM_FSCALE(a,b) (float)((a) * (double)(1<<(b)))
90 #define TIM_FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
91
92 /* Vibrato and tremolo Choices of the Day */
93 #define SWEEP_TUNING 38
94 #define VIBRATO_AMPLITUDE_TUNING 1.0L
95 #define VIBRATO_RATE_TUNING 38
96 #define TREMOLO_AMPLITUDE_TUNING 1.0L
97 #define TREMOLO_RATE_TUNING 38
98
99 #define SWEEP_SHIFT 16
100 #define RATE_SHIFT 5
101
102 #ifndef PI
103 #define PI 3.14159265358979323846
104 #endif
105
106 #endif /* TIMIDITY_OPTIONS_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 output.c
8
9 Audio output (to file / device) functions.
10 */
11
12 #include "SDL.h"
13
14 #include "options.h"
15 #include "output.h"
16
17 /*****************************************************************/
18 /* Some functions to convert signed 32-bit data to other formats */
19
20 void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c)
21 {
22 Sint8 *cp=(Sint8 *)(dp);
23 Sint32 l;
24 while (c--)
25 {
26 l=(*lp++)>>(32-8-GUARD_BITS);
27 if (l>127) l=127;
28 else if (l<-128) l=-128;
29 *cp++ = (Sint8) (l);
30 }
31 }
32
33 void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c)
34 {
35 Uint8 *cp=(Uint8 *)(dp);
36 Sint32 l;
37 while (c--)
38 {
39 l=(*lp++)>>(32-8-GUARD_BITS);
40 if (l>127) l=127;
41 else if (l<-128) l=-128;
42 *cp++ = 0x80 ^ ((Uint8) l);
43 }
44 }
45
46 void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c)
47 {
48 Sint16 *sp=(Sint16 *)(dp);
49 Sint32 l;
50 while (c--)
51 {
52 l=(*lp++)>>(32-16-GUARD_BITS);
53 if (l > 32767) l=32767;
54 else if (l<-32768) l=-32768;
55 *sp++ = (Sint16)(l);
56 }
57 }
58
59 void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c)
60 {
61 Uint16 *sp=(Uint16 *)(dp);
62 Sint32 l;
63 while (c--)
64 {
65 l=(*lp++)>>(32-16-GUARD_BITS);
66 if (l > 32767) l=32767;
67 else if (l<-32768) l=-32768;
68 *sp++ = 0x8000 ^ (Uint16)(l);
69 }
70 }
71
72 void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c)
73 {
74 Sint16 *sp=(Sint16 *)(dp);
75 Sint32 l;
76 while (c--)
77 {
78 l=(*lp++)>>(32-16-GUARD_BITS);
79 if (l > 32767) l=32767;
80 else if (l<-32768) l=-32768;
81 *sp++ = SDL_Swap16((Sint16)(l));
82 }
83 }
84
85 void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c)
86 {
87 Uint16 *sp=(Uint16 *)(dp);
88 Sint32 l;
89 while (c--)
90 {
91 l=(*lp++)>>(32-16-GUARD_BITS);
92 if (l > 32767) l=32767;
93 else if (l<-32768) l=-32768;
94 *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l));
95 }
96 }
97
98 void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c)
99 {
100 float *sp=(float *)(dp);
101 while (c--)
102 {
103 *sp++ = (float)(*lp++) / 2147483647.0f;
104 }
105 }
106
107 void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c)
108 {
109 Sint32 *sp=(Sint32 *)(dp);
110 while (c--)
111 {
112 *sp++ = (*lp++);
113 }
114 }
115
116 void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c)
117 {
118 Sint32 *sp=(Sint32 *)(dp);
119 while (c--)
120 {
121 *sp++ = SDL_Swap32(*lp++);
122 }
123 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 output.h
8 */
9
10 #ifndef TIMIDITY_OUTPUT_H
11 #define TIMIDITY_OUTPUT_H
12
13 /* Data format encoding bits */
14
15 #define PE_MONO 0x01 /* versus stereo */
16 #define PE_SIGNED 0x02 /* versus unsigned */
17 #define PE_16BIT 0x04 /* versus 8-bit */
18 #define PE_32BIT 0x08 /* versus 8-bit or 16-bit */
19
20 /* Conversion functions -- These overwrite the Sint32 data in *lp with
21 data in another format */
22
23 /* 8-bit signed and unsigned*/
24 extern void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c);
25 extern void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c);
26
27 /* 16-bit */
28 extern void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c);
29 extern void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c);
30
31 /* byte-exchanged 16-bit */
32 extern void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c);
33 extern void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c);
34
35 /* 32-bit */
36 extern void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c);
37 extern void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c);
38
39 /* byte-exchanged 32-bit */
40 extern void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c);
41
42 /* little-endian and big-endian specific */
43 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
44 #define timi_s32tou16l timi_s32tou16
45 #define timi_s32tou16b timi_s32tou16x
46 #define timi_s32tos16l timi_s32tos16
47 #define timi_s32tos16b timi_s32tos16x
48 #define timi_s32tos32l timi_s32tos32
49 #define timi_s32tos32b timi_s32tos32x
50 #else
51 #define timi_s32tou16l timi_s32tou16x
52 #define timi_s32tou16b timi_s32tou16
53 #define timi_s32tos16l timi_s32tos16x
54 #define timi_s32tos16b timi_s32tos16
55 #define timi_s32tos32l timi_s32tos32x
56 #define timi_s32tos32b timi_s32tos32
57 #endif
58
59 #endif /* TIMIDITY_OUTPUT_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 playmidi.c -- random stuff in need of rearrangement
8 */
9
10 #include "SDL.h"
11
12 #include "timidity.h"
13 #include "options.h"
14 #include "common.h"
15 #include "instrum.h"
16 #include "playmidi.h"
17 #include "output.h"
18 #include "mix.h"
19 #include "tables.h"
20
21 static void adjust_amplification(MidiSong *song)
22 {
23 song->master_volume = (float)(song->amplification) / 100.0f;
24 }
25
26 static void reset_voices(MidiSong *song)
27 {
28 int i;
29 for (i=0; i<MAX_VOICES; i++)
30 song->voice[i].status=VOICE_FREE;
31 }
32
33 /* Process the Reset All Controllers event */
34 static void reset_controllers(MidiSong *song, int c)
35 {
36 song->channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */
37 song->channel[c].expression=127; /* SCC-1 does this. */
38 song->channel[c].sustain=0;
39 song->channel[c].pitchbend=0x2000;
40 song->channel[c].pitchfactor=0; /* to be computed */
41 }
42
43 static void reset_midi(MidiSong *song)
44 {
45 int i;
46 for (i=0; i<MAXCHAN; i++)
47 {
48 reset_controllers(song, i);
49 /* The rest of these are unaffected by the Reset All Controllers event */
50 song->channel[i].program=song->default_program;
51 song->channel[i].panning=NO_PANNING;
52 song->channel[i].pitchsens=2;
53 song->channel[i].bank=0; /* tone bank or drum set */
54 }
55 reset_voices(song);
56 }
57
58 static void select_sample(MidiSong *song, int v, Instrument *ip)
59 {
60 Sint32 f, cdiff, diff;
61 int s,i;
62 Sample *sp, *closest;
63
64 s=ip->samples;
65 sp=ip->sample;
66
67 if (s==1)
68 {
69 song->voice[v].sample=sp;
70 return;
71 }
72
73 f=song->voice[v].orig_frequency;
74 for (i=0; i<s; i++, sp++)
75 {
76 if (sp->low_freq <= f && sp->high_freq >= f)
77 {
78 song->voice[v].sample=sp;
79 return;
80 }
81 }
82
83 /*
84 No suitable sample found! We'll select the sample whose root
85 frequency is closest to the one we want. (Actually we should
86 probably convert the low, high, and root frequencies to MIDI
87 note values and compare those.)
88 */
89 cdiff=0x7FFFFFFF;
90 closest=sp=ip->sample;
91 for(i=0; i<s; i++, sp++)
92 {
93 diff=sp->root_freq - f;
94 if (diff<0) diff=-diff;
95 if (diff<cdiff)
96 {
97 cdiff=diff;
98 closest=sp;
99 }
100 }
101 song->voice[v].sample=closest;
102 }
103
104 static void recompute_freq(MidiSong *song, int v)
105 {
106 int
107 sign=(song->voice[v].sample_increment < 0), /* for bidirectional loops */
108 pb=song->channel[song->voice[v].channel].pitchbend;
109 double a;
110
111 if (!song->voice[v].sample->sample_rate)
112 return;
113
114 if (song->voice[v].vibrato_control_ratio)
115 {
116 /* This instrument has vibrato. Invalidate any precomputed
117 sample_increments. */
118
119 int i=VIBRATO_SAMPLE_INCREMENTS;
120 while (i--)
121 song->voice[v].vibrato_sample_increment[i]=0;
122 }
123
124 if (pb==0x2000 || pb<0 || pb>0x3FFF)
125 song->voice[v].frequency = song->voice[v].orig_frequency;
126 else
127 {
128 pb-=0x2000;
129 if (!(song->channel[song->voice[v].channel].pitchfactor))
130 {
131 /* Damn. Somebody bent the pitch. */
132 Sint32 i=pb*song->channel[song->voice[v].channel].pitchsens;
133 if (pb<0)
134 i=-i;
135 song->channel[song->voice[v].channel].pitchfactor=
136 (float)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]);
137 }
138 if (pb>0)
139 song->voice[v].frequency=
140 (Sint32)(song->channel[song->voice[v].channel].pitchfactor *
141 (double)(song->voice[v].orig_frequency));
142 else
143 song->voice[v].frequency=
144 (Sint32)((double)(song->voice[v].orig_frequency) /
145 song->channel[song->voice[v].channel].pitchfactor);
146 }
147
148 a = TIM_FSCALE(((double)(song->voice[v].sample->sample_rate) *
149 (double)(song->voice[v].frequency)) /
150 ((double)(song->voice[v].sample->root_freq) *
151 (double)(song->rate)),
152 FRACTION_BITS);
153
154 if (sign)
155 a = -a; /* need to preserve the loop direction */
156
157 song->voice[v].sample_increment = (Sint32)(a);
158 }
159
160 static void recompute_amp(MidiSong *song, int v)
161 {
162 Sint32 tempamp;
163
164 /* TODO: use fscale */
165
166 tempamp= (song->voice[v].velocity *
167 song->channel[song->voice[v].channel].volume *
168 song->channel[song->voice[v].channel].expression); /* 21 bits */
169
170 if (!(song->encoding & PE_MONO))
171 {
172 if (song->voice[v].panning > 60 && song->voice[v].panning < 68)
173 {
174 song->voice[v].panned=PANNED_CENTER;
175
176 song->voice[v].left_amp=
177 TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
178 21);
179 }
180 else if (song->voice[v].panning<5)
181 {
182 song->voice[v].panned = PANNED_LEFT;
183
184 song->voice[v].left_amp=
185 TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
186 20);
187 }
188 else if (song->voice[v].panning>123)
189 {
190 song->voice[v].panned = PANNED_RIGHT;
191
192 song->voice[v].left_amp= /* left_amp will be used */
193 TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
194 20);
195 }
196 else
197 {
198 song->voice[v].panned = PANNED_MYSTERY;
199
200 song->voice[v].left_amp=
201 TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
202 27);
203 song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning);
204 song->voice[v].left_amp *= (float)(127 - song->voice[v].panning);
205 }
206 }
207 else
208 {
209 song->voice[v].panned = PANNED_CENTER;
210
211 song->voice[v].left_amp=
212 TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
213 21);
214 }
215 }
216
217 static void start_note(MidiSong *song, MidiEvent *e, int i)
218 {
219 Instrument *ip;
220 int j;
221
222 if (ISDRUMCHANNEL(song, e->channel))
223 {
224 if (!(ip=song->drumset[song->channel[e->channel].bank]->instrument[e->a]))
225 {
226 if (!(ip=song->drumset[0]->instrument[e->a]))
227 return; /* No instrument? Then we can't play. */
228 }
229 if (ip->samples != 1)
230 {
231 SNDDBG(("Strange: percussion instrument with %d samples!",
232 ip->samples));
233 }
234
235 if (ip->sample->note_to_use) /* Do we have a fixed pitch? */
236 song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)];
237 else
238 song->voice[i].orig_frequency = freq_table[e->a & 0x7F];
239
240 /* drums are supposed to have only one sample */
241 song->voice[i].sample = ip->sample;
242 }
243 else
244 {
245 if (song->channel[e->channel].program == SPECIAL_PROGRAM)
246 ip=song->default_instrument;
247 else if (!(ip=song->tonebank[song->channel[e->channel].bank]->
248 instrument[song->channel[e->channel].program]))
249 {
250 if (!(ip=song->tonebank[0]->instrument[song->channel[e->channel].program]))
251 return; /* No instrument? Then we can't play. */
252 }
253
254 if (ip->sample->note_to_use) /* Fixed-pitch instrument? */
255 song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)];
256 else
257 song->voice[i].orig_frequency = freq_table[e->a & 0x7F];
258 select_sample(song, i, ip);
259 }
260
261 song->voice[i].status = VOICE_ON;
262 song->voice[i].channel = e->channel;
263 song->voice[i].note = e->a;
264 song->voice[i].velocity = e->b;
265 song->voice[i].sample_offset = 0;
266 song->voice[i].sample_increment = 0; /* make sure it isn't negative */
267
268 song->voice[i].tremolo_phase = 0;
269 song->voice[i].tremolo_phase_increment = song->voice[i].sample->tremolo_phase_increment;
270 song->voice[i].tremolo_sweep = song->voice[i].sample->tremolo_sweep_increment;
271 song->voice[i].tremolo_sweep_position = 0;
272
273 song->voice[i].vibrato_sweep = song->voice[i].sample->vibrato_sweep_increment;
274 song->voice[i].vibrato_sweep_position = 0;
275 song->voice[i].vibrato_control_ratio = song->voice[i].sample->vibrato_control_ratio;
276 song->voice[i].vibrato_control_counter = song->voice[i].vibrato_phase = 0;
277 for (j=0; j<VIBRATO_SAMPLE_INCREMENTS; j++)
278 song->voice[i].vibrato_sample_increment[j] = 0;
279
280 if (song->channel[e->channel].panning != NO_PANNING)
281 song->voice[i].panning = song->channel[e->channel].panning;
282 else
283 song->voice[i].panning = song->voice[i].sample->panning;
284
285 recompute_freq(song, i);
286 recompute_amp(song, i);
287 if (song->voice[i].sample->modes & MODES_ENVELOPE)
288 {
289 /* Ramp up from 0 */
290 song->voice[i].envelope_stage = 0;
291 song->voice[i].envelope_volume = 0;
292 song->voice[i].control_counter = 0;
293 recompute_envelope(song, i);
294 apply_envelope_to_amp(song, i);
295 }
296 else
297 {
298 song->voice[i].envelope_increment = 0;
299 apply_envelope_to_amp(song, i);
300 }
301 }
302
303 static void kill_note(MidiSong *song, int i)
304 {
305 song->voice[i].status = VOICE_DIE;
306 }
307
308 /* Only one instance of a note can be playing on a single channel. */
309 static void note_on(MidiSong *song)
310 {
311 int i = song->voices, lowest=-1;
312 Sint32 lv=0x7FFFFFFF, v;
313 MidiEvent *e = song->current_event;
314
315 while (i--)
316 {
317 if (song->voice[i].status == VOICE_FREE)
318 lowest=i; /* Can't get a lower volume than silence */
319 else if (song->voice[i].channel==e->channel &&
320 (song->voice[i].note==e->a || song->channel[song->voice[i].channel].mono))
321 kill_note(song, i);
322 }
323
324 if (lowest != -1)
325 {
326 /* Found a free voice. */
327 start_note(song,e,lowest);
328 return;
329 }
330
331 /* Look for the decaying note with the lowest volume */
332 i = song->voices;
333 while (i--)
334 {
335 if ((song->voice[i].status != VOICE_ON) &&
336 (song->voice[i].status != VOICE_DIE))
337 {
338 v = song->voice[i].left_mix;
339 if ((song->voice[i].panned == PANNED_MYSTERY)
340 && (song->voice[i].right_mix > v))
341 v = song->voice[i].right_mix;
342 if (v<lv)
343 {
344 lv=v;
345 lowest=i;
346 }
347 }
348 }
349
350 if (lowest != -1)
351 {
352 /* This can still cause a click, but if we had a free voice to
353 spare for ramping down this note, we wouldn't need to kill it
354 in the first place... Still, this needs to be fixed. Perhaps
355 we could use a reserve of voices to play dying notes only. */
356
357 song->cut_notes++;
358 song->voice[lowest].status=VOICE_FREE;
359 start_note(song,e,lowest);
360 }
361 else
362 song->lost_notes++;
363 }
364
365 static void finish_note(MidiSong *song, int i)
366 {
367 if (song->voice[i].sample->modes & MODES_ENVELOPE)
368 {
369 /* We need to get the envelope out of Sustain stage */
370 song->voice[i].envelope_stage = 3;
371 song->voice[i].status = VOICE_OFF;
372 recompute_envelope(song, i);
373 apply_envelope_to_amp(song, i);
374 }
375 else
376 {
377 /* Set status to OFF so resample_voice() will let this voice out
378 of its loop, if any. In any case, this voice dies when it
379 hits the end of its data (ofs>=data_length). */
380 song->voice[i].status = VOICE_OFF;
381 }
382 }
383
384 static void note_off(MidiSong *song)
385 {
386 int i = song->voices;
387 MidiEvent *e = song->current_event;
388
389 while (i--)
390 if (song->voice[i].status == VOICE_ON &&
391 song->voice[i].channel == e->channel &&
392 song->voice[i].note == e->a)
393 {
394 if (song->channel[e->channel].sustain)
395 {
396 song->voice[i].status = VOICE_SUSTAINED;
397 }
398 else
399 finish_note(song, i);
400 return;
401 }
402 }
403
404 /* Process the All Notes Off event */
405 static void all_notes_off(MidiSong *song)
406 {
407 int i = song->voices;
408 int c = song->current_event->channel;
409
410 SNDDBG(("All notes off on channel %d", c));
411 while (i--)
412 if (song->voice[i].status == VOICE_ON &&
413 song->voice[i].channel == c)
414 {
415 if (song->channel[c].sustain)
416 song->voice[i].status = VOICE_SUSTAINED;
417 else
418 finish_note(song, i);
419 }
420 }
421
422 /* Process the All Sounds Off event */
423 static void all_sounds_off(MidiSong *song)
424 {
425 int i = song->voices;
426 int c = song->current_event->channel;
427
428 while (i--)
429 if (song->voice[i].channel == c &&
430 song->voice[i].status != VOICE_FREE &&
431 song->voice[i].status != VOICE_DIE)
432 {
433 kill_note(song, i);
434 }
435 }
436
437 static void adjust_pressure(MidiSong *song)
438 {
439 MidiEvent *e = song->current_event;
440 int i = song->voices;
441
442 while (i--)
443 if (song->voice[i].status == VOICE_ON &&
444 song->voice[i].channel == e->channel &&
445 song->voice[i].note == e->a)
446 {
447 song->voice[i].velocity = e->b;
448 recompute_amp(song, i);
449 apply_envelope_to_amp(song, i);
450 return;
451 }
452 }
453
454 static void drop_sustain(MidiSong *song)
455 {
456 int i = song->voices;
457 int c = song->current_event->channel;
458
459 while (i--)
460 if (song->voice[i].status == VOICE_SUSTAINED && song->voice[i].channel == c)
461 finish_note(song, i);
462 }
463
464 static void adjust_pitchbend(MidiSong *song)
465 {
466 int c = song->current_event->channel;
467 int i = song->voices;
468
469 while (i--)
470 if (song->voice[i].status != VOICE_FREE && song->voice[i].channel == c)
471 {
472 recompute_freq(song, i);
473 }
474 }
475
476 static void adjust_volume(MidiSong *song)
477 {
478 int c = song->current_event->channel;
479 int i = song->voices;
480
481 while (i--)
482 if (song->voice[i].channel == c &&
483 (song->voice[i].status==VOICE_ON || song->voice[i].status==VOICE_SUSTAINED))
484 {
485 recompute_amp(song, i);
486 apply_envelope_to_amp(song, i);
487 }
488 }
489
490 static void seek_forward(MidiSong *song, Sint32 until_time)
491 {
492 reset_voices(song);
493 while (song->current_event->time < until_time)
494 {
495 switch(song->current_event->type)
496 {
497 /* All notes stay off. Just handle the parameter changes. */
498
499 case ME_PITCH_SENS:
500 song->channel[song->current_event->channel].pitchsens =
501 song->current_event->a;
502 song->channel[song->current_event->channel].pitchfactor = 0;
503 break;
504
505 case ME_PITCHWHEEL:
506 song->channel[song->current_event->channel].pitchbend =
507 song->current_event->a + song->current_event->b * 128;
508 song->channel[song->current_event->channel].pitchfactor = 0;
509 break;
510
511 case ME_MAINVOLUME:
512 song->channel[song->current_event->channel].volume =
513 song->current_event->a;
514 break;
515
516 case ME_PAN:
517 song->channel[song->current_event->channel].panning =
518 song->current_event->a;
519 break;
520
521 case ME_EXPRESSION:
522 song->channel[song->current_event->channel].expression =
523 song->current_event->a;
524 break;
525
526 case ME_PROGRAM:
527 if (ISDRUMCHANNEL(song, song->current_event->channel))
528 /* Change drum set */
529 song->channel[song->current_event->channel].bank =
530 song->current_event->a;
531 else
532 song->channel[song->current_event->channel].program =
533 song->current_event->a;
534 break;
535
536 case ME_SUSTAIN:
537 song->channel[song->current_event->channel].sustain =
538 song->current_event->a;
539 break;
540
541 case ME_RESET_CONTROLLERS:
542 reset_controllers(song, song->current_event->channel);
543 break;
544
545 case ME_TONE_BANK:
546 song->channel[song->current_event->channel].bank =
547 song->current_event->a;
548 break;
549
550 case ME_EOT:
551 song->current_sample = song->current_event->time;
552 return;
553 }
554 song->current_event++;
555 }
556 /*song->current_sample=song->current_event->time;*/
557 if (song->current_event != song->events)
558 song->current_event--;
559 song->current_sample=until_time;
560 }
561
562 static void skip_to(MidiSong *song, Sint32 until_time)
563 {
564 if (song->current_sample > until_time)
565 song->current_sample = 0;
566
567 reset_midi(song);
568 song->buffered_count = 0;
569 song->buffer_pointer = song->common_buffer;
570 song->current_event = song->events;
571
572 if (until_time)
573 seek_forward(song, until_time);
574 }
575
576 static void do_compute_data(MidiSong *song, Sint32 count)
577 {
578 int i;
579 SDL_memset(song->buffer_pointer, 0,
580 (song->encoding & PE_MONO) ? (count * 4) : (count * 8));
581 for (i = 0; i < song->voices; i++)
582 {
583 if(song->voice[i].status != VOICE_FREE)
584 mix_voice(song, song->buffer_pointer, i, count);
585 }
586 song->current_sample += count;
587 }
588
589 /* count=0 means flush remaining buffered data to output device, then
590 flush the device itself */
591 static void compute_data(MidiSong *song, void *stream, Sint32 count)
592 {
593 int channels;
594
595 if ( song->encoding & PE_MONO )
596 channels = 1;
597 else
598 channels = 2;
599
600 if (!count)
601 {
602 if (song->buffered_count)
603 song->write(stream, song->common_buffer, channels * song->buffered_count);
604 song->buffer_pointer = song->common_buffer;
605 song->buffered_count = 0;
606 return;
607 }
608
609 while ((count + song->buffered_count) >= song->buffer_size)
610 {
611 do_compute_data(song, song->buffer_size - song->buffered_count);
612 count -= song->buffer_size - song->buffered_count;
613 song->write(stream, song->common_buffer, channels * song->buffer_size);
614 song->buffer_pointer = song->common_buffer;
615 song->buffered_count = 0;
616 }
617 if (count>0)
618 {
619 do_compute_data(song, count);
620 song->buffered_count += count;
621 song->buffer_pointer += (song->encoding & PE_MONO) ? count : count*2;
622 }
623 }
624
625 void Timidity_Start(MidiSong *song)
626 {
627 song->playing = 1;
628 adjust_amplification(song);
629 skip_to(song, 0);
630 }
631
632 void Timidity_Stop(MidiSong *song)
633 {
634 song->playing = 0;
635 }
636
637 int Timidity_IsActive(MidiSong *song)
638 {
639 return song->playing;
640 }
641
642 void Timidity_Seek(MidiSong *song, Uint32 ms)
643 {
644 skip_to(song, (ms * (song->rate / 100)) / 10);
645 }
646
647 Uint32 Timidity_GetSongLength(MidiSong *song)
648 {
649 MidiEvent *last_event = &song->events[song->groomed_event_count - 1];
650 /* We want last_event->time * 1000 / song->rate */
651 Uint32 retvalue = (last_event->time / song->rate) * 1000;
652 retvalue += (last_event->time % song->rate) * 1000 / song->rate;
653 return retvalue;
654 }
655
656 Uint32 Timidity_GetSongTime(MidiSong *song)
657 {
658 Uint32 retvalue = (song->current_sample / song->rate) * 1000;
659 retvalue += (song->current_sample % song->rate) * 1000 / song->rate;
660 return retvalue;
661 }
662
663 int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len)
664 {
665 Sint32 start_sample, end_sample, samples;
666 int bytes_per_sample;
667
668 if (!song->playing)
669 return 0;
670
671 bytes_per_sample = 1;
672 bytes_per_sample *= ((song->encoding & PE_32BIT) ? 4 : ((song->encoding & PE_16BIT) ? 2 : 1));
673 bytes_per_sample *= ((song->encoding & PE_MONO) ? 1 : 2);
674 samples = len / bytes_per_sample;
675
676 start_sample = song->current_sample;
677 end_sample = song->current_sample+samples;
678 while ( song->current_sample < end_sample ) {
679 /* Handle all events that should happen at this time */
680 while (song->current_event->time <= song->current_sample) {
681 switch(song->current_event->type) {
682 /* Effects affecting a single note */
683 case ME_NOTEON:
684 if (!(song->current_event->b)) /* Velocity 0? */
685 note_off(song);
686 else
687 note_on(song);
688 break;
689
690 case ME_NOTEOFF:
691 note_off(song);
692 break;
693
694 case ME_KEYPRESSURE:
695 adjust_pressure(song);
696 break;
697
698 /* Effects affecting a single channel */
699 case ME_PITCH_SENS:
700 song->channel[song->current_event->channel].pitchsens =
701 song->current_event->a;
702 song->channel[song->current_event->channel].pitchfactor = 0;
703 break;
704
705 case ME_PITCHWHEEL:
706 song->channel[song->current_event->channel].pitchbend =
707 song->current_event->a + song->current_event->b * 128;
708 song->channel[song->current_event->channel].pitchfactor = 0;
709 /* Adjust pitch for notes already playing */
710 adjust_pitchbend(song);
711 break;
712
713 case ME_MAINVOLUME:
714 song->channel[song->current_event->channel].volume =
715 song->current_event->a;
716 adjust_volume(song);
717 break;
718
719 case ME_PAN:
720 song->channel[song->current_event->channel].panning =
721 song->current_event->a;
722 break;
723
724 case ME_EXPRESSION:
725 song->channel[song->current_event->channel].expression =
726 song->current_event->a;
727 adjust_volume(song);
728 break;
729
730 case ME_PROGRAM:
731 if (ISDRUMCHANNEL(song, song->current_event->channel)) {
732 /* Change drum set */
733 song->channel[song->current_event->channel].bank =
734 song->current_event->a;
735 }
736 else
737 song->channel[song->current_event->channel].program =
738 song->current_event->a;
739 break;
740
741 case ME_SUSTAIN:
742 song->channel[song->current_event->channel].sustain =
743 song->current_event->a;
744 if (!song->current_event->a)
745 drop_sustain(song);
746 break;
747
748 case ME_RESET_CONTROLLERS:
749 reset_controllers(song, song->current_event->channel);
750 break;
751
752 case ME_ALL_NOTES_OFF:
753 all_notes_off(song);
754 break;
755
756 case ME_ALL_SOUNDS_OFF:
757 all_sounds_off(song);
758 break;
759
760 case ME_TONE_BANK:
761 song->channel[song->current_event->channel].bank =
762 song->current_event->a;
763 break;
764
765 case ME_EOT:
766 /* Give the last notes a couple of seconds to decay */
767 SNDDBG(("Playing time: ~%d seconds\n",
768 song->current_sample/song->rate+2));
769 SNDDBG(("Notes cut: %d\n", song->cut_notes));
770 SNDDBG(("Notes lost totally: %d\n", song->lost_notes));
771 song->playing = 0;
772 return (song->current_sample - start_sample) * bytes_per_sample;
773 }
774 song->current_event++;
775 }
776 if (song->current_event->time > end_sample)
777 compute_data(song, stream, end_sample-song->current_sample);
778 else
779 compute_data(song, stream, song->current_event->time-song->current_sample);
780 }
781 return samples * bytes_per_sample;
782 }
783
784 void Timidity_SetVolume(MidiSong *song, int volume)
785 {
786 int i;
787 if (volume > MAX_AMPLIFICATION)
788 song->amplification = MAX_AMPLIFICATION;
789 else
790 if (volume < 0)
791 song->amplification = 0;
792 else
793 song->amplification = volume;
794 adjust_amplification(song);
795 for (i = 0; i < song->voices; i++)
796 if (song->voice[i].status != VOICE_FREE)
797 {
798 recompute_amp(song, i);
799 apply_envelope_to_amp(song, i);
800 }
801 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 playmidi.h
8 */
9
10 #ifndef TIMIDITY_PLAYMIDI_H
11 #define TIMIDITY_PLAYMIDI_H
12
13 /* Midi events */
14 #define ME_NONE 0
15 #define ME_NOTEON 1
16 #define ME_NOTEOFF 2
17 #define ME_KEYPRESSURE 3
18 #define ME_MAINVOLUME 4
19 #define ME_PAN 5
20 #define ME_SUSTAIN 6
21 #define ME_EXPRESSION 7
22 #define ME_PITCHWHEEL 8
23 #define ME_PROGRAM 9
24 #define ME_TEMPO 10
25 #define ME_PITCH_SENS 11
26
27 #define ME_ALL_SOUNDS_OFF 12
28 #define ME_RESET_CONTROLLERS 13
29 #define ME_ALL_NOTES_OFF 14
30 #define ME_TONE_BANK 15
31
32 #define ME_LYRIC 16
33
34 #define ME_EOT 99
35
36 /* Causes the instrument's default panning to be used. */
37 #define NO_PANNING -1
38
39 /* Voice status options: */
40 #define VOICE_FREE 0
41 #define VOICE_ON 1
42 #define VOICE_SUSTAINED 2
43 #define VOICE_OFF 3
44 #define VOICE_DIE 4
45
46 /* Voice panned options: */
47 #define PANNED_MYSTERY 0
48 #define PANNED_LEFT 1
49 #define PANNED_RIGHT 2
50 #define PANNED_CENTER 3
51 /* Anything but PANNED_MYSTERY only uses the left volume */
52
53 #define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c))))
54
55 #endif /* TIMIDITY_PLAYMIDI_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6 */
7
8 #include "SDL.h"
9
10 #include "options.h"
11 #include "timidity.h"
12 #include "common.h"
13 #include "instrum.h"
14 #include "playmidi.h"
15 #include "readmidi.h"
16
17 /* Computes how many (fractional) samples one MIDI delta-time unit contains */
18 static void compute_sample_increment(MidiSong *song, Sint32 tempo,
19 Sint32 divisions)
20 {
21 double a;
22 a = (double) (tempo) * (double) (song->rate) * (65536.0/1000000.0) /
23 (double)(divisions);
24
25 song->sample_correction = (Sint32)(a) & 0xFFFF;
26 song->sample_increment = (Sint32)(a) >> 16;
27
28 SNDDBG(("Samples per delta-t: %d (correction %d)",
29 song->sample_increment, song->sample_correction));
30 }
31
32 /* Read variable-length number (7 bits per byte, MSB first) */
33 static Sint32 getvl(SDL_RWops *rw)
34 {
35 Sint32 l=0;
36 Uint8 c;
37 for (;;)
38 {
39 if (!SDL_RWread(rw, &c, 1, 1)) return l;
40 l += (c & 0x7f);
41 if (!(c & 0x80)) return l;
42 l<<=7;
43 }
44 }
45
46 #if (defined DEBUG_CHATTER)
47 /* Print a string from the file, followed by a newline. Any non-ASCII
48 or unprintable characters will be converted to periods. */
49 static int dumpstring(SDL_RWops *rw, Sint32 len, Uint8 type)
50 {
51 static const char *label[] = {
52 "Text event: ", "Text: ", "Copyright: ", "Track name: ",
53 "Instrument: ", "Lyric: ", "Marker: ", "Cue point: " };
54 signed char *s = SDL_malloc(len+1);
55 if (!s)
56 {
57 SDL_RWseek(rw, len, RW_SEEK_CUR);/* should I ? */
58 return -1;
59 }
60 if (len != (Sint32) SDL_RWread(rw, s, 1, len))
61 {
62 SDL_free(s);
63 return -1;
64 }
65
66 s[len]='\0';
67 while (len--)
68 {
69 if (s[len]<32)
70 s[len]='.';
71 }
72 SNDDBG(("%s%s", label[(type>7) ? 0 : type], s));
73 SDL_free(s);
74 return 0;
75 }
76 #endif
77
78 #define MIDIEVENT(at,t,ch,pa,pb) \
79 newlist = (MidiEventList *) SDL_malloc(sizeof(MidiEventList));\
80 if (!newlist) {song->oom = 1; return NULL;} \
81 newlist->event.time = at; \
82 newlist->event.type = t; \
83 newlist->event.channel = ch; \
84 newlist->event.a = pa; \
85 newlist->event.b = pb; \
86 newlist->next = NULL; \
87 return newlist;
88
89 #define MAGIC_EOT ((MidiEventList *)(-1))
90
91 /* Read a MIDI event, returning a freshly allocated element that can
92 be linked to the event list */
93 static MidiEventList *read_midi_event(MidiSong *song)
94 {
95 static Uint8 laststatus, lastchan;
96 static Uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */
97 Uint8 me, type, a,b,c;
98 Sint32 len;
99 MidiEventList *newlist;
100
101 for (;;)
102 {
103 song->at += getvl(song->rw);
104 if (SDL_RWread(song->rw, &me, 1, 1) != 1)
105 {
106 SNDDBG(("read_midi_event: SDL_RWread() failure\n"));
107 return NULL;
108 }
109
110 if(me==0xF0 || me == 0xF7) /* SysEx event */
111 {
112 len=getvl(song->rw);
113 SDL_RWseek(song->rw, len, RW_SEEK_CUR);
114 }
115 else if(me==0xFF) /* Meta event */
116 {
117 SDL_RWread(song->rw, &type, 1, 1);
118 len=getvl(song->rw);
119 if (type>0 && type<16)
120 {
121 #if (defined DEBUG_CHATTER)
122 dumpstring(song->rw, len, type);
123 #else
124 SDL_RWseek(song->rw, len, RW_SEEK_CUR);
125 #endif
126 }
127 else
128 switch(type)
129 {
130 case 0x2F: /* End of Track */
131 return MAGIC_EOT;
132
133 case 0x51: /* Tempo */
134 SDL_RWread(song->rw, &a, 1, 1);
135 SDL_RWread(song->rw, &b, 1, 1);
136 SDL_RWread(song->rw, &c, 1, 1);
137 MIDIEVENT(song->at, ME_TEMPO, c, a, b);
138
139 default:
140 SNDDBG(("(Meta event type 0x%02x, length %d)\n", type, len));
141 SDL_RWseek(song->rw, len, RW_SEEK_CUR);
142 break;
143 }
144 }
145 else
146 {
147 a=me;
148 if (a & 0x80) /* status byte */
149 {
150 lastchan=a & 0x0F;
151 laststatus=(a>>4) & 0x07;
152 SDL_RWread(song->rw, &a, 1, 1);
153 a &= 0x7F;
154 }
155 switch(laststatus)
156 {
157 case 0: /* Note off */
158 SDL_RWread(song->rw, &b, 1, 1);
159 b &= 0x7F;
160 MIDIEVENT(song->at, ME_NOTEOFF, lastchan, a,b);
161
162 case 1: /* Note on */
163 SDL_RWread(song->rw, &b, 1, 1);
164 b &= 0x7F;
165 MIDIEVENT(song->at, ME_NOTEON, lastchan, a,b);
166
167 case 2: /* Key Pressure */
168 SDL_RWread(song->rw, &b, 1, 1);
169 b &= 0x7F;
170 MIDIEVENT(song->at, ME_KEYPRESSURE, lastchan, a, b);
171
172 case 3: /* Control change */
173 SDL_RWread(song->rw, &b, 1, 1);
174 b &= 0x7F;
175 {
176 int control=255;
177 switch(a)
178 {
179 case 7: control=ME_MAINVOLUME; break;
180 case 10: control=ME_PAN; break;
181 case 11: control=ME_EXPRESSION; break;
182 case 64: control=ME_SUSTAIN; b = (b >= 64); break;
183 case 120: control=ME_ALL_SOUNDS_OFF; break;
184 case 121: control=ME_RESET_CONTROLLERS; break;
185 case 123: control=ME_ALL_NOTES_OFF; break;
186
187 /* These should be the SCC-1 tone bank switch
188 commands. I don't know why there are two, or
189 why the latter only allows switching to bank 0.
190 Also, some MIDI files use 0 as some sort of
191 continuous controller. This will cause lots of
192 warnings about undefined tone banks. */
193 case 0: control=ME_TONE_BANK; break;
194 case 32:
195 if (b!=0) {
196 SNDDBG(("(Strange: tone bank change 0x%02x)\n", b));
197 }
198 #if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */
199 else
200 control=ME_TONE_BANK;
201 #endif
202 break;
203
204 case 100: nrpn=0; rpn_msb[lastchan]=b; break;
205 case 101: nrpn=0; rpn_lsb[lastchan]=b; break;
206 case 99: nrpn=1; rpn_msb[lastchan]=b; break;
207 case 98: nrpn=1; rpn_lsb[lastchan]=b; break;
208
209 case 6:
210 if (nrpn)
211 {
212 SNDDBG(("(Data entry (MSB) for NRPN %02x,%02x: %d)\n",
213 rpn_msb[lastchan], rpn_lsb[lastchan], b));
214 break;
215 }
216
217 switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan])
218 {
219 case 0x0000: /* Pitch bend sensitivity */
220 control=ME_PITCH_SENS;
221 break;
222
223 case 0x7F7F: /* RPN reset */
224 /* reset pitch bend sensitivity to 2 */
225 MIDIEVENT(song->at, ME_PITCH_SENS, lastchan, 2, 0);
226
227 default:
228 SNDDBG(("(Data entry (MSB) for RPN %02x,%02x: %d)\n",
229 rpn_msb[lastchan], rpn_lsb[lastchan], b));
230 break;
231 }
232 break;
233
234 default:
235 SNDDBG(("(Control %d: %d)\n", a, b));
236 break;
237 }
238 if (control != 255)
239 {
240 MIDIEVENT(song->at, control, lastchan, b, 0);
241 }
242 }
243 break;
244
245 case 4: /* Program change */
246 a &= 0x7f;
247 MIDIEVENT(song->at, ME_PROGRAM, lastchan, a, 0);
248
249 case 5: /* Channel pressure - NOT IMPLEMENTED */
250 break;
251
252 case 6: /* Pitch wheel */
253 SDL_RWread(song->rw, &b, 1, 1);
254 b &= 0x7F;
255 MIDIEVENT(song->at, ME_PITCHWHEEL, lastchan, a, b);
256
257 default:
258 SNDDBG(("*** Can't happen: status 0x%02X, channel 0x%02X\n",
259 laststatus, lastchan));
260 break;
261 }
262 }
263 }
264
265 return newlist;
266 }
267
268 #undef MIDIEVENT
269
270 /* Read a midi track into the linked list, either merging with any previous
271 tracks or appending to them. */
272 static int read_track(MidiSong *song, int append)
273 {
274 MidiEventList *meep;
275 MidiEventList *next, *newlist;
276 Sint32 len;
277 Sint64 next_pos, pos;
278 char tmp[4];
279
280 meep = song->evlist;
281 if (append && meep)
282 {
283 /* find the last event in the list */
284 for (; meep->next; meep=meep->next)
285 ;
286 song->at = meep->event.time;
287 }
288 else
289 song->at=0;
290
291 /* Check the formalities */
292 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
293 {
294 SNDDBG(("Can't read track header.\n"));
295 return -1;
296 }
297 len=(Sint32)SDL_SwapBE32((Uint32)len);
298 next_pos = SDL_RWtell(song->rw) + len;
299 if (SDL_memcmp(tmp, "MTrk", 4))
300 {
301 SNDDBG(("Corrupt MIDI file.\n"));
302 return -2;
303 }
304
305 for (;;)
306 {
307 if (!(newlist=read_midi_event(song))) /* Some kind of error */
308 return -2;
309
310 if (newlist==MAGIC_EOT) /* End-of-track Hack. */
311 {
312 /* If the track ends before the size of the
313 * track data, skip any junk at the end. */
314 pos = SDL_RWtell(song->rw);
315 if (pos < next_pos)
316 SDL_RWseek(song->rw, next_pos - pos, RW_SEEK_CUR);
317 return 0;
318 }
319
320 next=meep->next;
321 while (next && (next->event.time < newlist->event.time))
322 {
323 meep=next;
324 next=meep->next;
325 }
326
327 newlist->next=next;
328 meep->next=newlist;
329
330 song->event_count++; /* Count the event. (About one?) */
331 meep=newlist;
332 }
333 }
334
335 /* Free the linked event list from memory. */
336 static void free_midi_list(MidiSong *song)
337 {
338 MidiEventList *meep, *next;
339 meep = song->evlist;
340 while (meep)
341 {
342 next=meep->next;
343 SDL_free(meep);
344 meep=next;
345 }
346 song->evlist = NULL;
347 }
348
349 /* Allocate an array of MidiEvents and fill it from the linked list of
350 events, marking used instruments for loading. Convert event times to
351 samples: handle tempo changes. Strip unnecessary events from the list.
352 Free the linked list. */
353 static MidiEvent *groom_list(MidiSong *song, Sint32 divisions,Sint32 *eventsp,
354 Sint32 *samplesp)
355 {
356 MidiEvent *groomed_list, *lp;
357 MidiEventList *meep;
358 Sint32 i, our_event_count, tempo, skip_this_event, new_value;
359 Sint32 sample_cum, samples_to_do, at, st, dt, counting_time;
360
361 int current_bank[MAXCHAN], current_set[MAXCHAN], current_program[MAXCHAN];
362 /* Or should each bank have its own current program? */
363
364 for (i=0; i<MAXCHAN; i++)
365 {
366 current_bank[i]=0;
367 current_set[i]=0;
368 current_program[i]=song->default_program;
369 }
370
371 tempo=500000;
372 compute_sample_increment(song, tempo, divisions);
373
374 /* This may allocate a bit more than we need */
375 groomed_list=lp=SDL_malloc(sizeof(MidiEvent) * (song->event_count+1));
376 if (!groomed_list) {
377 song->oom=1;
378 free_midi_list(song);
379 return NULL;
380 }
381 meep=song->evlist;
382
383 our_event_count=0;
384 st=at=sample_cum=0;
385 counting_time=2; /* We strip any silence before the first NOTE ON. */
386
387 for (i = 0; i < song->event_count; i++)
388 {
389 skip_this_event=0;
390
391 if (meep->event.type==ME_TEMPO)
392 {
393 skip_this_event=1;
394 }
395 else if (meep->event.channel >= MAXCHAN)
396 skip_this_event=1;
397 else switch (meep->event.type)
398 {
399 case ME_PROGRAM:
400 if (ISDRUMCHANNEL(song, meep->event.channel))
401 {
402 if (song->drumset[meep->event.a]) /* Is this a defined drumset? */
403 new_value=meep->event.a;
404 else
405 {
406 SNDDBG(("Drum set %d is undefined\n", meep->event.a));
407 new_value=meep->event.a=0;
408 }
409 if (current_set[meep->event.channel] != new_value)
410 current_set[meep->event.channel]=new_value;
411 else
412 skip_this_event=1;
413 }
414 else
415 {
416 new_value=meep->event.a;
417 if ((current_program[meep->event.channel] != SPECIAL_PROGRAM)
418 && (current_program[meep->event.channel] != new_value))
419 current_program[meep->event.channel] = new_value;
420 else
421 skip_this_event=1;
422 }
423 break;
424
425 case ME_NOTEON:
426 if (counting_time)
427 counting_time=1;
428 if (ISDRUMCHANNEL(song, meep->event.channel))
429 {
430 /* Mark this instrument to be loaded */
431 if (!(song->drumset[current_set[meep->event.channel]]
432 ->instrument[meep->event.a]))
433 song->drumset[current_set[meep->event.channel]]
434 ->instrument[meep->event.a] = MAGIC_LOAD_INSTRUMENT;
435 }
436 else
437 {
438 if (current_program[meep->event.channel]==SPECIAL_PROGRAM)
439 break;
440 /* Mark this instrument to be loaded */
441 if (!(song->tonebank[current_bank[meep->event.channel]]
442 ->instrument[current_program[meep->event.channel]]))
443 song->tonebank[current_bank[meep->event.channel]]
444 ->instrument[current_program[meep->event.channel]] =
445 MAGIC_LOAD_INSTRUMENT;
446 }
447 break;
448
449 case ME_TONE_BANK:
450 if (ISDRUMCHANNEL(song, meep->event.channel))
451 {
452 skip_this_event=1;
453 break;
454 }
455 if (song->tonebank[meep->event.a]) /* Is this a defined tone bank? */
456 new_value=meep->event.a;
457 else
458 {
459 SNDDBG(("Tone bank %d is undefined\n", meep->event.a));
460 new_value=meep->event.a=0;
461 }
462 if (current_bank[meep->event.channel]!=new_value)
463 current_bank[meep->event.channel]=new_value;
464 else
465 skip_this_event=1;
466 break;
467 }
468
469 /* Recompute time in samples*/
470 if ((dt=meep->event.time - at) && !counting_time)
471 {
472 if (song->sample_increment > 2147483647/dt ||
473 song->sample_correction > 2147483647/dt) {
474 goto _overflow;
475 }
476 samples_to_do = song->sample_increment * dt;
477 sample_cum += song->sample_correction * dt;
478 if (sample_cum & 0xFFFF0000)
479 {
480 samples_to_do += ((sample_cum >> 16) & 0xFFFF);
481 sample_cum &= 0x0000FFFF;
482 }
483 if (st >= 2147483647 - samples_to_do) {
484 _overflow:
485 SNDDBG(("Overflow in sample counter\n"));
486 free_midi_list(song);
487 SDL_free(groomed_list);
488 return NULL;
489 }
490 st += samples_to_do;
491 }
492 else if (counting_time==1) counting_time=0;
493 if (meep->event.type==ME_TEMPO)
494 {
495 tempo=
496 meep->event.channel + meep->event.b * 256 + meep->event.a * 65536;
497 compute_sample_increment(song, tempo, divisions);
498 }
499 if (!skip_this_event)
500 {
501 /* Add the event to the list */
502 *lp=meep->event;
503 lp->time=st;
504 lp++;
505 our_event_count++;
506 }
507 at=meep->event.time;
508 meep=meep->next;
509 }
510 /* Add an End-of-Track event */
511 lp->time=st;
512 lp->type=ME_EOT;
513 our_event_count++;
514 free_midi_list(song);
515
516 *eventsp=our_event_count;
517 *samplesp=st;
518 return groomed_list;
519 }
520
521 MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp)
522 {
523 Sint32 len, divisions;
524 Sint16 format, tracks, divisions_tmp;
525 int i;
526 char tmp[4];
527
528 song->event_count=0;
529 song->at=0;
530 song->evlist = NULL;
531
532 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
533 {
534 SNDDBG(("Not a MIDI file!\n"));
535 return NULL;
536 }
537 if (SDL_memcmp(tmp, "RIFF", 4) == 0) { /* RMID ?? */
538 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_memcmp(tmp, "RMID", 4) != 0 ||
539 SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_memcmp(tmp, "data", 4) != 0 ||
540 SDL_RWread(song->rw, tmp, 1, 4) != 4 ||
541 /* SMF must begin from here onwards: */
542 SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
543 {
544 SNDDBG(("Not an RMID file!\n"));
545 return NULL;
546 }
547 }
548 len=(Sint32)SDL_SwapBE32((Uint32)len);
549 if (SDL_memcmp(tmp, "MThd", 4) || len < 6)
550 {
551 SNDDBG(("Not a MIDI file!\n"));
552 return NULL;
553 }
554
555 format=tracks=divisions_tmp = -1;
556 SDL_RWread(song->rw, &format, 2, 1);
557 SDL_RWread(song->rw, &tracks, 2, 1);
558 SDL_RWread(song->rw, &divisions_tmp, 2, 1);
559 format=SDL_SwapBE16(format);
560 tracks=SDL_SwapBE16(tracks);
561 divisions_tmp=SDL_SwapBE16(divisions_tmp);
562
563 if (divisions_tmp<0)
564 {
565 /* SMPTE time -- totally untested. Got a MIDI file that uses this? */
566 divisions=
567 (Sint32)(-(divisions_tmp/256)) * (Sint32)(divisions_tmp & 0xFF);
568 }
569 else divisions=(Sint32)(divisions_tmp);
570
571 if (len > 6)
572 {
573 SNDDBG(("MIDI file header size %u bytes", len));
574 SDL_RWseek(song->rw, len-6, RW_SEEK_CUR); /* skip the excess */
575 }
576 if (format<0 || format >2)
577 {
578 SNDDBG(("Unknown MIDI file format %d\n", format));
579 return NULL;
580 }
581 if (tracks<1)
582 {
583 SNDDBG(("Bad number of tracks %d\n", tracks));
584 return NULL;
585 }
586 if (format==0 && tracks!=1)
587 {
588 SNDDBG(("%d tracks with Type-0 MIDI (must be 1.)\n", tracks));
589 return NULL;
590 }
591 SNDDBG(("Format: %d Tracks: %d Divisions: %d\n",
592 format, tracks, divisions));
593
594 /* Put a do-nothing event first in the list for easier processing */
595 song->evlist=SDL_calloc(1, sizeof(MidiEventList));
596 if (!song->evlist) {
597 song->oom=1;
598 return NULL;
599 }
600 song->event_count++;
601
602 switch(format)
603 {
604 case 0:
605 if (read_track(song, 0))
606 {
607 free_midi_list(song);
608 return NULL;
609 }
610 break;
611
612 case 1:
613 for (i=0; i<tracks; i++)
614 if (read_track(song, 0))
615 {
616 free_midi_list(song);
617 return NULL;
618 }
619 break;
620
621 case 2: /* We simply play the tracks sequentially */
622 for (i=0; i<tracks; i++)
623 if (read_track(song, 1))
624 {
625 free_midi_list(song);
626 return NULL;
627 }
628 break;
629 }
630
631 return groom_list(song, divisions, count, sp);
632 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 readmidi.h
8 */
9
10 #ifndef TIMIDITY_READMIDI_H
11 #define TIMIDITY_READMIDI_H
12
13 #define read_midi_file TIMI_NAMESPACE(read_midi_file)
14
15 extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp);
16
17 #endif /* TIMIDITY_READMIDI_H */
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 resample.c
9 */
10
11 #include "SDL.h"
12
13 #include "timidity.h"
14 #include "options.h"
15 #include "common.h"
16 #include "instrum.h"
17 #include "playmidi.h"
18 #include "tables.h"
19 #include "resample.h"
20
21 #define PRECALC_LOOP_COUNT(start, end, incr) (((end) - (start) + (incr) - 1) / (incr))
22
23 /*************** resampling with fixed increment *****************/
24
25 static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr)
26 {
27
28 /* Play sample until end, then free the voice. */
29
30 sample_t v1, v2;
31 Voice
32 *vp=&(song->voice[v]);
33 sample_t
34 *dest=song->resample_buffer,
35 *src=vp->sample->data;
36 Sint32
37 ofs=vp->sample_offset,
38 incr=vp->sample_increment,
39 le=vp->sample->data_length,
40 count=*countptr;
41 Sint32 i, j;
42
43 if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */
44
45 /* Precalc how many times we should go through the loop.
46 NOTE: Assumes that incr > 0 and that ofs <= le */
47 i = PRECALC_LOOP_COUNT(ofs, le, incr);
48
49 if (i > count)
50 {
51 i = count;
52 count = 0;
53 }
54 else count -= i;
55
56 for (j = 0; j < i; j++)
57 {
58 v1 = src[ofs >> FRACTION_BITS];
59 v2 = src[(ofs >> FRACTION_BITS)+1];
60 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
61 ofs += incr;
62 }
63
64 if (ofs >= le)
65 {
66 if (ofs == le)
67 *dest++ = src[(ofs>>FRACTION_BITS)-1]/2;
68 vp->status=VOICE_FREE;
69 *countptr-=count+1;
70 }
71
72 vp->sample_offset=ofs; /* Update offset */
73 return song->resample_buffer;
74 }
75
76 static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count)
77 {
78 /* Play sample until end-of-loop, skip back and continue. */
79
80 sample_t v1, v2;
81 Sint32
82 ofs=vp->sample_offset,
83 incr=vp->sample_increment,
84 le=vp->sample->loop_end,
85 ll=le - vp->sample->loop_start;
86 sample_t
87 *dest=song->resample_buffer,
88 *src=vp->sample->data;
89 Sint32 i, j;
90
91 while (count)
92 {
93 while (ofs >= le)
94 ofs -= ll;
95 /* Precalc how many times we should go through the loop */
96 i = PRECALC_LOOP_COUNT(ofs, le, incr);
97 if (i > count)
98 {
99 i = count;
100 count = 0;
101 }
102 else count -= i;
103 for (j = 0; j < i; j++)
104 {
105 v1 = src[ofs >> FRACTION_BITS];
106 v2 = src[(ofs >> FRACTION_BITS)+1];
107 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
108 ofs += incr;
109 }
110 }
111
112 vp->sample_offset=ofs; /* Update offset */
113 return song->resample_buffer;
114 }
115
116 static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count)
117 {
118 sample_t v1, v2;
119 Sint32
120 ofs=vp->sample_offset,
121 incr=vp->sample_increment,
122 le=vp->sample->loop_end,
123 ls=vp->sample->loop_start;
124 sample_t
125 *dest=song->resample_buffer,
126 *src=vp->sample->data;
127 Sint32
128 le2 = le<<1,
129 ls2 = ls<<1,
130 i, j;
131 /* Play normally until inside the loop region */
132
133 if (incr > 0 && ofs < ls)
134 {
135 /* NOTE: Assumes that incr > 0, which is NOT always the case
136 when doing bidirectional looping. I have yet to see a case
137 where both ofs <= ls AND incr < 0, however. */
138 i = PRECALC_LOOP_COUNT(ofs, ls, incr);
139 if (i > count)
140 {
141 i = count;
142 count = 0;
143 }
144 else count -= i;
145 for (j = 0; j < i; j++)
146 {
147 v1 = src[ofs >> FRACTION_BITS];
148 v2 = src[(ofs >> FRACTION_BITS)+1];
149 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
150 ofs += incr;
151 }
152 }
153
154 /* Then do the bidirectional looping */
155 while(count)
156 {
157 /* Precalc how many times we should go through the loop */
158 i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr);
159 if (i > count)
160 {
161 i = count;
162 count = 0;
163 }
164 else count -= i;
165 for (j = 0; j < i; j++)
166 {
167 v1 = src[ofs >> FRACTION_BITS];
168 v2 = src[(ofs >> FRACTION_BITS)+1];
169 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
170 ofs += incr;
171 }
172 if (ofs>=le)
173 {
174 /* fold the overshoot back in */
175 ofs = le2 - ofs;
176 incr *= -1;
177 }
178 else if (ofs <= ls)
179 {
180 ofs = ls2 - ofs;
181 incr *= -1;
182 }
183 }
184
185 vp->sample_increment=incr;
186 vp->sample_offset=ofs; /* Update offset */
187 return song->resample_buffer;
188 }
189
190 /*********************** vibrato versions ***************************/
191
192 /* We only need to compute one half of the vibrato sine cycle */
193 static int vib_phase_to_inc_ptr(int phase)
194 {
195 if (phase < VIBRATO_SAMPLE_INCREMENTS/2)
196 return VIBRATO_SAMPLE_INCREMENTS/2-1-phase;
197 else if (phase >= 3*VIBRATO_SAMPLE_INCREMENTS/2)
198 return 5*VIBRATO_SAMPLE_INCREMENTS/2-1-phase;
199 else
200 return phase-VIBRATO_SAMPLE_INCREMENTS/2;
201 }
202
203 static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign)
204 {
205 Sint32 depth;
206 int phase, pb;
207 double a;
208
209 if (vp->vibrato_phase++ >= 2*VIBRATO_SAMPLE_INCREMENTS-1)
210 vp->vibrato_phase=0;
211 phase=vib_phase_to_inc_ptr(vp->vibrato_phase);
212
213 if (vp->vibrato_sample_increment[phase])
214 {
215 if (sign)
216 return -vp->vibrato_sample_increment[phase];
217 else
218 return vp->vibrato_sample_increment[phase];
219 }
220
221 /* Need to compute this sample increment. */
222 depth=vp->sample->vibrato_depth<<7;
223
224 if (vp->vibrato_sweep)
225 {
226 /* Need to update sweep */
227 vp->vibrato_sweep_position += vp->vibrato_sweep;
228 if (vp->vibrato_sweep_position >= (1<<SWEEP_SHIFT))
229 vp->vibrato_sweep=0;
230 else
231 {
232 /* Adjust depth */
233 depth *= vp->vibrato_sweep_position;
234 depth >>= SWEEP_SHIFT;
235 }
236 }
237
238 a = TIM_FSCALE(((double)(vp->sample->sample_rate) *
239 (double)(vp->frequency)) /
240 ((double)(vp->sample->root_freq) *
241 (double)(song->rate)),
242 FRACTION_BITS);
243
244 pb=(int)((timi_sine(vp->vibrato_phase *
245 (SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS)))
246 * (double)(depth) * VIBRATO_AMPLITUDE_TUNING));
247
248 if (pb<0)
249 {
250 pb=-pb;
251 a /= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13];
252 }
253 else
254 a *= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13];
255
256 /* If the sweep's over, we can store the newly computed sample_increment */
257 if (!vp->vibrato_sweep)
258 vp->vibrato_sample_increment[phase]=(Sint32) a;
259
260 if (sign)
261 a = -a; /* need to preserve the loop direction */
262
263 return (Sint32) a;
264 }
265
266 static sample_t *rs_vib_plain(MidiSong *song, int v, Sint32 *countptr)
267 {
268 /* Play sample until end, then free the voice. */
269
270 sample_t v1, v2;
271 Voice *vp=&(song->voice[v]);
272 sample_t
273 *dest=song->resample_buffer,
274 *src=vp->sample->data;
275 Sint32
276 le=vp->sample->data_length,
277 ofs=vp->sample_offset,
278 incr=vp->sample_increment,
279 count=*countptr;
280 int
281 cc=vp->vibrato_control_counter;
282
283 /* This has never been tested */
284
285 if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */
286
287 while (count--)
288 {
289 if (!cc--)
290 {
291 cc=vp->vibrato_control_ratio;
292 incr=update_vibrato(song, vp, 0);
293 }
294 v1 = src[ofs >> FRACTION_BITS];
295 v2 = src[(ofs >> FRACTION_BITS)+1];
296 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
297 ofs += incr;
298 if (ofs >= le)
299 {
300 if (ofs == le)
301 *dest++ = src[(ofs>>FRACTION_BITS)-1]/2;
302 vp->status=VOICE_FREE;
303 *countptr-=count+1;
304 break;
305 }
306 }
307
308 vp->vibrato_control_counter=cc;
309 vp->sample_increment=incr;
310 vp->sample_offset=ofs; /* Update offset */
311 return song->resample_buffer;
312 }
313
314 static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count)
315 {
316 /* Play sample until end-of-loop, skip back and continue. */
317
318 sample_t v1, v2;
319 Sint32
320 ofs=vp->sample_offset,
321 incr=vp->sample_increment,
322 le=vp->sample->loop_end,
323 ll=le - vp->sample->loop_start;
324 sample_t
325 *dest=song->resample_buffer,
326 *src=vp->sample->data;
327 int
328 cc=vp->vibrato_control_counter;
329 Sint32 i, j;
330 int
331 vibflag=0;
332
333 while (count)
334 {
335 /* Hopefully the loop is longer than an increment */
336 while(ofs >= le)
337 ofs -= ll;
338 /* Precalc how many times to go through the loop, taking
339 the vibrato control ratio into account this time. */
340 i = PRECALC_LOOP_COUNT(ofs, le, incr);
341 if(i > count) i = count;
342 if(i > cc)
343 {
344 i = cc;
345 vibflag = 1;
346 }
347 else cc -= i;
348 count -= i;
349 for (j = 0; j < i; j++)
350 {
351 v1 = src[ofs >> FRACTION_BITS];
352 v2 = src[(ofs >> FRACTION_BITS)+1];
353 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
354 ofs += incr;
355 }
356 if(vibflag)
357 {
358 cc = vp->vibrato_control_ratio;
359 incr = update_vibrato(song, vp, 0);
360 vibflag = 0;
361 }
362 }
363
364 vp->vibrato_control_counter=cc;
365 vp->sample_increment=incr;
366 vp->sample_offset=ofs; /* Update offset */
367 return song->resample_buffer;
368 }
369
370 static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count)
371 {
372 sample_t v1, v2;
373 Sint32
374 ofs=vp->sample_offset,
375 incr=vp->sample_increment,
376 le=vp->sample->loop_end,
377 ls=vp->sample->loop_start;
378 sample_t
379 *dest=song->resample_buffer,
380 *src=vp->sample->data;
381 int
382 cc=vp->vibrato_control_counter;
383 Sint32
384 le2=le<<1,
385 ls2=ls<<1,
386 i, j;
387 int
388 vibflag = 0;
389
390 /* Play normally until inside the loop region */
391 while (count && incr > 0 && ofs < ls)
392 {
393 i = PRECALC_LOOP_COUNT(ofs, ls, incr);
394 if (i > count) i = count;
395 if (i > cc)
396 {
397 i = cc;
398 vibflag = 1;
399 }
400 else cc -= i;
401 count -= i;
402 for (j = 0; j < i; j++)
403 {
404 v1 = src[ofs >> FRACTION_BITS];
405 v2 = src[(ofs >> FRACTION_BITS)+1];
406 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
407 ofs += incr;
408 }
409 if (vibflag)
410 {
411 cc = vp->vibrato_control_ratio;
412 incr = update_vibrato(song, vp, 0);
413 vibflag = 0;
414 }
415 }
416
417 /* Then do the bidirectional looping */
418 while (count)
419 {
420 /* Precalc how many times we should go through the loop */
421 i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr);
422 if(i > count) i = count;
423 if(i > cc)
424 {
425 i = cc;
426 vibflag = 1;
427 }
428 else cc -= i;
429 count -= i;
430 while (i--)
431 {
432 v1 = src[ofs >> FRACTION_BITS];
433 v2 = src[(ofs >> FRACTION_BITS)+1];
434 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
435 ofs += incr;
436 }
437 if (vibflag)
438 {
439 cc = vp->vibrato_control_ratio;
440 incr = update_vibrato(song, vp, (incr < 0));
441 vibflag = 0;
442 }
443 if (ofs >= le)
444 {
445 /* fold the overshoot back in */
446 ofs = le2 - ofs;
447 incr *= -1;
448 }
449 else if (ofs <= ls)
450 {
451 ofs = ls2 - ofs;
452 incr *= -1;
453 }
454 }
455
456 vp->vibrato_control_counter=cc;
457 vp->sample_increment=incr;
458 vp->sample_offset=ofs; /* Update offset */
459 return song->resample_buffer;
460 }
461
462 sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr)
463 {
464 Sint32 ofs;
465 Uint8 modes;
466 Voice *vp=&(song->voice[v]);
467
468 if (!(vp->sample->sample_rate))
469 {
470 /* Pre-resampled data -- just update the offset and check if
471 we're out of data. */
472 ofs=vp->sample_offset >> FRACTION_BITS; /* Kind of silly to use
473 FRACTION_BITS here... */
474 if (*countptr >= (vp->sample->data_length>>FRACTION_BITS) - ofs)
475 {
476 /* Note finished. Free the voice. */
477 vp->status = VOICE_FREE;
478
479 /* Let the caller know how much data we had left */
480 *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs;
481 }
482 else
483 vp->sample_offset += *countptr << FRACTION_BITS;
484
485 return vp->sample->data+ofs;
486 }
487
488 /* Need to resample. Use the proper function. */
489 modes=vp->sample->modes;
490
491 if (vp->vibrato_control_ratio)
492 {
493 if ((modes & MODES_LOOPING) &&
494 ((modes & MODES_ENVELOPE) ||
495 (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED)))
496 {
497 if (modes & MODES_PINGPONG)
498 return rs_vib_bidir(song, vp, *countptr);
499 else
500 return rs_vib_loop(song, vp, *countptr);
501 }
502 else
503 return rs_vib_plain(song, v, countptr);
504 }
505 else
506 {
507 if ((modes & MODES_LOOPING) &&
508 ((modes & MODES_ENVELOPE) ||
509 (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED)))
510 {
511 if (modes & MODES_PINGPONG)
512 return rs_bidir(song, vp, *countptr);
513 else
514 return rs_loop(song, vp, *countptr);
515 }
516 else
517 return rs_plain(song, v, countptr);
518 }
519 }
520
521 void pre_resample(MidiSong *song, Sample *sp)
522 {
523 double a, xdiff;
524 Sint32 incr, ofs, newlen, count;
525 Sint16 *newdata, *dest, *src = (Sint16 *) sp->data, *vptr;
526 Sint32 v, v1, v2, v3, v4, v5, i;
527 #ifdef DEBUG_CHATTER
528 static const char note_name[12][3] = {
529 "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
530 };
531
532 SNDDBG((" * pre-resampling for note %d (%s%d)\n",
533 sp->note_to_use,
534 note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12));
535 #endif
536
537 a = ((double) (sp->root_freq) * song->rate) /
538 ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]);
539 if(sp->data_length * a >= 0x7fffffffL) { /* Too large to compute */
540 SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use));
541 return;
542 }
543
544 newlen = (Sint32)(sp->data_length * a);
545 count = (newlen >> FRACTION_BITS) - 1;
546 ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count;
547
548 if((double)newlen + incr >= 0x7fffffffL) { /* Too large to compute */
549 SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use));
550 return;
551 }
552
553 dest = newdata = (Sint16 *) SDL_malloc((newlen >> (FRACTION_BITS - 1)) + 2);
554 if (!dest) {
555 song->oom = 1;
556 return;
557 }
558
559 if (--count)
560 *dest++ = src[0];
561
562 /* Since we're pre-processing and this doesn't have to be done in
563 real-time, we go ahead and do the full sliding cubic interpolation. */
564 count--;
565 for(i = 0; i < count; i++)
566 {
567 vptr = src + (ofs >> FRACTION_BITS);
568 v1 = ((vptr>=src+1)? *(vptr - 1):0);
569 v2 = *vptr;
570 v3 = *(vptr + 1);
571 v4 = *(vptr + 2);
572 v5 = v2 - v3;
573 xdiff = TIM_FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS);
574 v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 +
575 xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1))));
576 *dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v));
577 ofs += incr;
578 }
579
580 if (ofs & FRACTION_MASK)
581 {
582 v1 = src[ofs >> FRACTION_BITS];
583 v2 = src[(ofs >> FRACTION_BITS) + 1];
584 *dest++ = (Sint16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS));
585 }
586 else
587 *dest++ = src[ofs >> FRACTION_BITS];
588
589 *dest = *(dest - 1) / 2;
590 ++dest;
591 *dest = *(dest - 1) / 2;
592
593 sp->data_length = newlen;
594 sp->loop_start = (Sint32)(sp->loop_start * a);
595 sp->loop_end = (Sint32)(sp->loop_end * a);
596 SDL_free(sp->data);
597 sp->data = (sample_t *) newdata;
598 sp->sample_rate = 0;
599 }
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 resample.h
8 */
9
10 #ifndef TIMIDITY_RESAMPLE_H
11 #define TIMIDITY_RESAMPLE_H
12
13 #define resample_voice TIMI_NAMESPACE(resample_voice)
14 #define pre_resample TIMI_NAMESPACE(pre_resample)
15
16 extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr);
17 extern void pre_resample(MidiSong *song, Sample *sp);
18
19 #endif /* TIMIDITY_RESAMPLE_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6 */
7
8 #include "SDL.h"
9
10 #include "common.h"
11 #include "tables.h"
12
13 const Sint32 freq_table[128] =
14 {
15 8176, 8662, 9177, 9723,
16 10301, 10913, 11562, 12250,
17 12978, 13750, 14568, 15434,
18
19 16352, 17324, 18354, 19445,
20 20602, 21827, 23125, 24500,
21 25957, 27500, 29135, 30868,
22
23 32703, 34648, 36708, 38891,
24 41203, 43654, 46249, 48999,
25 51913, 55000, 58270, 61735,
26
27 65406, 69296, 73416, 77782,
28 82407, 87307, 92499, 97999,
29 103826, 110000, 116541, 123471,
30
31 130813, 138591, 146832, 155563,
32 164814, 174614, 184997, 195998,
33 207652, 220000, 233082, 246942,
34
35 261626, 277183, 293665, 311127,
36 329628, 349228, 369994, 391995,
37 415305, 440000, 466164, 493883,
38
39 523251, 554365, 587330, 622254,
40 659255, 698456, 739989, 783991,
41 830609, 880000, 932328, 987767,
42
43 1046502, 1108731, 1174659, 1244508,
44 1318510, 1396913, 1479978, 1567982,
45 1661219, 1760000, 1864655, 1975533,
46
47 2093005, 2217461, 2349318, 2489016,
48 2637020, 2793826, 2959955, 3135963,
49 3322438, 3520000, 3729310, 3951066,
50
51 4186009, 4434922, 4698636, 4978032,
52 5274041, 5587652, 5919911, 6271927,
53 6644875, 7040000, 7458620, 7902133,
54
55 8372018, 8869844, 9397273, 9956063,
56 10548082, 11175303, 11839822, 12543854
57 };
58
59 /* v=2.^((x/127-1) * 6) */
60 const double vol_table[128] =
61 {
62 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438,
63 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921,
64 0.020304632921913132, 0.020980557880044631, 0.021678983838355849, 0.02240065983711079,
65 0.023146359851523596, 0.023916883621822989, 0.024713057510949051, 0.025535735390801884,
66 0.026385799557992876, 0.027264161680080529, 0.028171763773305786, 0.029109579212875332,
67 0.030078613776876421, 0.031079906724942836, 0.032114531912828696, 0.033183598944085631,
68 0.034288254360078256, 0.035429682869614412, 0.036609108619508737, 0.037827796507442342,
69 0.039087053538526394, 0.040388230227024875, 0.041732722044739302, 0.043121970917609151,
70 0.044557466772132896, 0.046040749133268132, 0.047573408775524545, 0.049157089429020417,
71 0.050793489542332405, 0.05248436410402918, 0.054231526524842463, 0.056036850582493913,
72 0.057902272431264008, 0.059829792678457581, 0.061821478529993396, 0.063879466007418645,
73 0.066005962238725971, 0.068203247825430205, 0.070473679288442961, 0.072819691595368496,
74 0.075243800771931268, 0.077748606600335793, 0.080336795407452768, 0.083011142945821612,
75 0.085774517370559328, 0.088629882315368294, 0.091580300070941839, 0.094628934869176312,
76 0.097779056276712184, 0.10103404270144323, 0.1043973850157546, 0.1078726903003755,
77 0.11146368571286204, 0.11517422248485852, 0.11900828005242428, 0.12296997032385605,
78 0.12706354208958254, 0.13129338557886089, 0.13566403716816194, 0.14018018424629392,
79 0.14484667024148207, 0.14966849981579558, 0.15465084423249356, 0.15979904690204472,
80 0.16511862911277009, 0.17061529595225433, 0.17629494242587571, 0.18216365977901747,
81 0.18822774202974024, 0.19449369271892172, 0.20096823188510385, 0.20765830327152621,
82 0.21457108177307616, 0.22171398113114205, 0.2290946618846218, 0.23672103958561411,
83 0.2446012932886038, 0.25274387432224471, 0.26115751535314891, 0.26985123975140174,
84 0.27883437126784744, 0.28811654403352405, 0.29770771289197112, 0.30761816407549192,
85 0.31785852623682015, 0.32843978184802081, 0.33937327897885317, 0.3506707434672246,
86 0.36234429149478936, 0.37440644258117928, 0.38687013301080181, 0.39974872970660535,
87 0.41305604456569134, 0.42680634927214656, 0.44101439060298442, 0.45569540624360722,
88 0.47086514112975281, 0.48653986433345225, 0.50273638651110641, 0.51947207793239625,
89 0.53676488710936021, 0.55463336004561792, 0.57309666012638816, 0.59217458867062556,
90 0.61188760616732485, 0.63225685421876243, 0.65330417821421161, 0.67505215075844849,
91 0.69752409588017272, 0.72074411404630734, 0.74473710800900605, 0.76952880951308478,
92 0.79514580689252357, 0.82161557358563286, 0.84896649759946774, 0.87722791195508854,
93 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1
94 };
95
96 const double bend_fine[256] = {
97 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664,
98 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274,
99 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551,
100 1.0027112750502025, 1.0029375461797159, 1.0031638683694153, 1.0033902416308227,
101 1.0036166659754628, 1.0038431414148634, 1.0040696679605541, 1.0042962456240678,
102 1.0045228744169397, 1.0047495543507072, 1.0049762854369111, 1.0052030676870944,
103 1.0054299011128027, 1.0056567857255843, 1.00588372153699, 1.006110708558573,
104 1.0063377468018897, 1.0065648362784985, 1.0067919769999607, 1.0070191689778405,
105 1.0072464122237039, 1.0074737067491204, 1.0077010525656616, 1.0079284496849015,
106 1.0081558981184175, 1.008383397877789, 1.008610948974598, 1.0088385514204294,
107 1.0090662052268706, 1.0092939104055114, 1.0095216669679448, 1.0097494749257656,
108 1.009977334290572, 1.0102052450739643, 1.0104332072875455, 1.0106612209429215,
109 1.0108892860517005, 1.0111174026254934, 1.0113455706759138, 1.0115737902145781,
110 1.0118020612531047, 1.0120303838031153, 1.0122587578762337, 1.012487183484087,
111 1.0127156606383041, 1.0129441893505169, 1.0131727696323602, 1.0134014014954713,
112 1.0136300849514894, 1.0138588200120575, 1.0140876066888203, 1.0143164449934257,
113 1.0145453349375237, 1.0147742765327674, 1.0150032697908125, 1.0152323147233171,
114 1.015461411341942, 1.0156905596583505, 1.0159197596842091, 1.0161490114311862,
115 1.0163783149109531, 1.0166076701351838, 1.0168370771155553, 1.0170665358637463,
116 1.0172960463914391, 1.0175256087103179, 1.0177552228320703, 1.0179848887683858,
117 1.0182146065309567, 1.0184443761314785, 1.0186741975816487, 1.0189040708931674,
118 1.0191339960777379, 1.0193639731470658, 1.0195940021128593, 1.0198240829868295,
119 1.0200542157806898, 1.0202844005061564, 1.0205146371749483, 1.0207449257987866,
120 1.0209752663893958, 1.0212056589585028, 1.0214361035178368, 1.0216666000791297,
121 1.0218971486541166, 1.0221277492545349, 1.0223584018921241, 1.0225891065786274,
122 1.0228198633257899, 1.0230506721453596, 1.023281533049087, 1.0235124460487257,
123 1.0237434111560313, 1.0239744283827625, 1.0242054977406807, 1.0244366192415495,
124 1.0246677928971357, 1.0248990187192082, 1.025130296719539, 1.0253616269099028,
125 1.0255930093020766, 1.0258244439078401, 1.0260559307389761, 1.0262874698072693,
126 1.0265190611245079, 1.0267507047024822, 1.0269824005529853, 1.027214148687813,
127 1.0274459491187637, 1.0276778018576387, 1.0279097069162415, 1.0281416643063788,
128 1.0283736740398595, 1.0286057361284953, 1.0288378505841009, 1.0290700174184932,
129 1.0293022366434921, 1.0295345082709197, 1.0297668323126017, 1.0299992087803651,
130 1.030231637686041, 1.0304641190414621, 1.0306966528584645, 1.0309292391488862,
131 1.0311618779245688, 1.0313945691973556, 1.0316273129790936, 1.0318601092816313,
132 1.0320929581168212, 1.0323258594965172, 1.0325588134325767, 1.0327918199368598,
133 1.0330248790212284, 1.0332579906975481, 1.0334911549776868, 1.033724371873515,
134 1.0339576413969056, 1.0341909635597348, 1.0344243383738811, 1.0346577658512259,
135 1.034891246003653, 1.0351247788430489, 1.0353583643813031, 1.0355920026303078,
136 1.0358256936019572, 1.0360594373081489, 1.0362932337607829, 1.0365270829717617,
137 1.0367609849529913, 1.0369949397163791, 1.0372289472738365, 1.0374630076372766,
138 1.0376971208186156, 1.0379312868297725, 1.0381655056826686, 1.0383997773892284,
139 1.0386341019613787, 1.0388684794110492, 1.0391029097501721, 1.0393373929906822,
140 1.0395719291445176, 1.0398065182236185, 1.0400411602399278, 1.0402758552053915,
141 1.0405106031319582, 1.0407454040315787, 1.0409802579162071, 1.0412151647977996,
142 1.0414501246883161, 1.0416851375997183, 1.0419202035439705, 1.0421553225330404,
143 1.042390494578898, 1.042625719693516, 1.0428609978888699, 1.043096329176938,
144 1.0433317135697009, 1.0435671510791424, 1.0438026417172486, 1.0440381854960086,
145 1.0442737824274138, 1.044509432523459, 1.044745135796141, 1.0449808922574599,
146 1.0452167019194181, 1.0454525647940205, 1.0456884808932754, 1.0459244502291931,
147 1.0461604728137874, 1.0463965486590741, 1.046632677777072, 1.0468688601798024,
148 1.0471050958792898, 1.047341384887561, 1.0475777272166455, 1.047814122878576,
149 1.048050571885387, 1.0482870742491166, 1.0485236299818055, 1.0487602390954964,
150 1.0489969016022356, 1.0492336175140715, 1.0494703868430555, 1.0497072096012419,
151 1.0499440858006872, 1.0501810154534512, 1.050417998571596, 1.0506550351671864,
152 1.0508921252522903, 1.0511292688389782, 1.0513664659393229, 1.0516037165654004,
153 1.0518410207292894, 1.0520783784430709, 1.0523157897188296, 1.0525532545686513,
154 1.0527907730046264, 1.0530283450388465, 1.0532659706834067, 1.0535036499504049,
155 1.0537413828519411, 1.0539791694001188, 1.0542170096070436, 1.0544549034848243,
156 1.0546928510455722, 1.0549308523014012, 1.0551689072644284, 1.0554070159467728,
157 1.0556451783605572, 1.0558833945179062, 1.0561216644309479, 1.0563599881118126,
158 1.0565983655726334, 1.0568367968255465, 1.0570752818826903, 1.0573138207562065,
159 1.057552413458239, 1.0577910600009348, 1.0580297603964437, 1.058268514656918,
160 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123
161 };
162
163 const double bend_coarse[128] = {
164 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721,
165 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815,
166 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868,
167 2, 2.1189261887185906, 2.244924096618746, 2.3784142300054421,
168 2.5198420997897464, 2.6696797083400687, 2.8284271247461903, 2.996614153753363,
169 3.1748021039363992, 3.363585661014858, 3.5635948725613571, 3.7754972507267741,
170 4, 4.2378523774371812, 4.4898481932374912, 4.7568284600108841,
171 5.0396841995794928, 5.3393594166801366, 5.6568542494923806, 5.993228307506727,
172 6.3496042078727974, 6.727171322029716, 7.1271897451227151, 7.5509945014535473,
173 8, 8.4757047548743625, 8.9796963864749824, 9.5136569200217682,
174 10.079368399158986, 10.678718833360273, 11.313708498984761, 11.986456615013454,
175 12.699208415745595, 13.454342644059432, 14.25437949024543, 15.101989002907095,
176 16, 16.951409509748721, 17.959392772949972, 19.027313840043536,
177 20.158736798317967, 21.357437666720553, 22.627416997969522, 23.972913230026901,
178 25.398416831491197, 26.908685288118864, 28.508758980490853, 30.203978005814196,
179 32, 33.902819019497443, 35.918785545899944, 38.054627680087073,
180 40.317473596635935, 42.714875333441107, 45.254833995939045, 47.945826460053802,
181 50.796833662982394, 53.817370576237728, 57.017517960981706, 60.407956011628393,
182 64, 67.805638038994886, 71.837571091799887, 76.109255360174146,
183 80.63494719327187, 85.429750666882214, 90.509667991878089, 95.891652920107603,
184 101.59366732596479, 107.63474115247546, 114.03503592196341, 120.81591202325679,
185 128, 135.61127607798977, 143.67514218359977, 152.21851072034829,
186 161.26989438654374, 170.85950133376443, 181.01933598375618, 191.78330584021521,
187 203.18733465192958, 215.26948230495091, 228.07007184392683, 241.63182404651357,
188 256, 271.22255215597971, 287.35028436719938, 304.43702144069658,
189 322.53978877308765, 341.71900266752868, 362.03867196751236, 383.56661168043064,
190 406.37466930385892, 430.53896460990183, 456.14014368785394, 483.26364809302686,
191 512, 542.44510431195943, 574.70056873439876, 608.87404288139317,
192 645.0795775461753, 683.43800533505737, 724.07734393502471, 767.13322336086128,
193 812.74933860771785, 861.07792921980365, 912.28028737570787, 966.52729618605372,
194 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863,
195 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226
196 };
197
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6
7 tables.h
8 */
9
10 #ifndef TIMIDITY_TABLES_H
11 #define TIMIDITY_TABLES_H
12
13 #if defined(HAVE_LIBC) && defined(__WATCOMC__) /* Watcom has issues... */
14 #define SDL_sin sin
15 #endif
16 #define timi_sine(x) (SDL_sin((2*PI/1024.0) * (x)))
17
18 #define SINE_CYCLE_LENGTH 1024
19
20 #define freq_table TIMI_NAMESPACE(freq_table)
21 #define vol_table TIMI_NAMESPACE(vol_table)
22 #define bend_fine TIMI_NAMESPACE(bend_fine)
23 #define bend_coarse TIMI_NAMESPACE(bend_coarse)
24
25 extern const Sint32 freq_table[];
26 extern const double vol_table[];
27 extern const double bend_fine[];
28 extern const double bend_coarse[];
29
30 #endif /* TIMIDITY_TABLES_H */
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6 */
7
8 #include "SDL.h"
9 #include "../../utils.h" /* for SDL_strtokr() */
10
11 #include "timidity.h"
12
13 #include "options.h"
14 #include "common.h"
15 #include "instrum.h"
16 #include "playmidi.h"
17 #include "readmidi.h"
18 #include "output.h"
19
20 #include "tables.h"
21
22 static ToneBank *master_tonebank[MAXBANK], *master_drumset[MAXBANK];
23
24 static char def_instr_name[256] = "";
25
26 #define MAXWORDS 10
27 #define MAX_RCFCOUNT 50
28
29 /* Quick-and-dirty fgets() replacement. */
30
31 static char *RWgets(SDL_RWops *rw, char *s, int size)
32 {
33 int num_read = 0;
34 char *p = s;
35
36 --size;/* so that we nul terminate properly */
37
38 for (; num_read < size; ++p)
39 {
40 if (SDL_RWread(rw, p, 1, 1) != 1)
41 break;
42
43 num_read++;
44
45 /* Unlike fgets(), don't store newline. Under Windows/DOS we'll
46 * probably get an extra blank line for every line that's being
47 * read, but that should be ok.
48 */
49 if (*p == '\n' || *p == '\r')
50 {
51 *p = '\0';
52 return s;
53 }
54 }
55
56 *p = '\0';
57
58 return (num_read != 0) ? s : NULL;
59 }
60
61 static int read_config_file(const char *name, int rcf_count)
62 {
63 SDL_RWops *rw;
64 char tmp[1024];
65 char *w[MAXWORDS], *cp;
66 char *endp;
67 ToneBank *bank;
68 int i, j, k, line, r, words;
69
70 if (rcf_count >= MAX_RCFCOUNT) {
71 SNDDBG(("Probable source loop in configuration files\n"));
72 return -1;
73 }
74
75 if (!(rw=timi_openfile(name)))
76 return -1;
77
78 bank = NULL;
79 line = 0;
80 r = -1; /* start by assuming failure, */
81
82 while (RWgets(rw, tmp, sizeof(tmp)))
83 {
84 line++;
85 words=0;
86 w[0]=SDL_strtokr(tmp, " \t\240", &endp);
87 if (!w[0]) continue;
88
89 /* Originally the TiMidity++ extensions were prefixed like this */
90 if (SDL_strcmp(w[0], "#extension") == 0)
91 {
92 w[0]=SDL_strtokr(0, " \t\240", &endp);
93 if (!w[0]) continue;
94 }
95
96 if (*w[0] == '#')
97 continue;
98
99 while (words < MAXWORDS - 1) /* -1 : next arg */
100 {
101 while (*endp == ' ' || *endp == '\t' || *endp == '\240')
102 endp++;
103 if (*endp == '\0' || *endp == '#')
104 break;
105 if (*endp == '"' || *endp == '\'') /* quoted string */
106 {
107 char *terminator;
108 if ((terminator = SDL_strchr(endp + 1, *endp)) != NULL) /* terminated */
109 {
110 if (terminator[1] == ' ' || terminator[1] == '\t' || terminator[1] == '\240' || terminator[1] == '\0')
111 {
112 char *extraQuote;
113 if ((extraQuote = SDL_strchr(endp + 1, *endp == '"' ? '\'' : '"')) != NULL && extraQuote < terminator)
114 {
115 SNDDBG(("%s: line %d: Quote characters are not allowed inside a quoted string", name, line));
116 goto fail;
117 }
118
119 w[++words] = endp + 1;
120 endp = terminator + 1;
121 *terminator = '\0';
122 }
123 else /* no space after quoted string */
124 {
125 SNDDBG(("%s: line %d: There must be at least one whitespace between string terminator (%c) and the next parameter", name, line, *endp));
126 goto fail;
127 }
128 }
129 else /* not terminated */
130 {
131 SNDDBG(("%s: line %d: The quoted string is not terminated", name, line));
132 goto fail;
133 }
134 }
135 else /* not quoted string */
136 {
137 w[++words] = endp;
138 while (!(*endp == ' ' || *endp == '\t' || *endp == '\240' || *endp == '\0'))
139 {
140 if (*endp == '"' || *endp == '\'') /* no space before quoted string */
141 {
142 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));
143 goto fail;
144 }
145 endp++;
146 }
147 if (*endp != '\0') /* unless at the end-of-string (i.e. EOF) */
148 {
149 *endp = '\0'; /* terminate the token */
150 endp++;
151 }
152 }
153 }
154 w[++words] = NULL;
155
156 /* TiMidity++ adds a number of extensions to the config file format.
157 * Many of them are completely irrelevant to SDL_sound, but at least
158 * we shouldn't choke on them.
159 *
160 * Unfortunately the documentation for these extensions is often quite
161 * vague, gramatically strange or completely absent.
162 */
163 if (!SDL_strcmp(w[0], "comm") /* "comm" program second */ ||
164 !SDL_strcmp(w[0], "HTTPproxy") /* "HTTPproxy" hostname:port */ ||
165 !SDL_strcmp(w[0], "FTPproxy") /* "FTPproxy" hostname:port */ ||
166 !SDL_strcmp(w[0], "mailaddr") /* "mailaddr" your-mail-address */ ||
167 !SDL_strcmp(w[0], "opt") /* "opt" timidity-options */ )
168 {
169 /* + "comm" sets some kind of comment -- the documentation is too
170 * vague for me to understand at this time.
171 * + "HTTPproxy", "FTPproxy" and "mailaddr" are for reading data
172 * over a network, rather than from the file system.
173 * + "opt" specifies default options for TiMidity++.
174 *
175 * Quite useless for us, so they can safely remain no-ops.
176 */
177 }
178 else if (!SDL_strcmp(w[0], "timeout")) /* "timeout" program second */
179 {
180 /* Specifies a timeout value of the program. A number of seconds
181 * before TiMidity kills the note. No urgent need for it.
182 */
183 SNDDBG(("FIXME: Implement \"timeout\" in TiMidity config.\n"));
184 }
185 else if (!SDL_strcmp(w[0], "copydrumset") /* "copydrumset" drumset */ ||
186 !SDL_strcmp(w[0], "copybank")) /* "copybank" bank */
187 {
188 /* Copies all the settings of the specified drumset or bank to
189 * the current drumset or bank. May be useful later, but not a
190 * high priority.
191 */
192 SNDDBG(("FIXME: Implement \"%s\" in TiMidity config.\n", w[0]));
193 }
194 else if (!SDL_strcmp(w[0], "undef")) /* "undef" progno */
195 {
196 /* Undefines the tone "progno" of the current tone bank (or
197 * drum set?). Not a high priority.
198 */
199 SNDDBG(("FIXME: Implement \"undef\" in TiMidity config.\n"));
200 }
201 else if (!SDL_strcmp(w[0], "altassign")) /* "altassign" prog1 prog2 ... */
202 {
203 /* Sets the alternate assign for drum set. Whatever that's
204 * supposed to mean.
205 */
206 SNDDBG(("FIXME: Implement \"altassign\" in TiMidity config.\n"));
207 }
208 else if (!SDL_strcmp(w[0], "soundfont") ||
209 !SDL_strcmp(w[0], "font"))
210 {
211 /* "soundfont" sf_file "remove"
212 * "soundfont" sf_file ["order=" order] ["cutoff=" cutoff]
213 * ["reso=" reso] ["amp=" amp]
214 * "font" "exclude" bank preset keynote
215 * "font" "order" order bank preset keynote
216 */
217 SNDDBG(("FIXME: Implmement \"%s\" in TiMidity config.\n", w[0]));
218 }
219 else if (!SDL_strcmp(w[0], "progbase"))
220 {
221 /* The documentation for this makes absolutely no sense to me, but
222 * apparently it sets some sort of base offset for tone numbers.
223 */
224 SNDDBG(("FIXME: Implement \"progbase\" in TiMidity config.\n"));
225 }
226 else if (!SDL_strcmp(w[0], "map")) /* "map" name set1 elem1 set2 elem2 */
227 {
228 /* This one is used by the "eawpats". Looks like it's used
229 * for remapping one instrument to another somehow.
230 */
231 SNDDBG(("FIXME: Implement \"map\" in TiMidity config.\n"));
232 }
233
234 /* Standard TiMidity config */
235 else if (!SDL_strcmp(w[0], "dir"))
236 {
237 if (words < 2)
238 {
239 SNDDBG(("%s: line %d: No directory given\n", name, line));
240 goto fail;
241 }
242 for (i=1; i<words; i++) {
243 if (timi_add_pathlist(w[i], SDL_strlen(w[i])) < 0)
244 goto fail;
245 }
246 }
247 else if (!SDL_strcmp(w[0], "source"))
248 {
249 if (words < 2)
250 {
251 SNDDBG(("%s: line %d: No file name given\n", name, line));
252 goto fail;
253 }
254 for (i=1; i<words; i++)
255 {
256 r = read_config_file(w[i], rcf_count + 1);
257 if (r != 0)
258 goto fail;
259 }
260 r = -1; /* not finished yet, */
261 }
262 else if (!SDL_strcmp(w[0], "default"))
263 {
264 if (words != 2)
265 {
266 SNDDBG(("%s: line %d: Must specify exactly one patch name\n",
267 name, line));
268 goto fail;
269 }
270 SDL_strlcpy(def_instr_name, w[1], 256);
271 }
272 else if (!SDL_strcmp(w[0], "drumset"))
273 {
274 if (words < 2)
275 {
276 SNDDBG(("%s: line %d: No drum set number given\n", name, line));
277 goto fail;
278 }
279 i=SDL_atoi(w[1]);
280 if (i<0 || i>(MAXBANK-1))
281 {
282 SNDDBG(("%s: line %d: Drum set must be between 0 and %d\n",
283 name, line, MAXBANK-1));
284 goto fail;
285 }
286 if (!master_drumset[i])
287 {
288 master_drumset[i] = SDL_calloc(1, sizeof(ToneBank));
289 if (!master_drumset[i]) goto fail;
290 master_drumset[i]->tone = SDL_calloc(128, sizeof(ToneBankElement));
291 if (!master_drumset[i]->tone) goto fail;
292 }
293 bank=master_drumset[i];
294 }
295 else if (!SDL_strcmp(w[0], "bank"))
296 {
297 if (words < 2)
298 {
299 SNDDBG(("%s: line %d: No bank number given\n", name, line));
300 goto fail;
301 }
302 i=SDL_atoi(w[1]);
303 if (i<0 || i>(MAXBANK-1))
304 {
305 SNDDBG(("%s: line %d: Tone bank must be between 0 and %d\n",
306 name, line, MAXBANK-1));
307 goto fail;
308 }
309 if (!master_tonebank[i])
310 {
311 master_tonebank[i] = SDL_calloc(1, sizeof(ToneBank));
312 if (!master_tonebank[i]) goto fail;
313 master_tonebank[i]->tone = SDL_calloc(128, sizeof(ToneBankElement));
314 if (!master_tonebank[i]->tone) goto fail;
315 }
316 bank=master_tonebank[i];
317 }
318 else
319 {
320 size_t sz;
321 if ((words < 2) || (*w[0] < '0' || *w[0] > '9'))
322 {
323 SNDDBG(("%s: line %d: syntax error\n", name, line));
324 goto fail;
325 }
326 i=SDL_atoi(w[0]);
327 if (i<0 || i>127)
328 {
329 SNDDBG(("%s: line %d: Program must be between 0 and 127\n",
330 name, line));
331 goto fail;
332 }
333 if (!bank)
334 {
335 SNDDBG(("%s: line %d: Must specify tone bank or drum set before assignment\n",
336 name, line));
337 goto fail;
338 }
339 SDL_free(bank->tone[i].name);
340 sz = SDL_strlen(w[1])+1;
341 bank->tone[i].name = SDL_malloc(sz);
342 if (!bank->tone[i].name) goto fail;
343 SDL_memcpy(bank->tone[i].name,w[1],sz);
344 bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan=
345 bank->tone[i].strip_loop=bank->tone[i].strip_envelope=
346 bank->tone[i].strip_tail=-1;
347
348 for (j=2; j<words; j++)
349 {
350 if (!(cp=SDL_strchr(w[j], '=')))
351 {
352 SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j]));
353 goto fail;
354 }
355 *cp++=0;
356 if (!SDL_strcmp(w[j], "amp"))
357 {
358 k=SDL_atoi(cp);
359 if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9'))
360 {
361 SNDDBG(("%s: line %d: amplification must be between 0 and %d\n",
362 name, line, MAX_AMPLIFICATION));
363 goto fail;
364 }
365 bank->tone[i].amp=k;
366 }
367 else if (!SDL_strcmp(w[j], "note"))
368 {
369 k=SDL_atoi(cp);
370 if ((k<0 || k>127) || (*cp < '0' || *cp > '9'))
371 {
372 SNDDBG(("%s: line %d: note must be between 0 and 127\n",
373 name, line));
374 goto fail;
375 }
376 bank->tone[i].note=k;
377 }
378 else if (!SDL_strcmp(w[j], "pan"))
379 {
380 if (!SDL_strcmp(cp, "center"))
381 k=64;
382 else if (!SDL_strcmp(cp, "left"))
383 k=0;
384 else if (!SDL_strcmp(cp, "right"))
385 k=127;
386 else
387 k=((SDL_atoi(cp)+100) * 100) / 157;
388 if ((k<0 || k>127) || (k==0 && *cp!='-' && (*cp < '0' || *cp > '9')))
389 {
390 SNDDBG(("%s: line %d: panning must be left, right, center, or between -100 and 100\n",
391 name, line));
392 goto fail;
393 }
394 bank->tone[i].pan=k;
395 }
396 else if (!SDL_strcmp(w[j], "keep"))
397 {
398 if (!SDL_strcmp(cp, "env"))
399 bank->tone[i].strip_envelope=0;
400 else if (!SDL_strcmp(cp, "loop"))
401 bank->tone[i].strip_loop=0;
402 else
403 {
404 SNDDBG(("%s: line %d: keep must be env or loop\n", name, line));
405 goto fail;
406 }
407 }
408 else if (!SDL_strcmp(w[j], "strip"))
409 {
410 if (!SDL_strcmp(cp, "env"))
411 bank->tone[i].strip_envelope=1;
412 else if (!SDL_strcmp(cp, "loop"))
413 bank->tone[i].strip_loop=1;
414 else if (!SDL_strcmp(cp, "tail"))
415 bank->tone[i].strip_tail=1;
416 else
417 {
418 SNDDBG(("%s: line %d: strip must be env, loop, or tail\n",
419 name, line));
420 goto fail;
421 }
422 }
423 else
424 {
425 SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j]));
426 goto fail;
427 }
428 }
429 }
430 }
431
432 r = 0; /* we're good. */
433 fail:
434 SDL_RWclose(rw);
435 return r;
436 }
437
438 #if defined(_WIN32)||defined(__CYGWIN__)||defined(__OS2__)
439 /* FIXME: What about C:FOO ? */
440 static SDL_INLINE char *get_last_dirsep (const char *p) {
441 char *p1 = SDL_strrchr(p, '/');
442 char *p2 = SDL_strrchr(p, '\\');
443 if (!p1) return p2;
444 if (!p2) return p1;
445 return (p1 > p2)? p1 : p2;
446 }
447 #else /* assumed UNIX-ish : */
448 static SDL_INLINE char *get_last_dirsep (const char *p) {
449 return SDL_strrchr(p, '/');
450 }
451 #endif
452
453 static int init_alloc_banks(void)
454 {
455 /* Allocate memory for the standard tonebank and drumset */
456 master_tonebank[0] = SDL_calloc(1, sizeof(ToneBank));
457 if (!master_tonebank[0]) goto _nomem;
458 master_tonebank[0]->tone = SDL_calloc(128, sizeof(ToneBankElement));
459 if (!master_tonebank[0]->tone) goto _nomem;
460
461 master_drumset[0] = SDL_calloc(1, sizeof(ToneBank));
462 if (!master_drumset[0]) goto _nomem;
463 master_drumset[0]->tone = SDL_calloc(128, sizeof(ToneBankElement));
464 if (!master_drumset[0]->tone) goto _nomem;
465
466 return 0;
467 _nomem:
468 SNDDBG(("Out of memory\n"));
469 Timidity_Exit ();
470 return -2;
471 }
472
473 static int init_begin_config(const char *cf)
474 {
475 const char *p = get_last_dirsep(cf);
476 if (p != NULL)
477 return timi_add_pathlist(cf, p - cf + 1); /* including DIRSEP */
478 return 0;
479 }
480
481 static int init_with_config(const char *cf)
482 {
483 int rc = init_begin_config(cf);
484 if (rc != 0) {
485 Timidity_Exit ();
486 return rc;
487 }
488 rc = read_config_file(cf, 0);
489 if (rc != 0) {
490 Timidity_Exit ();
491 }
492 return rc;
493 }
494
495 int Timidity_Init_NoConfig(void)
496 {
497 master_tonebank[0] = NULL;
498 master_drumset[0] = NULL;
499 return init_alloc_banks();
500 }
501
502 int Timidity_Init(const char *config_file)
503 {
504 int rc = Timidity_Init_NoConfig();
505 if (rc != 0) {
506 return rc;
507 }
508 if (config_file == NULL || *config_file == '\0') {
509 return init_with_config(TIMIDITY_CFG);
510 }
511 return init_with_config(config_file);
512 }
513
514 static void do_song_load(SDL_RWops *rw, SDL_AudioSpec *audio, MidiSong **out)
515 {
516 MidiSong *song;
517 int i;
518
519 *out = NULL;
520 if (rw == NULL)
521 return;
522
523 /* Allocate memory for the song */
524 song = (MidiSong *)SDL_calloc(1, sizeof(*song));
525 if (song == NULL)
526 return;
527
528 for (i = 0; i < MAXBANK; i++)
529 {
530 if (master_tonebank[i]) {
531 song->tonebank[i] = SDL_calloc(1, sizeof(ToneBank));
532 if (!song->tonebank[i]) goto fail;
533 song->tonebank[i]->tone = master_tonebank[i]->tone;
534 }
535 if (master_drumset[i]) {
536 song->drumset[i] = SDL_calloc(1, sizeof(ToneBank));
537 if (!song->drumset[i]) goto fail;
538 song->drumset[i]->tone = master_drumset[i]->tone;
539 }
540 }
541
542 song->amplification = DEFAULT_AMPLIFICATION;
543 song->voices = DEFAULT_VOICES;
544 song->drumchannels = DEFAULT_DRUMCHANNELS;
545
546 song->rw = rw;
547
548 song->rate = audio->freq;
549 song->encoding = 0;
550 if ((audio->format & 0xFF) == 16)
551 song->encoding |= PE_16BIT;
552 else if ((audio->format & 0xFF) == 32)
553 song->encoding |= PE_32BIT;
554 if (audio->format & 0x8000)
555 song->encoding |= PE_SIGNED;
556 if (audio->channels == 1)
557 song->encoding |= PE_MONO;
558 else if (audio->channels > 2) {
559 SDL_SetError("Surround sound not supported");
560 goto fail;
561 }
562 switch (audio->format) {
563 case AUDIO_S8:
564 song->write = timi_s32tos8;
565 break;
566 case AUDIO_U8:
567 song->write = timi_s32tou8;
568 break;
569 case AUDIO_S16LSB:
570 song->write = timi_s32tos16l;
571 break;
572 case AUDIO_S16MSB:
573 song->write = timi_s32tos16b;
574 break;
575 case AUDIO_U16LSB:
576 song->write = timi_s32tou16l;
577 break;
578 case AUDIO_U16MSB:
579 song->write = timi_s32tou16b;
580 break;
581 case AUDIO_S32LSB:
582 song->write = timi_s32tos32l;
583 break;
584 case AUDIO_S32MSB:
585 song->write = timi_s32tos32b;
586 break;
587 case AUDIO_F32SYS:
588 song->write = timi_s32tof32;
589 break;
590 default:
591 SDL_SetError("Unsupported audio format");
592 goto fail;
593 }
594
595 song->buffer_size = audio->samples;
596 song->resample_buffer = SDL_malloc(audio->samples * sizeof(sample_t));
597 if (!song->resample_buffer) goto fail;
598 song->common_buffer = SDL_malloc(audio->samples * 2 * sizeof(Sint32));
599 if (!song->common_buffer) goto fail;
600
601 song->control_ratio = audio->freq / CONTROLS_PER_SECOND;
602 if (song->control_ratio < 1)
603 song->control_ratio = 1;
604 else if (song->control_ratio > MAX_CONTROL_RATIO)
605 song->control_ratio = MAX_CONTROL_RATIO;
606
607 song->lost_notes = 0;
608 song->cut_notes = 0;
609
610 song->events = read_midi_file(song, &(song->groomed_event_count),
611 &song->samples);
612
613 /* Make sure everything is okay */
614 if (!song->events)
615 goto fail;
616
617 song->default_instrument = NULL;
618 song->default_program = DEFAULT_PROGRAM;
619
620 if (*def_instr_name)
621 set_default_instrument(song, def_instr_name);
622
623 load_missing_instruments(song);
624
625 if (! song->oom)
626 *out = song;
627 else {
628 fail: Timidity_FreeSong(song);
629 }
630 }
631
632 MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio)
633 {
634 MidiSong *song;
635 do_song_load(rw, audio, &song);
636 return song;
637 }
638
639 void Timidity_FreeSong(MidiSong *song)
640 {
641 int i;
642
643 if (!song) return;
644
645 free_instruments(song);
646
647 for (i = 0; i < 128; i++) {
648 SDL_free(song->tonebank[i]);
649 SDL_free(song->drumset[i]);
650 }
651
652 SDL_free(song->common_buffer);
653 SDL_free(song->resample_buffer);
654 SDL_free(song->events);
655
656 SDL_free(song);
657 }
658
659 void Timidity_Exit(void)
660 {
661 int i, j;
662
663 for (i = 0; i < MAXBANK; i++) {
664 if (master_tonebank[i]) {
665 ToneBankElement *e = master_tonebank[i]->tone;
666 if (e != NULL) {
667 for (j = 0; j < 128; j++) {
668 SDL_free(e[j].name);
669 }
670 SDL_free(e);
671 }
672 SDL_free(master_tonebank[i]);
673 master_tonebank[i] = NULL;
674 }
675 if (master_drumset[i]) {
676 ToneBankElement *e = master_drumset[i]->tone;
677 if (e != NULL) {
678 for (j = 0; j < 128; j++) {
679 SDL_free(e[j].name);
680 }
681 SDL_free(e);
682 }
683 SDL_free(master_drumset[i]);
684 master_drumset[i] = NULL;
685 }
686 }
687
688 timi_free_pathlist();
689 }
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7 */
8
9 #ifndef TIMIDITY_H
10 #define TIMIDITY_H
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 typedef Sint16 sample_t;
16 typedef Sint32 final_volume_t;
17
18 #define VIBRATO_SAMPLE_INCREMENTS 32
19
20 /* Maximum polyphony. */
21 /* #define MAX_VOICES 48 */
22 #define MAX_VOICES 256
23 #define MAXCHAN 16
24 /* #define MAXCHAN 64 */
25 #define MAXBANK 128
26
27 typedef struct {
28 Sint32
29 loop_start, loop_end, data_length,
30 sample_rate, low_freq, high_freq, root_freq;
31 Sint32
32 envelope_rate[6], envelope_offset[6];
33 float
34 volume;
35 sample_t *data;
36 Sint32
37 tremolo_sweep_increment, tremolo_phase_increment,
38 vibrato_sweep_increment, vibrato_control_ratio;
39 Uint8
40 tremolo_depth, vibrato_depth,
41 modes;
42 Sint8
43 panning, note_to_use;
44 } Sample;
45
46 typedef struct {
47 int
48 bank, program, volume, sustain, panning, pitchbend, expression,
49 mono, /* one note only on this channel -- not implemented yet */
50 pitchsens;
51 /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
52 processor near you */
53 float
54 pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
55 } Channel;
56
57 typedef struct {
58 Uint8
59 status, channel, note, velocity;
60 Sample *sample;
61 Sint32
62 orig_frequency, frequency,
63 sample_offset, sample_increment,
64 envelope_volume, envelope_target, envelope_increment,
65 tremolo_sweep, tremolo_sweep_position,
66 tremolo_phase, tremolo_phase_increment,
67 vibrato_sweep, vibrato_sweep_position;
68
69 final_volume_t left_mix, right_mix;
70
71 float
72 left_amp, right_amp, tremolo_volume;
73 Sint32
74 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
75 int
76 vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
77 envelope_stage, control_counter, panning, panned;
78
79 } Voice;
80
81 typedef struct {
82 int samples;
83 Sample *sample;
84 } Instrument;
85
86 /* Shared data */
87 typedef struct {
88 char *name;
89 int note, amp, pan, strip_loop, strip_envelope, strip_tail;
90 } ToneBankElement;
91
92 typedef struct {
93 ToneBankElement *tone;
94 Instrument *instrument[128];
95 } ToneBank;
96
97 typedef struct {
98 Sint32 time;
99 Uint8 channel, type, a, b;
100 } MidiEvent;
101
102 typedef struct _MidiEventList {
103 MidiEvent event;
104 struct _MidiEventList *next;
105 } MidiEventList;
106
107 typedef struct {
108 int oom; /* malloc() failed */
109 int playing;
110 SDL_RWops *rw;
111 Sint32 rate;
112 Sint32 encoding;
113 float master_volume;
114 Sint32 amplification;
115 ToneBank *tonebank[MAXBANK];
116 ToneBank *drumset[MAXBANK];
117 Instrument *default_instrument;
118 int default_program;
119 void (*write)(void *dp, Sint32 *lp, Sint32 c);
120 int buffer_size;
121 sample_t *resample_buffer;
122 Sint32 *common_buffer;
123 Sint32 *buffer_pointer;
124 /* These would both fit into 32 bits, but they are often added in
125 large multiples, so it's simpler to have two roomy ints */
126 /* samples per MIDI delta-t */
127 Sint32 sample_increment;
128 Sint32 sample_correction;
129 Channel channel[MAXCHAN];
130 Voice voice[MAX_VOICES];
131 int voices;
132 Sint32 drumchannels;
133 Sint32 buffered_count;
134 Sint32 control_ratio;
135 Sint32 lost_notes;
136 Sint32 cut_notes;
137 Sint32 samples;
138 MidiEvent *events;
139 MidiEvent *current_event;
140 MidiEventList *evlist;
141 Sint32 current_sample;
142 Sint32 event_count;
143 Sint32 at;
144 Sint32 groomed_event_count;
145 } MidiSong;
146
147 /* Some of these are not defined in timidity.c but are here for convenience */
148
149 extern int Timidity_Init(const char *config_file);
150 extern int Timidity_Init_NoConfig(void);
151 extern void Timidity_SetVolume(MidiSong *song, int volume);
152 extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len);
153 extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio);
154 extern void Timidity_Start(MidiSong *song);
155 extern void Timidity_Seek(MidiSong *song, Uint32 ms);
156 extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */
157 extern Uint32 Timidity_GetSongTime(MidiSong *song); /* returns millseconds */
158 extern void Timidity_Stop(MidiSong *song);
159 extern int Timidity_IsActive(MidiSong *song);
160 extern void Timidity_FreeSong(MidiSong *song);
161 extern void Timidity_Exit(void);
162
163 #ifdef __cplusplus
164 }
165 #endif
166 #endif /* TIMIDITY_H */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some internally supported special effects that use SDL_mixer's
23 effect callback API. They are meant for speed over quality. :)
24 */
25
26 #include "SDL_endian.h"
27 #include "SDL_mixer.h"
28
29 #include "mixer.h"
30
31 #define MIX_INTERNAL_EFFECT__
32 #include "effects_internal.h"
33
34 /* profile code:
35 #include <sys/time.h>
36 #include <unistd.h>
37 struct timeval tv1;
38 struct timeval tv2;
39
40 gettimeofday(&tv1, NULL);
41
42 ... do your thing here ...
43
44 gettimeofday(&tv2, NULL);
45 printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
46 */
47
48
49 /*
50 * Positional effects...panning, distance attenuation, etc.
51 */
52
53 typedef struct _Eff_positionargs
54 {
55 volatile float left_f;
56 volatile float right_f;
57 volatile Uint8 left_u8;
58 volatile Uint8 right_u8;
59 volatile float left_rear_f;
60 volatile float right_rear_f;
61 volatile float center_f;
62 volatile float lfe_f;
63 volatile Uint8 left_rear_u8;
64 volatile Uint8 right_rear_u8;
65 volatile Uint8 center_u8;
66 volatile Uint8 lfe_u8;
67 volatile float distance_f;
68 volatile Uint8 distance_u8;
69 volatile Sint16 room_angle;
70 volatile int in_use;
71 volatile int channels;
72 } position_args;
73
74 static position_args **pos_args_array = NULL;
75 static position_args *pos_args_global = NULL;
76 static int position_channels = 0;
77
78 void _Eff_PositionDeinit(void)
79 {
80 int i;
81 for (i = 0; i < position_channels; i++) {
82 SDL_free(pos_args_array[i]);
83 }
84
85 position_channels = 0;
86
87 SDL_free(pos_args_global);
88 pos_args_global = NULL;
89 SDL_free(pos_args_array);
90 pos_args_array = NULL;
91 }
92
93
94 /* This just frees up the callback-specific data. */
95 static void SDLCALL _Eff_PositionDone(int channel, void *udata)
96 {
97 (void)udata;
98
99 if (channel < 0) {
100 if (pos_args_global != NULL) {
101 SDL_free(pos_args_global);
102 pos_args_global = NULL;
103 }
104 }
105 else if (pos_args_array[channel] != NULL) {
106 SDL_free(pos_args_array[channel]);
107 pos_args_array[channel] = NULL;
108 }
109 }
110
111 static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata)
112 {
113 volatile position_args *args = (volatile position_args *) udata;
114 Uint8 *ptr = (Uint8 *) stream;
115 int i;
116
117 (void)chan;
118
119 /*
120 * if there's only a mono channnel (the only way we wouldn't have
121 * a len divisible by 2 here), then left_f and right_f are always
122 * 1.0, and are therefore throwaways.
123 */
124 if (len % (int)sizeof(Uint16) != 0) {
125 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
126 ptr++;
127 len--;
128 }
129
130 if (args->room_angle == 180)
131 for (i = 0; i < len; i += sizeof (Uint8) * 2) {
132 /* must adjust the sample so that 0 is the center */
133 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
134 * args->right_f) * args->distance_f) + 128);
135 ptr++;
136 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
137 * args->left_f) * args->distance_f) + 128);
138 ptr++;
139 }
140 else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
141 /* must adjust the sample so that 0 is the center */
142 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
143 * args->left_f) * args->distance_f) + 128);
144 ptr++;
145 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
146 * args->right_f) * args->distance_f) + 128);
147 ptr++;
148 }
149 }
150
151 static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata)
152 {
153 volatile position_args *args = (volatile position_args *) udata;
154 Uint8 *ptr = (Uint8 *) stream;
155 int i;
156
157 (void)chan;
158
159 /*
160 * if there's only a mono channnel (the only way we wouldn't have
161 * a len divisible by 2 here), then left_f and right_f are always
162 * 1.0, and are therefore throwaways.
163 */
164 if (len % (int)sizeof(Uint16) != 0) {
165 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
166 ptr++;
167 len--;
168 }
169
170 if (args->room_angle == 0)
171 for (i = 0; i < len; i += sizeof (Uint8) * 4) {
172 /* must adjust the sample so that 0 is the center */
173 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
174 * args->left_f) * args->distance_f) + 128);
175 ptr++;
176 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
177 * args->right_f) * args->distance_f) + 128);
178 ptr++;
179 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
180 * args->left_rear_f) * args->distance_f) + 128);
181 ptr++;
182 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
183 * args->right_rear_f) * args->distance_f) + 128);
184 ptr++;
185 }
186 else if (args->room_angle == 90)
187 for (i = 0; i < len; i += sizeof (Uint8) * 4) {
188 /* must adjust the sample so that 0 is the center */
189 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
190 * args->right_f) * args->distance_f) + 128);
191 ptr++;
192 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
193 * args->right_rear_f) * args->distance_f) + 128);
194 ptr++;
195 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
196 * args->left_f) * args->distance_f) + 128);
197 ptr++;
198 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
199 * args->left_rear_f) * args->distance_f) + 128);
200 ptr++;
201 }
202 else if (args->room_angle == 180)
203 for (i = 0; i < len; i += sizeof (Uint8) * 4) {
204 /* must adjust the sample so that 0 is the center */
205 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
206 * args->right_rear_f) * args->distance_f) + 128);
207 ptr++;
208 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
209 * args->left_rear_f) * args->distance_f) + 128);
210 ptr++;
211 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
212 * args->right_f) * args->distance_f) + 128);
213 ptr++;
214 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
215 * args->left_f) * args->distance_f) + 128);
216 ptr++;
217 }
218 else if (args->room_angle == 270)
219 for (i = 0; i < len; i += sizeof (Uint8) * 4) {
220 /* must adjust the sample so that 0 is the center */
221 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
222 * args->left_rear_f) * args->distance_f) + 128);
223 ptr++;
224 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
225 * args->left_f) * args->distance_f) + 128);
226 ptr++;
227 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
228 * args->right_rear_f) * args->distance_f) + 128);
229 ptr++;
230 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
231 * args->right_f) * args->distance_f) + 128);
232 ptr++;
233 }
234 }
235
236 static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata)
237 {
238 volatile position_args *args = (volatile position_args *) udata;
239 Uint8 *ptr = (Uint8 *) stream;
240 int i;
241
242 (void)chan;
243 (void)len;
244
245 /*
246 * if there's only a mono channnel (the only way we wouldn't have
247 * a len divisible by 2 here), then left_f and right_f are always
248 * 1.0, and are therefore throwaways.
249 */
250 if (len % (int)sizeof(Uint16) != 0) {
251 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
252 ptr++;
253 len--;
254 }
255
256 if (args->room_angle == 0)
257 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
258 /* must adjust the sample so that 0 is the center */
259 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
260 * args->left_f) * args->distance_f) + 128);
261 ptr++;
262 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
263 * args->right_f) * args->distance_f) + 128);
264 ptr++;
265 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
266 * args->left_rear_f) * args->distance_f) + 128);
267 ptr++;
268 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
269 * args->right_rear_f) * args->distance_f) + 128);
270 ptr++;
271 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
272 * args->center_f) * args->distance_f) + 128);
273 ptr++;
274 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
275 * args->lfe_f) * args->distance_f) + 128);
276 ptr++;
277 }
278 else if (args->room_angle == 90)
279 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
280 /* must adjust the sample so that 0 is the center */
281 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
282 * args->right_f) * args->distance_f) + 128);
283 ptr++;
284 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
285 * args->right_rear_f) * args->distance_f) + 128);
286 ptr++;
287 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
288 * args->left_f) * args->distance_f) + 128);
289 ptr++;
290 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
291 * args->left_rear_f) * args->distance_f) + 128);
292 ptr++;
293 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
294 * args->right_rear_f) * args->distance_f/2) + 128)
295 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
296 * args->right_f) * args->distance_f/2) + 128);
297 ptr++;
298 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
299 * args->lfe_f) * args->distance_f) + 128);
300 ptr++;
301 }
302 else if (args->room_angle == 180)
303 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
304 /* must adjust the sample so that 0 is the center */
305 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
306 * args->right_rear_f) * args->distance_f) + 128);
307 ptr++;
308 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
309 * args->left_rear_f) * args->distance_f) + 128);
310 ptr++;
311 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
312 * args->right_f) * args->distance_f) + 128);
313 ptr++;
314 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
315 * args->left_f) * args->distance_f) + 128);
316 ptr++;
317 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
318 * args->right_rear_f) * args->distance_f/2) + 128)
319 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
320 * args->left_rear_f) * args->distance_f/2) + 128);
321 ptr++;
322 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
323 * args->lfe_f) * args->distance_f) + 128);
324 ptr++;
325 }
326 else if (args->room_angle == 270)
327 for (i = 0; i < len; i += sizeof (Uint8) * 6) {
328 /* must adjust the sample so that 0 is the center */
329 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
330 * args->left_rear_f) * args->distance_f) + 128);
331 ptr++;
332 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
333 * args->left_f) * args->distance_f) + 128);
334 ptr++;
335 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
336 * args->right_rear_f) * args->distance_f) + 128);
337 ptr++;
338 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
339 * args->right_f) * args->distance_f) + 128);
340 ptr++;
341 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
342 * args->left_f) * args->distance_f/2) + 128)
343 + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
344 * args->left_rear_f) * args->distance_f/2) + 128);
345 ptr++;
346 *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
347 * args->lfe_f) * args->distance_f) + 128);
348 ptr++;
349 }
350 }
351
352
353 /*
354 * This one runs about 10.1 times faster than the non-table version, with
355 * no loss in quality. It does, however, require 64k of memory for the
356 * lookup table. Also, this will only update position information once per
357 * call; the non-table version always checks the arguments for each sample,
358 * in case the user has called Mix_SetPanning() or whatnot again while this
359 * callback is running.
360 */
361 static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata)
362 {
363 volatile position_args *args = (volatile position_args *) udata;
364 Uint8 *ptr = (Uint8 *) stream;
365 Uint32 *p;
366 int i;
367 Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8);
368 Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8);
369 Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
370
371 (void)chan;
372
373 if (args->room_angle == 180) {
374 Uint8 *temp = l;
375 l = r;
376 r = temp;
377 }
378 /*
379 * if there's only a mono channnel, then l[] and r[] are always
380 * volume 255, and are therefore throwaways. Still, we have to
381 * be sure not to overrun the audio buffer...
382 */
383 while (len % (int)sizeof(Uint32) != 0) {
384 *ptr = d[l[*ptr]];
385 ptr++;
386 if (args->channels > 1) {
387 *ptr = d[r[*ptr]];
388 ptr++;
389 }
390 len -= args->channels;
391 }
392
393 p = (Uint32 *) ptr;
394
395 for (i = 0; i < len; i += sizeof (Uint32)) {
396 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
397 *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
398 (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
399 (d[l[(*p & 0x0000FF00) >> 8]] << 8) |
400 (d[r[(*p & 0x000000FF) ]] ) ;
401 #else
402 *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
403 (d[l[(*p & 0x00FF0000) >> 16]] << 16) |
404 (d[r[(*p & 0x0000FF00) >> 8]] << 8) |
405 (d[l[(*p & 0x000000FF) ]] ) ;
406 #endif
407 ++p;
408 }
409 }
410
411
412 static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata)
413 {
414 volatile position_args *args = (volatile position_args *) udata;
415 Sint8 *ptr = (Sint8 *) stream;
416 int i;
417
418 (void)chan;
419
420 /*
421 * if there's only a mono channnel (the only way we wouldn't have
422 * a len divisible by 2 here), then left_f and right_f are always
423 * 1.0, and are therefore throwaways.
424 */
425 if (len % (int)sizeof(Sint16) != 0) {
426 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
427 ptr++;
428 len--;
429 }
430
431 if (args->room_angle == 180)
432 for (i = 0; i < len; i += sizeof (Sint8) * 2) {
433 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
434 ptr++;
435 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
436 ptr++;
437 }
438 else
439 for (i = 0; i < len; i += sizeof (Sint8) * 2) {
440 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
441 ptr++;
442 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
443 ptr++;
444 }
445 }
446 static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata)
447 {
448 volatile position_args *args = (volatile position_args *) udata;
449 Sint8 *ptr = (Sint8 *) stream;
450 int i;
451
452 (void)chan;
453
454 /*
455 * if there's only a mono channnel (the only way we wouldn't have
456 * a len divisible by 2 here), then left_f and right_f are always
457 * 1.0, and are therefore throwaways.
458 */
459 if (len % (int)sizeof(Sint16) != 0) {
460 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
461 ptr++;
462 len--;
463 }
464
465 for (i = 0; i < len; i += sizeof (Sint8) * 4) {
466 switch (args->room_angle) {
467 case 0:
468 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
469 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
470 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
471 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
472 break;
473 case 90:
474 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
475 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
476 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
477 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
478 break;
479 case 180:
480 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
481 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
482 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
483 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
484 break;
485 case 270:
486 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
487 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
488 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
489 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
490 break;
491 }
492 }
493 }
494
495 static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata)
496 {
497 volatile position_args *args = (volatile position_args *) udata;
498 Sint8 *ptr = (Sint8 *) stream;
499 int i;
500
501 (void)chan;
502
503 /*
504 * if there's only a mono channnel (the only way we wouldn't have
505 * a len divisible by 2 here), then left_f and right_f are always
506 * 1.0, and are therefore throwaways.
507 */
508 if (len % (int)sizeof(Sint16) != 0) {
509 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
510 ptr++;
511 len--;
512 }
513
514 for (i = 0; i < len; i += sizeof (Sint8) * 6) {
515 switch (args->room_angle) {
516 case 0:
517 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
518 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
519 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
520 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
521 *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
522 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
523 break;
524 case 90:
525 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
526 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
527 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
528 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
529 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
530 + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++;
531 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
532 break;
533 case 180:
534 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
535 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
536 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
537 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
538 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
539 + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
540 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
541 break;
542 case 270:
543 *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
544 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
545 *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
546 *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
547 *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2)
548 + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
549 *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
550 break;
551 }
552 }
553 }
554
555 /*
556 * This one runs about 10.1 times faster than the non-table version, with
557 * no loss in quality. It does, however, require 64k of memory for the
558 * lookup table. Also, this will only update position information once per
559 * call; the non-table version always checks the arguments for each sample,
560 * in case the user has called Mix_SetPanning() or whatnot again while this
561 * callback is running.
562 */
563 static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata)
564 {
565 volatile position_args *args = (volatile position_args *) udata;
566 Sint8 *ptr = (Sint8 *) stream;
567 Uint32 *p;
568 int i;
569 Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
570 Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
571 Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
572
573 (void)chan;
574
575 if (args->room_angle == 180) {
576 Sint8 *temp = l;
577 l = r;
578 r = temp;
579 }
580
581 while (len % (int)sizeof(Uint32) != 0) {
582 *ptr = d[l[*ptr]];
583 ptr++;
584 if (args->channels > 1) {
585 *ptr = d[r[*ptr]];
586 ptr++;
587 }
588 len -= args->channels;
589 }
590
591 p = (Uint32 *) ptr;
592
593 for (i = 0; i < len; i += sizeof (Uint32)) {
594 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
595 *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
596 (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
597 (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
598 (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
599 #else
600 *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
601 (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
602 (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
603 (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
604 #endif
605 ++p;
606 }
607 }
608
609
610 /* !!! FIXME : Optimize the code for 16-bit samples? */
611
612 static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
613 {
614 volatile position_args *args = (volatile position_args *) udata;
615 Uint16 *ptr = (Uint16 *) stream;
616 int i;
617
618 (void)chan;
619
620 for (i = 0; i < len; i += sizeof (Uint16) * 2) {
621 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
622 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
623
624 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
625 * args->distance_f) + 32768);
626 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
627 * args->distance_f) + 32768);
628
629 if (args->room_angle == 180) {
630 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
631 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
632 }
633 else {
634 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
635 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
636 }
637 }
638 }
639
640 static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
641 {
642 volatile position_args *args = (volatile position_args *) udata;
643 Uint16 *ptr = (Uint16 *) stream;
644 int i;
645
646 (void)chan;
647
648 for (i = 0; i < len; i += sizeof (Uint16) * 4) {
649 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
650 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
651 Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
652 Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
653
654 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
655 * args->distance_f) + 32768);
656 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
657 * args->distance_f) + 32768);
658 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
659 * args->distance_f) + 32768);
660 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
661 * args->distance_f) + 32768);
662
663 switch (args->room_angle) {
664 case 0:
665 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
666 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
667 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
668 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
669 break;
670 case 90:
671 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
672 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
673 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
674 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
675 break;
676 case 180:
677 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
678 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
679 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
680 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
681 break;
682 case 270:
683 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
684 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
685 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
686 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
687 break;
688 }
689 }
690 }
691
692 static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
693 {
694 volatile position_args *args = (volatile position_args *) udata;
695 Uint16 *ptr = (Uint16 *) stream;
696 int i;
697
698 (void)chan;
699
700 for (i = 0; i < len; i += sizeof (Uint16) * 6) {
701 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
702 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
703 Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
704 Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
705 Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
706 Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
707
708 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
709 * args->distance_f) + 32768);
710 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
711 * args->distance_f) + 32768);
712 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
713 * args->distance_f) + 32768);
714 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
715 * args->distance_f) + 32768);
716 Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
717 * args->distance_f) + 32768);
718 Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
719 * args->distance_f) + 32768);
720
721 switch (args->room_angle) {
722 case 0:
723 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
724 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
725 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
726 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
727 *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
728 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
729 break;
730 case 90:
731 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
732 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
733 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
734 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
735 *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
736 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
737 break;
738 case 180:
739 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
740 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
741 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
742 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
743 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
744 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
745 break;
746 case 270:
747 *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
748 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
749 *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
750 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
751 *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
752 *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
753 break;
754 }
755 }
756 }
757
758 static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
759 {
760 /* 16 signed bits (lsb) * 2 channels. */
761 volatile position_args *args = (volatile position_args *) udata;
762 Sint16 *ptr = (Sint16 *) stream;
763 int i;
764
765 (void)chan;
766
767 #if 0
768 if (len % (int)(sizeof(Sint16) * 2)) {
769 fprintf(stderr,"Not an even number of frames! len=%d\n", len);
770 return;
771 }
772 #endif
773
774 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
775 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
776 args->left_f) * args->distance_f);
777 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
778 args->right_f) * args->distance_f);
779 if (args->room_angle == 180) {
780 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
781 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
782 }
783 else {
784 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
785 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
786 }
787 }
788 }
789 static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
790 {
791 /* 16 signed bits (lsb) * 4 channels. */
792 volatile position_args *args = (volatile position_args *) udata;
793 Sint16 *ptr = (Sint16 *) stream;
794 int i;
795
796 (void)chan;
797
798 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
799 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
800 args->left_f) * args->distance_f);
801 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
802 args->right_f) * args->distance_f);
803 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
804 args->left_rear_f) * args->distance_f);
805 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
806 args->right_rear_f) * args->distance_f);
807 switch (args->room_angle) {
808 case 0:
809 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
810 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
811 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
812 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
813 break;
814 case 90:
815 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
816 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
817 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
818 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
819 break;
820 case 180:
821 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
822 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
823 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
824 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
825 break;
826 case 270:
827 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
828 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
829 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
830 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
831 break;
832 }
833 }
834 }
835
836 static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata)
837 {
838 /* 16 signed bits (lsb) * 6 channels. */
839 volatile position_args *args = (volatile position_args *) udata;
840 Sint16 *ptr = (Sint16 *) stream;
841 int i;
842
843 (void)chan;
844
845 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
846 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
847 args->left_f) * args->distance_f);
848 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
849 args->right_f) * args->distance_f);
850 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
851 args->left_rear_f) * args->distance_f);
852 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *
853 args->right_rear_f) * args->distance_f);
854 Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *
855 args->center_f) * args->distance_f);
856 Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *
857 args->lfe_f) * args->distance_f);
858 switch (args->room_angle) {
859 case 0:
860 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
861 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
862 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
863 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
864 *(ptr++) = (Sint16) SDL_SwapLE16(swapce);
865 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
866 break;
867 case 90:
868 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
869 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
870 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
871 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
872 *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;
873 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
874 break;
875 case 180:
876 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
877 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
878 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
879 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
880 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
881 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
882 break;
883 case 270:
884 *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
885 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
886 *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
887 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
888 *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
889 *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
890 break;
891 }
892 }
893 }
894
895 static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
896 {
897 /* 16 signed bits (lsb) * 2 channels. */
898 volatile position_args *args = (volatile position_args *) udata;
899 Uint16 *ptr = (Uint16 *) stream;
900 int i;
901
902 (void)chan;
903
904 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
905 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
906 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
907
908 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
909 * args->distance_f) + 32768);
910 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
911 * args->distance_f) + 32768);
912
913 if (args->room_angle == 180) {
914 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
915 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
916 }
917 else {
918 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
919 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
920 }
921 }
922 }
923
924 static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
925 {
926 /* 16 signed bits (lsb) * 4 channels. */
927 volatile position_args *args = (volatile position_args *) udata;
928 Uint16 *ptr = (Uint16 *) stream;
929 int i;
930
931 (void)chan;
932
933 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
934 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
935 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
936 Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
937 Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
938
939 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
940 * args->distance_f) + 32768);
941 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
942 * args->distance_f) + 32768);
943 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
944 * args->distance_f) + 32768);
945 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
946 * args->distance_f) + 32768);
947
948 switch (args->room_angle) {
949 case 0:
950 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
951 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
952 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
953 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
954 break;
955 case 90:
956 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
957 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
958 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
959 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
960 break;
961 case 180:
962 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
963 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
964 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
965 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
966 break;
967 case 270:
968 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
969 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
970 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
971 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
972 break;
973 }
974 }
975 }
976
977 static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
978 {
979 /* 16 signed bits (lsb) * 6 channels. */
980 volatile position_args *args = (volatile position_args *) udata;
981 Uint16 *ptr = (Uint16 *) stream;
982 int i;
983
984 (void)chan;
985
986 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
987 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
988 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
989 Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
990 Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
991 Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
992 Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
993
994 Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
995 * args->distance_f) + 32768);
996 Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
997 * args->distance_f) + 32768);
998 Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
999 * args->distance_f) + 32768);
1000 Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
1001 * args->distance_f) + 32768);
1002 Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
1003 * args->distance_f) + 32768);
1004 Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
1005 * args->distance_f) + 32768);
1006
1007 switch (args->room_angle) {
1008 case 0:
1009 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
1010 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
1011 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
1012 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
1013 *(ptr++) = (Uint16) SDL_SwapBE16(swapce);
1014 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1015 break;
1016 case 90:
1017 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
1018 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
1019 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
1020 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
1021 *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
1022 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1023 break;
1024 case 180:
1025 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
1026 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
1027 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
1028 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
1029 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
1030 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1031 break;
1032 case 270:
1033 *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
1034 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
1035 *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
1036 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
1037 *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
1038 *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
1039 break;
1040 }
1041 }
1042 }
1043
1044 static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
1045 {
1046 /* 16 signed bits (lsb) * 2 channels. */
1047 volatile position_args *args = (volatile position_args *) udata;
1048 Sint16 *ptr = (Sint16 *) stream;
1049 int i;
1050
1051 (void)chan;
1052
1053 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
1054 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1055 args->left_f) * args->distance_f);
1056 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1057 args->right_f) * args->distance_f);
1058 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1059 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1060 }
1061 }
1062
1063 static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata)
1064 {
1065 /* 16 signed bits (lsb) * 4 channels. */
1066 volatile position_args *args = (volatile position_args *) udata;
1067 Sint16 *ptr = (Sint16 *) stream;
1068 int i;
1069
1070 (void)chan;
1071
1072 for (i = 0; i < len; i += sizeof (Sint16) * 4) {
1073 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1074 args->left_f) * args->distance_f);
1075 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1076 args->right_f) * args->distance_f);
1077 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
1078 args->left_rear_f) * args->distance_f);
1079 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
1080 args->right_rear_f) * args->distance_f);
1081 switch (args->room_angle) {
1082 case 0:
1083 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1084 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1085 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1086 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1087 break;
1088 case 90:
1089 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1090 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1091 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1092 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1093 break;
1094 case 180:
1095 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1096 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1097 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1098 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1099 break;
1100 case 270:
1101 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1102 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1103 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1104 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1105 break;
1106 }
1107 }
1108 }
1109
1110 static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata)
1111 {
1112 /* 16 signed bits (lsb) * 6 channels. */
1113 volatile position_args *args = (volatile position_args *) udata;
1114 Sint16 *ptr = (Sint16 *) stream;
1115 int i;
1116
1117 (void)chan;
1118
1119 for (i = 0; i < len; i += sizeof (Sint16) * 6) {
1120 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1121 args->left_f) * args->distance_f);
1122 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1123 args->right_f) * args->distance_f);
1124 Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
1125 args->left_rear_f) * args->distance_f);
1126 Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
1127 args->right_rear_f) * args->distance_f);
1128 Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) *
1129 args->center_f) * args->distance_f);
1130 Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) *
1131 args->lfe_f) * args->distance_f);
1132
1133 switch (args->room_angle) {
1134 case 0:
1135 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1136 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1137 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1138 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1139 *(ptr++) = (Sint16) SDL_SwapBE16(swapce);
1140 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1141 break;
1142 case 90:
1143 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1144 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1145 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1146 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1147 *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2;
1148 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1149 break;
1150 case 180:
1151 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1152 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1153 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1154 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1155 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
1156 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1157 break;
1158 case 270:
1159 *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
1160 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
1161 *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
1162 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
1163 *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
1164 *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
1165 break;
1166 }
1167 }
1168 }
1169
1170 static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata)
1171 {
1172 /* 32 signed bits (lsb) * 2 channels. */
1173 volatile position_args *args = (volatile position_args *) udata;
1174 Sint32 *ptr = (Sint32 *) stream;
1175 int i;
1176
1177 (void)chan;
1178
1179 #if 0
1180 if (len % (int)(sizeof(Sint32) * 2)) {
1181 fprintf(stderr,"Not an even number of frames! len=%d\n", len);
1182 return;
1183 }
1184 #endif
1185
1186 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
1187 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1188 args->left_f) * args->distance_f);
1189 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1190 args->right_f) * args->distance_f);
1191 if (args->room_angle == 180) {
1192 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1193 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1194 }
1195 else {
1196 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1197 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1198 }
1199 }
1200 }
1201
1202 static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata)
1203 {
1204 /* 32 signed bits (lsb) * 4 channels. */
1205 volatile position_args *args = (volatile position_args *) udata;
1206 Sint32 *ptr = (Sint32 *) stream;
1207 int i;
1208
1209 (void)chan;
1210
1211 for (i = 0; i < len; i += sizeof (Sint32) * 4) {
1212 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1213 args->left_f) * args->distance_f);
1214 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1215 args->right_f) * args->distance_f);
1216 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1217 args->left_rear_f) * args->distance_f);
1218 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
1219 args->right_rear_f) * args->distance_f);
1220 switch (args->room_angle) {
1221 case 0:
1222 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1223 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1224 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1225 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1226 break;
1227 case 90:
1228 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1229 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1230 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1231 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1232 break;
1233 case 180:
1234 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1235 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1236 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1237 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1238 break;
1239 case 270:
1240 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1241 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1242 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1243 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1244 break;
1245 }
1246 }
1247 }
1248
1249 static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata)
1250 {
1251 /* 32 signed bits (lsb) * 6 channels. */
1252 volatile position_args *args = (volatile position_args *) udata;
1253 Sint32 *ptr = (Sint32 *) stream;
1254 int i;
1255
1256 (void)chan;
1257
1258 for (i = 0; i < len; i += sizeof (Sint32) * 6) {
1259 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1260 args->left_f) * args->distance_f);
1261 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
1262 args->right_f) * args->distance_f);
1263 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
1264 args->left_rear_f) * args->distance_f);
1265 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) *
1266 args->right_rear_f) * args->distance_f);
1267 Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) *
1268 args->center_f) * args->distance_f);
1269 Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) *
1270 args->lfe_f) * args->distance_f);
1271 switch (args->room_angle) {
1272 case 0:
1273 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1274 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1275 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1276 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1277 *(ptr++) = (Sint32) SDL_SwapLE32(swapce);
1278 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1279 break;
1280 case 90:
1281 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1282 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1283 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1284 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1285 *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2;
1286 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1287 break;
1288 case 180:
1289 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1290 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1291 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1292 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1293 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
1294 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1295 break;
1296 case 270:
1297 *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
1298 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
1299 *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
1300 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
1301 *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
1302 *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
1303 break;
1304 }
1305 }
1306 }
1307
1308 static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata)
1309 {
1310 /* 32 signed bits (lsb) * 2 channels. */
1311 volatile position_args *args = (volatile position_args *) udata;
1312 Sint32 *ptr = (Sint32 *) stream;
1313 int i;
1314
1315 (void)chan;
1316
1317 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
1318 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1319 args->left_f) * args->distance_f);
1320 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1321 args->right_f) * args->distance_f);
1322 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1323 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1324 }
1325 }
1326
1327 static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata)
1328 {
1329 /* 32 signed bits (lsb) * 4 channels. */
1330 volatile position_args *args = (volatile position_args *) udata;
1331 Sint32 *ptr = (Sint32 *) stream;
1332 int i;
1333
1334 (void)chan;
1335
1336 for (i = 0; i < len; i += sizeof (Sint32) * 4) {
1337 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1338 args->left_f) * args->distance_f);
1339 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1340 args->right_f) * args->distance_f);
1341 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
1342 args->left_rear_f) * args->distance_f);
1343 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
1344 args->right_rear_f) * args->distance_f);
1345 switch (args->room_angle) {
1346 case 0:
1347 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1348 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1349 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1350 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1351 break;
1352 case 90:
1353 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1354 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1355 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1356 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1357 break;
1358 case 180:
1359 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1360 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1361 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1362 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1363 break;
1364 case 270:
1365 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1366 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1367 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1368 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1369 break;
1370 }
1371 }
1372 }
1373
1374 static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata)
1375 {
1376 /* 32 signed bits (lsb) * 6 channels. */
1377 volatile position_args *args = (volatile position_args *) udata;
1378 Sint32 *ptr = (Sint32 *) stream;
1379 int i;
1380
1381 (void)chan;
1382
1383 for (i = 0; i < len; i += sizeof (Sint32) * 6) {
1384 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1385 args->left_f) * args->distance_f);
1386 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1387 args->right_f) * args->distance_f);
1388 Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
1389 args->left_rear_f) * args->distance_f);
1390 Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
1391 args->right_rear_f) * args->distance_f);
1392 Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) *
1393 args->center_f) * args->distance_f);
1394 Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) *
1395 args->lfe_f) * args->distance_f);
1396
1397 switch (args->room_angle) {
1398 case 0:
1399 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1400 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1401 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1402 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1403 *(ptr++) = (Sint32) SDL_SwapBE32(swapce);
1404 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1405 break;
1406 case 90:
1407 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1408 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1409 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1410 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1411 *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2;
1412 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1413 break;
1414 case 180:
1415 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1416 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1417 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1418 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1419 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
1420 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1421 break;
1422 case 270:
1423 *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
1424 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
1425 *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
1426 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
1427 *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
1428 *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
1429 break;
1430 }
1431 }
1432 }
1433
1434 static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata)
1435 {
1436 /* float * 2 channels. */
1437 volatile position_args *args = (volatile position_args *) udata;
1438 float *ptr = (float *) stream;
1439 int i;
1440
1441 (void)chan;
1442
1443 for (i = 0; i < len; i += sizeof (float) * 2) {
1444 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1445 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1446 *(ptr++) = swapl;
1447 *(ptr++) = swapr;
1448 }
1449 }
1450
1451 static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata)
1452 {
1453 /* float * 4 channels. */
1454 volatile position_args *args = (volatile position_args *) udata;
1455 float *ptr = (float *) stream;
1456 int i;
1457
1458 (void)chan;
1459
1460 for (i = 0; i < len; i += sizeof (float) * 4) {
1461 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1462 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1463 float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
1464 float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
1465 switch (args->room_angle) {
1466 case 0:
1467 *(ptr++) = swapl;
1468 *(ptr++) = swapr;
1469 *(ptr++) = swaplr;
1470 *(ptr++) = swaprr;
1471 break;
1472 case 90:
1473 *(ptr++) = swapr;
1474 *(ptr++) = swaprr;
1475 *(ptr++) = swapl;
1476 *(ptr++) = swaplr;
1477 break;
1478 case 180:
1479 *(ptr++) = swaprr;
1480 *(ptr++) = swaplr;
1481 *(ptr++) = swapr;
1482 *(ptr++) = swapl;
1483 break;
1484 case 270:
1485 *(ptr++) = swaplr;
1486 *(ptr++) = swapl;
1487 *(ptr++) = swaprr;
1488 *(ptr++) = swapr;
1489 break;
1490 }
1491 }
1492 }
1493
1494 static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata)
1495 {
1496 /* float * 6 channels. */
1497 volatile position_args *args = (volatile position_args *) udata;
1498 float *ptr = (float *) stream;
1499 int i;
1500
1501 (void)chan;
1502
1503 for (i = 0; i < len; i += sizeof (float) * 6) {
1504 float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
1505 float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
1506 float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
1507 float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
1508 float swapce = ((*(ptr+4) * args->center_f) * args->distance_f);
1509 float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f);
1510
1511 switch (args->room_angle) {
1512 case 0:
1513 *(ptr++) = swapl;
1514 *(ptr++) = swapr;
1515 *(ptr++) = swaplr;
1516 *(ptr++) = swaprr;
1517 *(ptr++) = swapce;
1518 *(ptr++) = swapwf;
1519 break;
1520 case 90:
1521 *(ptr++) = swapr;
1522 *(ptr++) = swaprr;
1523 *(ptr++) = swapl;
1524 *(ptr++) = swaplr;
1525 *(ptr++) = swapr/2.0f + swaprr/2.0f;
1526 *(ptr++) = swapwf;
1527 break;
1528 case 180:
1529 *(ptr++) = swaprr;
1530 *(ptr++) = swaplr;
1531 *(ptr++) = swapr;
1532 *(ptr++) = swapl;
1533 *(ptr++) = swaprr/2.0f + swaplr/2.0f;
1534 *(ptr++) = swapwf;
1535 break;
1536 case 270:
1537 *(ptr++) = swaplr;
1538 *(ptr++) = swapl;
1539 *(ptr++) = swaprr;
1540 *(ptr++) = swapr;
1541 *(ptr++) = swapl/2.0f + swaplr/2.0f;
1542 *(ptr++) = swapwf;
1543 break;
1544 }
1545 }
1546 }
1547
1548 static void init_position_args(position_args *args)
1549 {
1550 SDL_memset(args, '\0', sizeof (position_args));
1551 args->in_use = 0;
1552 args->room_angle = 0;
1553 args->left_u8 = args->right_u8 = args->distance_u8 = 255;
1554 args->left_f = args->right_f = args->distance_f = 1.0f;
1555 args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255;
1556 args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f;
1557 Mix_QuerySpec(NULL, NULL, (int *) &args->channels);
1558 }
1559
1560 static position_args *get_position_arg(int channel)
1561 {
1562 void *rc;
1563 int i;
1564
1565 if (channel < 0) {
1566 if (pos_args_global == NULL) {
1567 pos_args_global = SDL_malloc(sizeof (position_args));
1568 if (pos_args_global == NULL) {
1569 Mix_SetError("Out of memory");
1570 return(NULL);
1571 }
1572 init_position_args(pos_args_global);
1573 }
1574
1575 return(pos_args_global);
1576 }
1577
1578 if (channel >= position_channels) {
1579 rc = SDL_realloc(pos_args_array, (size_t)(channel + 1) * sizeof(position_args *));
1580 if (rc == NULL) {
1581 Mix_SetError("Out of memory");
1582 return(NULL);
1583 }
1584 pos_args_array = (position_args **) rc;
1585 for (i = position_channels; i <= channel; i++) {
1586 pos_args_array[i] = NULL;
1587 }
1588 position_channels = channel + 1;
1589 }
1590
1591 if (pos_args_array[channel] == NULL) {
1592 pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
1593 if (pos_args_array[channel] == NULL) {
1594 Mix_SetError("Out of memory");
1595 return(NULL);
1596 }
1597 init_position_args(pos_args_array[channel]);
1598 }
1599
1600 return(pos_args_array[channel]);
1601 }
1602
1603 static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
1604 {
1605 Mix_EffectFunc_t f = NULL;
1606
1607 switch (format) {
1608 case AUDIO_U8:
1609 switch (channels) {
1610 case 1:
1611 case 2:
1612 f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 :
1613 _Eff_position_u8;
1614 break;
1615 case 4:
1616 f = _Eff_position_u8_c4;
1617 break;
1618 case 6:
1619 f = _Eff_position_u8_c6;
1620 break;
1621 default:
1622 Mix_SetError("Unsupported audio channels");
1623 break;
1624 }
1625 break;
1626
1627 case AUDIO_S8:
1628 switch (channels) {
1629 case 1:
1630 case 2:
1631 f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 :
1632 _Eff_position_s8;
1633 break;
1634 case 4:
1635 f = _Eff_position_s8_c4;
1636 break;
1637 case 6:
1638 f = _Eff_position_s8_c6;
1639 break;
1640 default:
1641 Mix_SetError("Unsupported audio channels");
1642 break;
1643 }
1644 break;
1645
1646 case AUDIO_U16LSB:
1647 switch (channels) {
1648 case 1:
1649 case 2:
1650 f = _Eff_position_u16lsb;
1651 break;
1652 case 4:
1653 f = _Eff_position_u16lsb_c4;
1654 break;
1655 case 6:
1656 f = _Eff_position_u16lsb_c6;
1657 break;
1658 default:
1659 Mix_SetError("Unsupported audio channels");
1660 break;
1661 }
1662 break;
1663
1664 case AUDIO_S16LSB:
1665 switch (channels) {
1666 case 1:
1667 case 2:
1668 f = _Eff_position_s16lsb;
1669 break;
1670 case 4:
1671 f = _Eff_position_s16lsb_c4;
1672 break;
1673 case 6:
1674 f = _Eff_position_s16lsb_c6;
1675 break;
1676 default:
1677 Mix_SetError("Unsupported audio channels");
1678 break;
1679 }
1680 break;
1681
1682 case AUDIO_U16MSB:
1683 switch (channels) {
1684 case 1:
1685 case 2:
1686 f = _Eff_position_u16msb;
1687 break;
1688 case 4:
1689 f = _Eff_position_u16msb_c4;
1690 break;
1691 case 6:
1692 f = _Eff_position_u16msb_c6;
1693 break;
1694 default:
1695 Mix_SetError("Unsupported audio channels");
1696 break;
1697 }
1698 break;
1699
1700 case AUDIO_S16MSB:
1701 switch (channels) {
1702 case 1:
1703 case 2:
1704 f = _Eff_position_s16msb;
1705 break;
1706 case 4:
1707 f = _Eff_position_s16msb_c4;
1708 break;
1709 case 6:
1710 f = _Eff_position_s16msb_c6;
1711 break;
1712 default:
1713 Mix_SetError("Unsupported audio channels");
1714 break;
1715 }
1716 break;
1717
1718 case AUDIO_S32MSB:
1719 switch (channels) {
1720 case 1:
1721 case 2:
1722 f = _Eff_position_s32msb;
1723 break;
1724 case 4:
1725 f = _Eff_position_s32msb_c4;
1726 break;
1727 case 6:
1728 f = _Eff_position_s32msb_c6;
1729 break;
1730 default:
1731 Mix_SetError("Unsupported audio channels");
1732 break;
1733 }
1734 break;
1735
1736 case AUDIO_S32LSB:
1737 switch (channels) {
1738 case 1:
1739 case 2:
1740 f = _Eff_position_s32lsb;
1741 break;
1742 case 4:
1743 f = _Eff_position_s32lsb_c4;
1744 break;
1745 case 6:
1746 f = _Eff_position_s32lsb_c6;
1747 break;
1748 default:
1749 Mix_SetError("Unsupported audio channels");
1750 break;
1751 }
1752 break;
1753
1754 case AUDIO_F32SYS:
1755 switch (channels) {
1756 case 1:
1757 case 2:
1758 f = _Eff_position_f32sys;
1759 break;
1760 case 4:
1761 f = _Eff_position_f32sys_c4;
1762 break;
1763 case 6:
1764 f = _Eff_position_f32sys_c6;
1765 break;
1766 default:
1767 Mix_SetError("Unsupported audio channels");
1768 break;
1769 }
1770 break;
1771
1772 default:
1773 Mix_SetError("Unsupported audio format");
1774 break;
1775 }
1776
1777 return(f);
1778 }
1779
1780 static Uint8 speaker_amplitude[6];
1781
1782 static void set_amplitudes(int channels, int angle, int room_angle)
1783 {
1784 int left = 255, right = 255;
1785 int left_rear = 255, right_rear = 255, center = 255;
1786
1787 /* our only caller Mix_SetPosition() already makes angle between 0 and 359. */
1788
1789 if (channels == 2)
1790 {
1791 /*
1792 * We only attenuate by position if the angle falls on the far side
1793 * of center; That is, an angle that's due north would not attenuate
1794 * either channel. Due west attenuates the right channel to 0.0, and
1795 * due east attenuates the left channel to 0.0. Slightly east of
1796 * center attenuates the left channel a little, and the right channel
1797 * not at all. I think of this as occlusion by one's own head. :)
1798 *
1799 * ...so, we split our angle circle into four quadrants...
1800 */
1801 if (angle < 90) {
1802 left = 255 - ((int) (255.0f * (((float) angle) / 89.0f)));
1803 } else if (angle < 180) {
1804 left = (int) (255.0f * (((float) (angle - 90)) / 89.0f));
1805 } else if (angle < 270) {
1806 right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f)));
1807 } else {
1808 right = (int) (255.0f * (((float) (angle - 270)) / 89.0f));
1809 }
1810 }
1811
1812 if (channels == 4 || channels == 6)
1813 {
1814 /*
1815 * An angle that's due north does not attenuate the center channel.
1816 * An angle in the first quadrant, 0-90, does not attenuate the RF.
1817 *
1818 * ...so, we split our angle circle into 8 ...
1819 *
1820 * CE
1821 * 0
1822 * LF | RF
1823 * |
1824 * 270<-------|----------->90
1825 * |
1826 * LR | RR
1827 * 180
1828 *
1829 */
1830 if (angle < 45) {
1831 left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
1832 left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f)));
1833 right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f)));
1834 } else if (angle < 90) {
1835 center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
1836 left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
1837 left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f)));
1838 right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f)));
1839 } else if (angle < 135) {
1840 center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
1841 left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f)));
1842 right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
1843 left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
1844 } else if (angle < 180) {
1845 center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f)));
1846 left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f)));
1847 right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
1848 left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
1849 } else if (angle < 225) {
1850 center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f)));
1851 left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
1852 right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f)));
1853 right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
1854 } else if (angle < 270) {
1855 center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
1856 left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
1857 right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f)));
1858 right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
1859 } else if (angle < 315) {
1860 center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
1861 right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
1862 left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
1863 right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f)));
1864 } else {
1865 right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
1866 left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
1867 right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f)));
1868 }
1869 }
1870
1871 if (left < 0) left = 0;
1872 if (left > 255) left = 255;
1873 if (right < 0) right = 0;
1874 if (right > 255) right = 255;
1875 if (left_rear < 0) left_rear = 0;
1876 if (left_rear > 255) left_rear = 255;
1877 if (right_rear < 0) right_rear = 0;
1878 if (right_rear > 255) right_rear = 255;
1879 if (center < 0) center = 0;
1880 if (center > 255) center = 255;
1881
1882 if (room_angle == 90) {
1883 speaker_amplitude[0] = (Uint8)left_rear;
1884 speaker_amplitude[1] = (Uint8)left;
1885 speaker_amplitude[2] = (Uint8)right_rear;
1886 speaker_amplitude[3] = (Uint8)right;
1887 }
1888 else if (room_angle == 180) {
1889 if (channels == 2) {
1890 speaker_amplitude[0] = (Uint8)right;
1891 speaker_amplitude[1] = (Uint8)left;
1892 }
1893 else {
1894 speaker_amplitude[0] = (Uint8)right_rear;
1895 speaker_amplitude[1] = (Uint8)left_rear;
1896 speaker_amplitude[2] = (Uint8)right;
1897 speaker_amplitude[3] = (Uint8)left;
1898 }
1899 }
1900 else if (room_angle == 270) {
1901 speaker_amplitude[0] = (Uint8)right;
1902 speaker_amplitude[1] = (Uint8)right_rear;
1903 speaker_amplitude[2] = (Uint8)left;
1904 speaker_amplitude[3] = (Uint8)left_rear;
1905 }
1906 else {
1907 speaker_amplitude[0] = (Uint8)left;
1908 speaker_amplitude[1] = (Uint8)right;
1909 speaker_amplitude[2] = (Uint8)left_rear;
1910 speaker_amplitude[3] = (Uint8)right_rear;
1911 }
1912 speaker_amplitude[4] = (Uint8)center;
1913 speaker_amplitude[5] = 255;
1914 }
1915
1916 int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
1917
1918 int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
1919 {
1920 Mix_EffectFunc_t f = NULL;
1921 int channels;
1922 Uint16 format;
1923 position_args *args = NULL;
1924 int retval = 1;
1925
1926 Mix_QuerySpec(NULL, &format, &channels);
1927
1928 if (channels != 2 && channels != 4 && channels != 6) /* it's a no-op; we call that successful. */
1929 return(1);
1930
1931 if (channels > 2) {
1932 /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */
1933 /* left = 255 => angle = -90; left = 0 => angle = +89 */
1934 int angle = 0;
1935 if ((left != 255) || (right != 255)) {
1936 angle = (int)left;
1937 angle = 127 - angle;
1938 angle = -angle;
1939 angle = angle * 90 / 128; /* Make it larger for more effect? */
1940 }
1941 return Mix_SetPosition(channel, angle, 0);
1942 }
1943
1944 f = get_position_effect_func(format, channels);
1945 if (f == NULL)
1946 return(0);
1947
1948 Mix_LockAudio();
1949 args = get_position_arg(channel);
1950 if (!args) {
1951 Mix_UnlockAudio();
1952 return(0);
1953 }
1954
1955 /* it's a no-op; unregister the effect, if it's registered. */
1956 if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
1957 if (args->in_use) {
1958 retval = _Mix_UnregisterEffect_locked(channel, f);
1959 Mix_UnlockAudio();
1960 return(retval);
1961 } else {
1962 Mix_UnlockAudio();
1963 return(1);
1964 }
1965 }
1966
1967 args->left_u8 = left;
1968 args->left_f = ((float) left) / 255.0f;
1969 args->right_u8 = right;
1970 args->right_f = ((float) right) / 255.0f;
1971 args->room_angle = 0;
1972
1973 if (!args->in_use) {
1974 args->in_use = 1;
1975 retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args);
1976 }
1977
1978 Mix_UnlockAudio();
1979 return(retval);
1980 }
1981
1982
1983 int Mix_SetDistance(int channel, Uint8 distance)
1984 {
1985 Mix_EffectFunc_t f = NULL;
1986 Uint16 format;
1987 position_args *args = NULL;
1988 int channels;
1989 int retval = 1;
1990
1991 Mix_QuerySpec(NULL, &format, &channels);
1992 f = get_position_effect_func(format, channels);
1993 if (f == NULL)
1994 return(0);
1995
1996 Mix_LockAudio();
1997 args = get_position_arg(channel);
1998 if (!args) {
1999 Mix_UnlockAudio();
2000 return(0);
2001 }
2002
2003 distance = 255 - distance; /* flip it to our scale. */
2004
2005 /* it's a no-op; unregister the effect, if it's registered. */
2006 if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
2007 if (args->in_use) {
2008 retval = _Mix_UnregisterEffect_locked(channel, f);
2009 Mix_UnlockAudio();
2010 return(retval);
2011 } else {
2012 Mix_UnlockAudio();
2013 return(1);
2014 }
2015 }
2016
2017 args->distance_u8 = distance;
2018 args->distance_f = ((float) distance) / 255.0f;
2019 if (!args->in_use) {
2020 args->in_use = 1;
2021 retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
2022 }
2023
2024 Mix_UnlockAudio();
2025 return(retval);
2026 }
2027
2028
2029 int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
2030 {
2031 Mix_EffectFunc_t f = NULL;
2032 Uint16 format;
2033 int channels;
2034 position_args *args = NULL;
2035 Sint16 room_angle = 0;
2036 int retval = 1;
2037
2038 Mix_QuerySpec(NULL, &format, &channels);
2039 f = get_position_effect_func(format, channels);
2040 if (f == NULL)
2041 return(0);
2042
2043 /* make angle between 0 and 359. */
2044 angle %= 360;
2045 if (angle < 0) angle += 360;
2046
2047 Mix_LockAudio();
2048 args = get_position_arg(channel);
2049 if (!args) {
2050 Mix_UnlockAudio();
2051 return(0);
2052 }
2053
2054 /* it's a no-op; unregister the effect, if it's registered. */
2055 if ((!distance) && (!angle)) {
2056 if (args->in_use) {
2057 retval = _Mix_UnregisterEffect_locked(channel, f);
2058 Mix_UnlockAudio();
2059 return(retval);
2060 } else {
2061 Mix_UnlockAudio();
2062 return(1);
2063 }
2064 }
2065
2066 if (channels == 2)
2067 {
2068 if (angle > 180)
2069 room_angle = 180; /* exchange left and right channels */
2070 else room_angle = 0;
2071 }
2072
2073 if (channels == 4 || channels == 6)
2074 {
2075 if (angle > 315) room_angle = 0;
2076 else if (angle > 225) room_angle = 270;
2077 else if (angle > 135) room_angle = 180;
2078 else if (angle > 45) room_angle = 90;
2079 else room_angle = 0;
2080 }
2081
2082 distance = 255 - distance; /* flip it to scale Mix_SetDistance() uses. */
2083
2084 set_amplitudes(channels, angle, room_angle);
2085
2086 args->left_u8 = speaker_amplitude[0];
2087 args->left_f = ((float) speaker_amplitude[0]) / 255.0f;
2088 args->right_u8 = speaker_amplitude[1];
2089 args->right_f = ((float) speaker_amplitude[1]) / 255.0f;
2090 args->left_rear_u8 = speaker_amplitude[2];
2091 args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f;
2092 args->right_rear_u8 = speaker_amplitude[3];
2093 args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f;
2094 args->center_u8 = speaker_amplitude[4];
2095 args->center_f = ((float) speaker_amplitude[4]) / 255.0f;
2096 args->lfe_u8 = speaker_amplitude[5];
2097 args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f;
2098 args->distance_u8 = distance;
2099 args->distance_f = ((float) distance) / 255.0f;
2100 args->room_angle = room_angle;
2101 if (!args->in_use) {
2102 args->in_use = 1;
2103 retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
2104 }
2105
2106 Mix_UnlockAudio();
2107 return(retval);
2108 }
2109
2110 /* end of effects_position.c ... */
2111
2112 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some internally supported special effects that use SDL_mixer's
23 effect callback API. They are meant for speed over quality. :)
24 */
25
26 #include "SDL_mixer.h"
27
28 #define MIX_INTERNAL_EFFECT__
29 #include "effects_internal.h"
30
31 /* profile code:
32 #include <sys/time.h>
33 #include <unistd.h>
34 struct timeval tv1;
35 struct timeval tv2;
36
37 gettimeofday(&tv1, NULL);
38
39 ... do your thing here ...
40
41 gettimeofday(&tv2, NULL);
42 printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
43 */
44
45
46 /*
47 * Stereo reversal effect...this one's pretty straightforward...
48 */
49
50 static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata)
51 {
52 /* 16 bits * 2 channels. */
53 Uint32 *ptr = (Uint32 *) stream;
54 Uint32 tmp;
55 int i;
56
57 (void)chan;
58 (void)udata;
59
60 for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) {
61 tmp = ptr[0];
62 ptr[0] = ptr[1];
63 ptr[1] = tmp;
64 }
65 }
66
67 static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata)
68 {
69 /* 16 bits * 2 channels. */
70 Uint32 *ptr = (Uint32 *) stream;
71 int i;
72
73 (void)chan;
74 (void)udata;
75
76 for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
77 *ptr = (((*ptr) & 0xFFFF0000) >> 16) | (((*ptr) & 0x0000FFFF) << 16);
78 }
79 }
80
81 static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata)
82 {
83 /* 8 bits * 2 channels. */
84 Uint32 *ptr = (Uint32 *) stream;
85 int i;
86
87 (void)chan;
88 (void)udata;
89
90 /* get the last two bytes if len is not divisible by four... */
91 if (len % (int)sizeof(Uint32) != 0) {
92 Uint16 *p = (Uint16 *) (((Uint8 *) stream) + (len - 2));
93 *p = (Uint16)((((*p) & 0xFF00) >> 8) | (((*ptr) & 0x00FF) << 8));
94 len -= 2;
95 }
96
97 for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
98 *ptr = (((*ptr) & 0x0000FF00) >> 8) | (((*ptr) & 0x000000FF) << 8) |
99 (((*ptr) & 0xFF000000) >> 8) | (((*ptr) & 0x00FF0000) << 8);
100 }
101 }
102
103 int Mix_SetReverseStereo(int channel, int flip)
104 {
105 Mix_EffectFunc_t f = NULL;
106 int channels;
107 Uint16 format;
108
109 Mix_QuerySpec(NULL, &format, &channels);
110
111 if (channels == 2) {
112 int bits = (format & 0xFF);
113 switch (bits) {
114 case 8:
115 f = _Eff_reversestereo8;
116 break;
117 case 16:
118 f = _Eff_reversestereo16;
119 break;
120 case 32:
121 f = _Eff_reversestereo32;
122 break;
123 default:
124 Mix_SetError("Unsupported audio format");
125 return(0);
126 }
127 if (!flip) return Mix_UnregisterEffect(channel, f);
128 return(Mix_RegisterEffect(channel, f, NULL, NULL));
129 }
130
131 Mix_SetError("Trying to reverse stereo on a non-stereo stream");
132 return(0);
133 }
134
135 /* end of effect_stereoreverse.c ... */
136
137 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This file by Ryan C. Gordon (icculus@icculus.org)
21
22 These are some helper functions for the internal mixer special effects.
23 */
24
25
26 /* ------ These are used internally only. Don't touch. ------ */
27
28 #include "SDL_mixer.h"
29
30 #define MIX_INTERNAL_EFFECT__
31 #include "effects_internal.h"
32
33 /* Should we favor speed over memory usage and/or quality of output? */
34 int _Mix_effects_max_speed = 0;
35
36
37 void _Mix_InitEffects(void)
38 {
39 _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
40 }
41
42 void _Mix_DeinitEffects(void)
43 {
44 _Eff_PositionDeinit();
45 }
46
47
48 void *_Eff_volume_table = NULL;
49
50
51 /* Build the volume table for Uint8-format samples.
52 *
53 * Each column of the table is a possible sample, while each row of the
54 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
55 * volume. So _Eff_volume_table[128][mysample] would be the value of
56 * mysample, at half volume.
57 */
58 void *_Eff_build_volume_table_u8(void)
59 {
60 int volume;
61 int sample;
62 Uint8 *rc;
63
64 if (!_Mix_effects_max_speed) {
65 return(NULL);
66 }
67
68 if (!_Eff_volume_table) {
69 rc = SDL_malloc(256 * 256);
70 if (rc) {
71 _Eff_volume_table = (void *) rc;
72 for (volume = 0; volume < 256; volume++) {
73 for (sample = -128; sample < 128; sample ++) {
74 *rc = (Uint8)(((float) sample) * ((float) volume / 255.0f))
75 + 128;
76 rc++;
77 }
78 }
79 }
80 }
81
82 return(_Eff_volume_table);
83 }
84
85
86 /* Build the volume table for Sint8-format samples.
87 *
88 * Each column of the table is a possible sample, while each row of the
89 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
90 * volume. So _Eff_volume_table[128][mysample+128] would be the value of
91 * mysample, at half volume.
92 */
93 void *_Eff_build_volume_table_s8(void)
94 {
95 int volume;
96 int sample;
97 Sint8 *rc;
98
99 if (!_Eff_volume_table) {
100 rc = SDL_malloc(256 * 256);
101 if (rc) {
102 _Eff_volume_table = (void *) rc;
103 for (volume = 0; volume < 256; volume++) {
104 for (sample = -128; sample < 128; sample ++) {
105 *rc = (Sint8)(((float) sample) * ((float) volume / 255.0f));
106 rc++;
107 }
108 }
109 }
110 }
111
112 return(_Eff_volume_table);
113 }
114
115
116 /* end of effects.c ... */
117
118 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef INCLUDE_EFFECTS_INTERNAL_H_
22 #define INCLUDE_EFFECTS_INTERNAL_H_
23
24 #ifndef MIX_INTERNAL_EFFECT__
25 #error You should not include this file or use these functions.
26 #endif
27
28 #include "SDL_mixer.h"
29
30 extern int _Mix_effects_max_speed;
31 extern void *_Eff_volume_table;
32 void *_Eff_build_volume_table_u8(void);
33 void *_Eff_build_volume_table_s8(void);
34
35 void _Mix_InitEffects(void);
36 void _Mix_DeinitEffects(void);
37 void _Eff_PositionDeinit(void);
38
39 int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
40 Mix_EffectDone_t d, void *arg);
41 int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f);
42 int _Mix_UnregisterAllEffects_locked(int channel);
43
44 #endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */
45
46 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #include "SDL.h"
22
23 #include "SDL_mixer.h"
24 #include "mixer.h"
25 #include "music.h"
26 #include "load_aiff.h"
27 #include "load_voc.h"
28
29 #define MIX_INTERNAL_EFFECT__
30 #include "effects_internal.h"
31
32 /* Magic numbers for various audio file formats */
33 #define RIFF 0x46464952 /* "RIFF" */
34 #define WAVE 0x45564157 /* "WAVE" */
35 #define FORM 0x4d524f46 /* "FORM" */
36 #define CREA 0x61657243 /* "Crea" */
37
38 static int audio_opened = 0;
39 static SDL_AudioSpec mixer;
40 static SDL_AudioDeviceID audio_device;
41
42 typedef struct _Mix_effectinfo
43 {
44 Mix_EffectFunc_t callback;
45 Mix_EffectDone_t done_callback;
46 void *udata;
47 struct _Mix_effectinfo *next;
48 } effect_info;
49
50 static struct _Mix_Channel {
51 Mix_Chunk *chunk;
52 int playing;
53 int paused;
54 Uint8 *samples;
55 int volume;
56 int looping;
57 int tag;
58 Uint32 expire;
59 Uint32 start_time;
60 Mix_Fading fading;
61 int fade_volume;
62 int fade_volume_reset;
63 Uint32 fade_length;
64 Uint32 ticks_fade;
65 effect_info *effects;
66 } *mix_channel = NULL;
67
68 static effect_info *posteffects = NULL;
69
70 static int num_channels;
71 static int reserved_channels = 0;
72
73
74 /* Support for hooking into the mixer callback system */
75 static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL;
76 static void *mix_postmix_data = NULL;
77
78 /* rcg07062001 callback to alert when channels are done playing. */
79 static void (SDLCALL *channel_done_callback)(int channel) = NULL;
80
81 /* Support for user defined music functions */
82 static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer;
83 static void *music_data = NULL;
84
85 /* rcg06042009 report available decoders at runtime. */
86 static const char **chunk_decoders = NULL;
87 static int num_decoders = 0;
88
89
90 int Mix_GetNumChunkDecoders(void)
91 {
92 return(num_decoders);
93 }
94
95 const char *Mix_GetChunkDecoder(int index)
96 {
97 if ((index < 0) || (index >= num_decoders)) {
98 return NULL;
99 }
100 return(chunk_decoders[index]);
101 }
102
103 SDL_bool Mix_HasChunkDecoder(const char *name)
104 {
105 int index;
106 for (index = 0; index < num_decoders; ++index) {
107 if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) {
108 return SDL_TRUE;
109 }
110 }
111 return SDL_FALSE;
112 }
113
114 void add_chunk_decoder(const char *decoder)
115 {
116 int i;
117 void *ptr;
118
119 /* Check to see if we already have this decoder */
120 for (i = 0; i < num_decoders; ++i) {
121 if (SDL_strcmp(chunk_decoders[i], decoder) == 0) {
122 return;
123 }
124 }
125
126 ptr = SDL_realloc((void *)chunk_decoders, (size_t)(num_decoders + 1) * sizeof (const char *));
127 if (ptr == NULL) {
128 return; /* oh well, go on without it. */
129 }
130 chunk_decoders = (const char **) ptr;
131 chunk_decoders[num_decoders++] = decoder;
132 }
133
134 /* rcg06192001 get linked library's version. */
135 const SDL_version *Mix_Linked_Version(void)
136 {
137 static SDL_version linked_version;
138 SDL_MIXER_VERSION(&linked_version);
139 return(&linked_version);
140 }
141
142 int Mix_Init(int flags)
143 {
144 int result = 0;
145
146 if (flags & MIX_INIT_FLAC) {
147 if (load_music_type(MUS_FLAC)) {
148 open_music_type(MUS_FLAC);
149 result |= MIX_INIT_FLAC;
150 } else {
151 Mix_SetError("FLAC support not available");
152 }
153 }
154 if (flags & MIX_INIT_MOD) {
155 if (load_music_type(MUS_MOD)) {
156 open_music_type(MUS_MOD);
157 result |= MIX_INIT_MOD;
158 } else {
159 Mix_SetError("MOD support not available");
160 }
161 }
162 if (flags & MIX_INIT_MP3) {
163 if (load_music_type(MUS_MP3)) {
164 open_music_type(MUS_MP3);
165 result |= MIX_INIT_MP3;
166 } else {
167 Mix_SetError("MP3 support not available");
168 }
169 }
170 if (flags & MIX_INIT_OGG) {
171 if (load_music_type(MUS_OGG)) {
172 open_music_type(MUS_OGG);
173 result |= MIX_INIT_OGG;
174 } else {
175 Mix_SetError("OGG support not available");
176 }
177 }
178 if (flags & MIX_INIT_OPUS) {
179 if (load_music_type(MUS_OPUS)) {
180 open_music_type(MUS_OPUS);
181 result |= MIX_INIT_OPUS;
182 } else {
183 Mix_SetError("OPUS support not available");
184 }
185 }
186 if (flags & MIX_INIT_MID) {
187 if (load_music_type(MUS_MID)) {
188 open_music_type(MUS_MID);
189 result |= MIX_INIT_MID;
190 } else {
191 Mix_SetError("MIDI support not available");
192 }
193 }
194 return result;
195 }
196
197 void Mix_Quit()
198 {
199 unload_music();
200 }
201
202 static int _Mix_remove_all_effects(int channel, effect_info **e);
203
204 /*
205 * rcg06122001 Cleanup effect callbacks.
206 * MAKE SURE Mix_LockAudio() is called before this (or you're in the
207 * audio callback).
208 */
209 static void _Mix_channel_done_playing(int channel)
210 {
211 if (channel_done_callback) {
212 channel_done_callback(channel);
213 }
214
215 /*
216 * Call internal function directly, to avoid locking audio from
217 * inside audio callback.
218 */
219 _Mix_remove_all_effects(channel, &mix_channel[channel].effects);
220 }
221
222
223 static void *Mix_DoEffects(int chan, void *snd, int len)
224 {
225 int posteffect = (chan == MIX_CHANNEL_POST);
226 effect_info *e = ((posteffect) ? posteffects : mix_channel[chan].effects);
227 void *buf = snd;
228
229 if (e != NULL) { /* are there any registered effects? */
230 /* if this is the postmix, we can just overwrite the original. */
231 if (!posteffect) {
232 buf = SDL_malloc((size_t)len);
233 if (buf == NULL) {
234 return(snd);
235 }
236 SDL_memcpy(buf, snd, (size_t)len);
237 }
238
239 for (; e != NULL; e = e->next) {
240 if (e->callback != NULL) {
241 e->callback(chan, buf, len, e->udata);
242 }
243 }
244 }
245
246 /* be sure to SDL_free() the return value if != snd ... */
247 return(buf);
248 }
249
250
251 /* Mixing function */
252 static void SDLCALL
253 mix_channels(void *udata, Uint8 *stream, int len)
254 {
255 Uint8 *mix_input;
256 int i, mixable, volume = MIX_MAX_VOLUME;
257 Uint32 sdl_ticks;
258
259 (void)udata;
260
261 #if SDL_VERSION_ATLEAST(1, 3, 0)
262 /* Need to initialize the stream in SDL 1.3+ */
263 SDL_memset(stream, mixer.silence, (size_t)len);
264 #endif
265
266 /* Mix the music (must be done before the channels are added) */
267 mix_music(music_data, stream, len);
268
269 /* Mix any playing channels... */
270 sdl_ticks = SDL_GetTicks();
271 for (i=0; i<num_channels; ++i) {
272 if (!mix_channel[i].paused) {
273 if (mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks) {
274 /* Expiration delay for that channel is reached */
275 mix_channel[i].playing = 0;
276 mix_channel[i].looping = 0;
277 mix_channel[i].fading = MIX_NO_FADING;
278 mix_channel[i].expire = 0;
279 _Mix_channel_done_playing(i);
280 } else if (mix_channel[i].fading != MIX_NO_FADING) {
281 Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
282 if (ticks >= mix_channel[i].fade_length) {
283 Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
284 if (mix_channel[i].fading == MIX_FADING_OUT) {
285 mix_channel[i].playing = 0;
286 mix_channel[i].looping = 0;
287 mix_channel[i].expire = 0;
288 _Mix_channel_done_playing(i);
289 }
290 mix_channel[i].fading = MIX_NO_FADING;
291 } else {
292 if (mix_channel[i].fading == MIX_FADING_OUT) {
293 Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
294 / mix_channel[i].fade_length);
295 } else {
296 Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length);
297 }
298 }
299 }
300 if (mix_channel[i].playing > 0) {
301 int index = 0;
302 int remaining = len;
303 while (mix_channel[i].playing > 0 && index < len) {
304 remaining = len - index;
305 volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME;
306 mixable = mix_channel[i].playing;
307 if (mixable > remaining) {
308 mixable = remaining;
309 }
310
311 mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable);
312 SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume);
313 if (mix_input != mix_channel[i].samples)
314 SDL_free(mix_input);
315
316 mix_channel[i].samples += mixable;
317 mix_channel[i].playing -= mixable;
318 index += mixable;
319
320 /* rcg06072001 Alert app if channel is done playing. */
321 if (!mix_channel[i].playing && !mix_channel[i].looping) {
322 _Mix_channel_done_playing(i);
323 }
324 }
325
326 /* If looping the sample and we are at its end, make sure
327 we will still return a full buffer */
328 while (mix_channel[i].looping && index < len) {
329 int alen = mix_channel[i].chunk->alen;
330 remaining = len - index;
331 if (remaining > alen) {
332 remaining = alen;
333 }
334
335 mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining);
336 SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume);
337 if (mix_input != mix_channel[i].chunk->abuf)
338 SDL_free(mix_input);
339
340 if (mix_channel[i].looping > 0) {
341 --mix_channel[i].looping;
342 }
343 mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining;
344 mix_channel[i].playing = mix_channel[i].chunk->alen - remaining;
345 index += remaining;
346 }
347 if (! mix_channel[i].playing && mix_channel[i].looping) {
348 if (mix_channel[i].looping > 0) {
349 --mix_channel[i].looping;
350 }
351 mix_channel[i].samples = mix_channel[i].chunk->abuf;
352 mix_channel[i].playing = mix_channel[i].chunk->alen;
353 }
354 }
355 }
356 }
357
358 /* rcg06122001 run posteffects... */
359 Mix_DoEffects(MIX_CHANNEL_POST, stream, len);
360
361 if (mix_postmix) {
362 mix_postmix(mix_postmix_data, stream, len);
363 }
364 }
365
366 #if 0
367 static void PrintFormat(char *title, SDL_AudioSpec *fmt)
368 {
369 printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF),
370 (fmt->format&0x8000) ? "signed" : "unsigned",
371 (fmt->channels > 2) ? "surround" :
372 (fmt->channels > 1) ? "stereo" : "mono", fmt->freq);
373 }
374 #endif
375
376 /* Open the mixer with a certain desired audio format */
377 int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize,
378 const char* device, int allowed_changes)
379 {
380 int i;
381 SDL_AudioSpec desired;
382
383 /* This used to call SDL_OpenAudio(), which initializes the audio
384 subsystem if necessary. Since SDL_OpenAudioDevice() doesn't,
385 we have to handle this case here. */
386 if (!SDL_WasInit(SDL_INIT_AUDIO)) {
387 if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
388 return -1;
389 }
390 }
391
392 /* If the mixer is already opened, increment open count */
393 if (audio_opened) {
394 if (format == mixer.format && nchannels == mixer.channels) {
395 ++audio_opened;
396 return(0);
397 }
398 while (audio_opened) {
399 Mix_CloseAudio();
400 }
401 }
402
403 /* Set the desired format and frequency */
404 desired.freq = frequency;
405 desired.format = format;
406 desired.channels = nchannels;
407 desired.samples = chunksize;
408 desired.callback = mix_channels;
409 desired.userdata = NULL;
410
411 /* Accept nearly any audio format */
412 if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) {
413 return(-1);
414 }
415 #if 0
416 PrintFormat("Audio device", &mixer);
417 #endif
418
419 num_channels = MIX_CHANNELS;
420 mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel));
421
422 /* Clear out the audio channels */
423 for (i=0; i<num_channels; ++i) {
424 mix_channel[i].chunk = NULL;
425 mix_channel[i].playing = 0;
426 mix_channel[i].looping = 0;
427 mix_channel[i].volume = SDL_MIX_MAXVOLUME;
428 mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME;
429 mix_channel[i].fade_volume_reset = SDL_MIX_MAXVOLUME;
430 mix_channel[i].fading = MIX_NO_FADING;
431 mix_channel[i].tag = -1;
432 mix_channel[i].expire = 0;
433 mix_channel[i].effects = NULL;
434 mix_channel[i].paused = 0;
435 }
436 Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
437
438 _Mix_InitEffects();
439
440 add_chunk_decoder("WAVE");
441 add_chunk_decoder("AIFF");
442 add_chunk_decoder("VOC");
443
444 /* Initialize the music players */
445 open_music(&mixer);
446
447 audio_opened = 1;
448 SDL_PauseAudioDevice(audio_device, 0);
449 return(0);
450 }
451
452 /* Open the mixer with a certain desired audio format */
453 int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
454 {
455 return Mix_OpenAudioDevice(frequency, format, nchannels, chunksize, NULL,
456 SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
457 SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
458 }
459
460 /* Dynamically change the number of channels managed by the mixer.
461 If decreasing the number of channels, the upper channels are
462 stopped.
463 */
464 int Mix_AllocateChannels(int numchans)
465 {
466 if (numchans<0 || numchans==num_channels)
467 return(num_channels);
468
469 if (numchans < num_channels) {
470 /* Stop the affected channels */
471 int i;
472 for(i=numchans; i < num_channels; i++) {
473 Mix_UnregisterAllEffects(i);
474 Mix_HaltChannel(i);
475 }
476 }
477 Mix_LockAudio();
478 mix_channel = (struct _Mix_Channel *) SDL_realloc(mix_channel, numchans * sizeof(struct _Mix_Channel));
479 if (numchans > num_channels) {
480 /* Initialize the new channels */
481 int i;
482 for(i=num_channels; i < numchans; i++) {
483 mix_channel[i].chunk = NULL;
484 mix_channel[i].playing = 0;
485 mix_channel[i].looping = 0;
486 mix_channel[i].volume = MIX_MAX_VOLUME;
487 mix_channel[i].fade_volume = MIX_MAX_VOLUME;
488 mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME;
489 mix_channel[i].fading = MIX_NO_FADING;
490 mix_channel[i].tag = -1;
491 mix_channel[i].expire = 0;
492 mix_channel[i].effects = NULL;
493 mix_channel[i].paused = 0;
494 }
495 }
496 num_channels = numchans;
497 Mix_UnlockAudio();
498 return(num_channels);
499 }
500
501 /* Return the actual mixer parameters */
502 int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels)
503 {
504 if (audio_opened) {
505 if (frequency) {
506 *frequency = mixer.freq;
507 }
508 if (format) {
509 *format = mixer.format;
510 }
511 if (channels) {
512 *channels = mixer.channels;
513 }
514 }
515 return(audio_opened);
516 }
517
518 typedef struct _MusicFragment
519 {
520 Uint8 *data;
521 int size;
522 struct _MusicFragment *next;
523 } MusicFragment;
524
525 static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
526 {
527 int i;
528 Mix_MusicType music_type;
529 Mix_MusicInterface *interface = NULL;
530 void *music = NULL;
531 Sint64 start;
532 SDL_bool playing;
533 MusicFragment *first = NULL, *last = NULL, *fragment = NULL;
534 int count = 0;
535 int fragment_size;
536
537 music_type = detect_music_type(src);
538 if (!load_music_type(music_type) || !open_music_type(music_type)) {
539 return NULL;
540 }
541
542 *spec = mixer;
543
544 /* Use fragments sized on full audio frame boundaries - this'll do */
545 fragment_size = spec->size;
546
547 start = SDL_RWtell(src);
548 for (i = 0; i < get_num_music_interfaces(); ++i) {
549 interface = get_music_interface(i);
550 if (!interface->opened) {
551 continue;
552 }
553 if (interface->type != music_type) {
554 continue;
555 }
556 if (!interface->CreateFromRW || !interface->GetAudio) {
557 continue;
558 }
559
560 /* These music interfaces are not safe to use while music is playing */
561 if (interface->api == MIX_MUSIC_CMD ||
562 interface->api == MIX_MUSIC_MIKMOD ||
563 interface->api == MIX_MUSIC_NATIVEMIDI) {
564 continue;
565 }
566
567 music = interface->CreateFromRW(src, freesrc);
568 if (music) {
569 /* The interface owns the data source now */
570 freesrc = SDL_FALSE;
571 break;
572 }
573
574 /* Reset the stream for the next decoder */
575 SDL_RWseek(src, start, RW_SEEK_SET);
576 }
577
578 if (!music) {
579 if (freesrc) {
580 SDL_RWclose(src);
581 }
582 Mix_SetError("Unrecognized audio format");
583 return NULL;
584 }
585
586 Mix_LockAudio();
587
588 if (interface->Play) {
589 interface->Play(music, 1);
590 }
591 playing = SDL_TRUE;
592
593 while (playing) {
594 int left;
595
596 fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment));
597 if (!fragment) {
598 /* Uh oh, out of memory, let's return what we have */
599 break;
600 }
601 fragment->data = (Uint8 *)SDL_malloc(fragment_size);
602 if (!fragment->data) {
603 /* Uh oh, out of memory, let's return what we have */
604 SDL_free(fragment);
605 break;
606 }
607 fragment->next = NULL;
608
609 left = interface->GetAudio(music, fragment->data, fragment_size);
610 if (left > 0) {
611 playing = SDL_FALSE;
612 } else if (interface->IsPlaying) {
613 playing = interface->IsPlaying(music);
614 }
615 fragment->size = (fragment_size - left);
616
617 if (!first) {
618 first = fragment;
619 }
620 if (last) {
621 last->next = fragment;
622 }
623 last = fragment;
624 ++count;
625 }
626
627 if (interface->Stop) {
628 interface->Stop(music);
629 }
630
631 if (music) {
632 interface->Delete(music);
633 }
634
635 Mix_UnlockAudio();
636
637 if (count > 0) {
638 *audio_len = (count - 1) * fragment_size + fragment->size;
639 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
640 if (*audio_buf) {
641 Uint8 *dst = *audio_buf;
642 for (fragment = first; fragment; fragment = fragment->next) {
643 SDL_memcpy(dst, fragment->data, fragment->size);
644 dst += fragment->size;
645 }
646 } else {
647 SDL_OutOfMemory();
648 spec = NULL;
649 }
650 } else {
651 Mix_SetError("No audio data");
652 spec = NULL;
653 }
654
655 while (first) {
656 fragment = first;
657 first = first->next;
658 SDL_free(fragment->data);
659 SDL_free(fragment);
660 }
661
662 if (freesrc) {
663 SDL_RWclose(src);
664 }
665 return spec;
666 }
667
668 /* Load a wave file */
669 Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
670 {
671 Uint8 magic[4];
672 Mix_Chunk *chunk;
673 SDL_AudioSpec wavespec, *loaded;
674 SDL_AudioCVT wavecvt;
675 int samplesize;
676
677 /* rcg06012001 Make sure src is valid */
678 if (!src) {
679 SDL_SetError("Mix_LoadWAV_RW with NULL src");
680 return(NULL);
681 }
682
683 /* Make sure audio has been opened */
684 if (!audio_opened) {
685 SDL_SetError("Audio device hasn't been opened");
686 if (freesrc) {
687 SDL_RWclose(src);
688 }
689 return(NULL);
690 }
691
692 /* Allocate the chunk memory */
693 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
694 if (chunk == NULL) {
695 SDL_SetError("Out of memory");
696 if (freesrc) {
697 SDL_RWclose(src);
698 }
699 return(NULL);
700 }
701
702 /* Find out what kind of audio file this is */
703 if (SDL_RWread(src, magic, 1, 4) != 4) {
704 SDL_free(chunk);
705 if (freesrc) {
706 SDL_RWclose(src);
707 }
708 Mix_SetError("Couldn't read first 4 bytes of audio data");
709 return NULL;
710 }
711 /* Seek backwards for compatibility with older loaders */
712 SDL_RWseek(src, -4, RW_SEEK_CUR);
713
714 if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) {
715 loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
716 } else if (SDL_memcmp(magic, "FORM", 4) == 0) {
717 loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
718 } else if (SDL_memcmp(magic, "Crea", 4) == 0) {
719 loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
720 } else {
721 loaded = Mix_LoadMusic_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
722 }
723 if (!loaded) {
724 /* The individual loaders have closed src if needed */
725 SDL_free(chunk);
726 return(NULL);
727 }
728
729 #if 0
730 PrintFormat("Audio device", &mixer);
731 PrintFormat("-- Wave file", &wavespec);
732 #endif
733
734 /* Build the audio converter and create conversion buffers */
735 if (wavespec.format != mixer.format ||
736 wavespec.channels != mixer.channels ||
737 wavespec.freq != mixer.freq) {
738 if (SDL_BuildAudioCVT(&wavecvt,
739 wavespec.format, wavespec.channels, wavespec.freq,
740 mixer.format, mixer.channels, mixer.freq) < 0) {
741 SDL_free(chunk->abuf);
742 SDL_free(chunk);
743 return(NULL);
744 }
745 samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels;
746 wavecvt.len = chunk->alen & ~(samplesize-1);
747 wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
748 if (wavecvt.buf == NULL) {
749 SDL_SetError("Out of memory");
750 SDL_free(chunk->abuf);
751 SDL_free(chunk);
752 return(NULL);
753 }
754 SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len);
755 SDL_free(chunk->abuf);
756
757 /* Run the audio converter */
758 if (SDL_ConvertAudio(&wavecvt) < 0) {
759 SDL_free(wavecvt.buf);
760 SDL_free(chunk);
761 return(NULL);
762 }
763
764 chunk->abuf = wavecvt.buf;
765 chunk->alen = wavecvt.len_cvt;
766 }
767
768 chunk->allocated = 1;
769 chunk->volume = MIX_MAX_VOLUME;
770
771 return(chunk);
772 }
773
774 /* Load a wave file of the mixer format from a memory buffer */
775 Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem)
776 {
777 Mix_Chunk *chunk;
778 Uint8 magic[4];
779
780 /* Make sure audio has been opened */
781 if (! audio_opened) {
782 SDL_SetError("Audio device hasn't been opened");
783 return(NULL);
784 }
785
786 /* Allocate the chunk memory */
787 chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk));
788 if (chunk == NULL) {
789 SDL_SetError("Out of memory");
790 return(NULL);
791 }
792
793 /* Essentially just skip to the audio data (no error checking - fast) */
794 chunk->allocated = 0;
795 mem += 12; /* WAV header */
796 do {
797 SDL_memcpy(magic, mem, 4);
798 mem += 4;
799 chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0]));
800 mem += 4;
801 chunk->abuf = mem;
802 mem += chunk->alen;
803 } while (SDL_memcmp(magic, "data", 4) != 0);
804 chunk->volume = MIX_MAX_VOLUME;
805
806 return(chunk);
807 }
808
809 /* Load raw audio data of the mixer format from a memory buffer */
810 Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len)
811 {
812 Mix_Chunk *chunk;
813
814 /* Make sure audio has been opened */
815 if (! audio_opened) {
816 SDL_SetError("Audio device hasn't been opened");
817 return(NULL);
818 }
819
820 /* Allocate the chunk memory */
821 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
822 if (chunk == NULL) {
823 SDL_SetError("Out of memory");
824 return(NULL);
825 }
826
827 /* Essentially just point at the audio data (no error checking - fast) */
828 chunk->allocated = 0;
829 chunk->alen = len;
830 chunk->abuf = mem;
831 chunk->volume = MIX_MAX_VOLUME;
832
833 return(chunk);
834 }
835
836 /* Free an audio chunk previously loaded */
837 void Mix_FreeChunk(Mix_Chunk *chunk)
838 {
839 int i;
840
841 /* Caution -- if the chunk is playing, the mixer will crash */
842 if (chunk) {
843 /* Guarantee that this chunk isn't playing */
844 Mix_LockAudio();
845 if (mix_channel) {
846 for (i=0; i<num_channels; ++i) {
847 if (chunk == mix_channel[i].chunk) {
848 mix_channel[i].playing = 0;
849 mix_channel[i].looping = 0;
850 }
851 }
852 }
853 Mix_UnlockAudio();
854 /* Actually free the chunk */
855 if (chunk->allocated) {
856 SDL_free(chunk->abuf);
857 }
858 SDL_free(chunk);
859 }
860 }
861
862 /* Set a function that is called after all mixing is performed.
863 This can be used to provide real-time visual display of the audio stream
864 or add a custom mixer filter for the stream data.
865 */
866 void Mix_SetPostMix(void (SDLCALL *mix_func)
867 (void *udata, Uint8 *stream, int len), void *arg)
868 {
869 Mix_LockAudio();
870 mix_postmix_data = arg;
871 mix_postmix = mix_func;
872 Mix_UnlockAudio();
873 }
874
875 /* Add your own music player or mixer function.
876 If 'mix_func' is NULL, the default music player is re-enabled.
877 */
878 void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len),
879 void *arg)
880 {
881 Mix_LockAudio();
882 if (mix_func != NULL) {
883 music_data = arg;
884 mix_music = mix_func;
885 } else {
886 music_data = NULL;
887 mix_music = music_mixer;
888 }
889 Mix_UnlockAudio();
890 }
891
892 void *Mix_GetMusicHookData(void)
893 {
894 return(music_data);
895 }
896
897 void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel))
898 {
899 Mix_LockAudio();
900 channel_done_callback = channel_finished;
901 Mix_UnlockAudio();
902 }
903
904
905 /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
906 them dynamically to the next sample if requested with a -1 value below.
907 Returns the number of reserved channels.
908 */
909 int Mix_ReserveChannels(int num)
910 {
911 if (num > num_channels)
912 num = num_channels;
913 reserved_channels = num;
914 return num;
915 }
916
917 static int checkchunkintegral(Mix_Chunk *chunk)
918 {
919 int frame_width = 1;
920
921 if ((mixer.format & 0xFF) == 16) frame_width = 2;
922 frame_width *= mixer.channels;
923 while (chunk->alen % frame_width) chunk->alen--;
924 return chunk->alen;
925 }
926
927 /* Play an audio chunk on a specific channel.
928 If the specified channel is -1, play on the first free channel.
929 'ticks' is the number of milliseconds at most to play the sample, or -1
930 if there is no limit.
931 Returns which channel was used to play the sound.
932 */
933 int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
934 {
935 int i;
936
937 /* Don't play null pointers :-) */
938 if (chunk == NULL) {
939 Mix_SetError("Tried to play a NULL chunk");
940 return(-1);
941 }
942 if (!checkchunkintegral(chunk)) {
943 Mix_SetError("Tried to play a chunk with a bad frame");
944 return(-1);
945 }
946
947 /* Lock the mixer while modifying the playing channels */
948 Mix_LockAudio();
949 {
950 /* If which is -1, play on the first free channel */
951 if (which == -1) {
952 for (i=reserved_channels; i<num_channels; ++i) {
953 if (!Mix_Playing(i))
954 break;
955 }
956 if (i == num_channels) {
957 Mix_SetError("No free channels available");
958 which = -1;
959 } else {
960 which = i;
961 }
962 } else {
963 if (Mix_Playing(which))
964 _Mix_channel_done_playing(which);
965 }
966
967 /* Queue up the audio data for this channel */
968 if (which >= 0 && which < num_channels) {
969 Uint32 sdl_ticks = SDL_GetTicks();
970 mix_channel[which].samples = chunk->abuf;
971 mix_channel[which].playing = (int)chunk->alen;
972 mix_channel[which].looping = loops;
973 mix_channel[which].chunk = chunk;
974 mix_channel[which].paused = 0;
975 mix_channel[which].fading = MIX_NO_FADING;
976 mix_channel[which].start_time = sdl_ticks;
977 mix_channel[which].expire = (ticks > 0) ? (sdl_ticks + (Uint32)ticks) : 0;
978 }
979 }
980 Mix_UnlockAudio();
981
982 /* Return the channel on which the sound is being played */
983 return(which);
984 }
985
986 /* Change the expiration delay for a channel */
987 int Mix_ExpireChannel(int which, int ticks)
988 {
989 int status = 0;
990
991 if (which == -1) {
992 int i;
993 for (i=0; i < num_channels; ++ i) {
994 status += Mix_ExpireChannel(i, ticks);
995 }
996 } else if (which < num_channels) {
997 Mix_LockAudio();
998 mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + (Uint32)ticks) : 0;
999 Mix_UnlockAudio();
1000 ++ status;
1001 }
1002 return(status);
1003 }
1004
1005 /* Fade in a sound on a channel, over ms milliseconds */
1006 int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int ticks)
1007 {
1008 int i;
1009
1010 /* Don't play null pointers :-) */
1011 if (chunk == NULL) {
1012 return(-1);
1013 }
1014 if (!checkchunkintegral(chunk)) {
1015 Mix_SetError("Tried to play a chunk with a bad frame");
1016 return(-1);
1017 }
1018
1019 /* Lock the mixer while modifying the playing channels */
1020 Mix_LockAudio();
1021 {
1022 /* If which is -1, play on the first free channel */
1023 if (which == -1) {
1024 for (i=reserved_channels; i<num_channels; ++i) {
1025 if (!Mix_Playing(i))
1026 break;
1027 }
1028 if (i == num_channels) {
1029 which = -1;
1030 } else {
1031 which = i;
1032 }
1033 } else {
1034 if (Mix_Playing(which))
1035 _Mix_channel_done_playing(which);
1036 }
1037
1038 /* Queue up the audio data for this channel */
1039 if (which >= 0 && which < num_channels) {
1040 Uint32 sdl_ticks = SDL_GetTicks();
1041 mix_channel[which].samples = chunk->abuf;
1042 mix_channel[which].playing = (int)chunk->alen;
1043 mix_channel[which].looping = loops;
1044 mix_channel[which].chunk = chunk;
1045 mix_channel[which].paused = 0;
1046 if (mix_channel[which].fading == MIX_NO_FADING) {
1047 mix_channel[which].fade_volume_reset = mix_channel[which].volume;
1048 }
1049 mix_channel[which].fading = MIX_FADING_IN;
1050 mix_channel[which].fade_volume = mix_channel[which].volume;
1051 mix_channel[which].volume = 0;
1052 mix_channel[which].fade_length = (Uint32)ms;
1053 mix_channel[which].start_time = mix_channel[which].ticks_fade = sdl_ticks;
1054 mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+(Uint32)ticks) : 0;
1055 }
1056 }
1057 Mix_UnlockAudio();
1058
1059 /* Return the channel on which the sound is being played */
1060 return(which);
1061 }
1062
1063 /* Set volume of a particular channel */
1064 int Mix_Volume(int which, int volume)
1065 {
1066 int i;
1067 int prev_volume = 0;
1068
1069 if (which == -1) {
1070 for (i=0; i<num_channels; ++i) {
1071 prev_volume += Mix_Volume(i, volume);
1072 }
1073 prev_volume /= num_channels;
1074 } else if (which < num_channels) {
1075 prev_volume = mix_channel[which].volume;
1076 if (volume >= 0) {
1077 if (volume > MIX_MAX_VOLUME) {
1078 volume = MIX_MAX_VOLUME;
1079 }
1080 mix_channel[which].volume = volume;
1081 }
1082 }
1083 return(prev_volume);
1084 }
1085 /* Set volume of a particular chunk */
1086 int Mix_VolumeChunk(Mix_Chunk *chunk, int volume)
1087 {
1088 int prev_volume;
1089
1090 if (chunk == NULL) {
1091 return(-1);
1092 }
1093 prev_volume = chunk->volume;
1094 if (volume >= 0) {
1095 if (volume > MIX_MAX_VOLUME) {
1096 volume = MIX_MAX_VOLUME;
1097 }
1098 chunk->volume = volume;
1099 }
1100 return(prev_volume);
1101 }
1102
1103 /* Halt playing of a particular channel */
1104 int Mix_HaltChannel(int which)
1105 {
1106 int i;
1107
1108 if (which == -1) {
1109 for (i=0; i<num_channels; ++i) {
1110 Mix_HaltChannel(i);
1111 }
1112 } else if (which < num_channels) {
1113 Mix_LockAudio();
1114 if (Mix_Playing(which)) {
1115 _Mix_channel_done_playing(which);
1116 mix_channel[which].playing = 0;
1117 mix_channel[which].looping = 0;
1118 }
1119 mix_channel[which].expire = 0;
1120 if (mix_channel[which].fading != MIX_NO_FADING) /* Restore volume */
1121 mix_channel[which].volume = mix_channel[which].fade_volume_reset;
1122 mix_channel[which].fading = MIX_NO_FADING;
1123 Mix_UnlockAudio();
1124 }
1125 return(0);
1126 }
1127
1128 /* Halt playing of a particular group of channels */
1129 int Mix_HaltGroup(int tag)
1130 {
1131 int i;
1132
1133 for (i=0; i<num_channels; ++i) {
1134 if (mix_channel[i].tag == tag) {
1135 Mix_HaltChannel(i);
1136 }
1137 }
1138 return(0);
1139 }
1140
1141 /* Fade out a channel and then stop it automatically */
1142 int Mix_FadeOutChannel(int which, int ms)
1143 {
1144 int status;
1145
1146 status = 0;
1147 if (audio_opened) {
1148 if (which == -1) {
1149 int i;
1150
1151 for (i=0; i<num_channels; ++i) {
1152 status += Mix_FadeOutChannel(i, ms);
1153 }
1154 } else if (which < num_channels) {
1155 Mix_LockAudio();
1156 if (Mix_Playing(which) &&
1157 (mix_channel[which].volume > 0) &&
1158 (mix_channel[which].fading != MIX_FADING_OUT)) {
1159 mix_channel[which].fade_volume = mix_channel[which].volume;
1160 mix_channel[which].fade_length = (Uint32)ms;
1161 mix_channel[which].ticks_fade = SDL_GetTicks();
1162
1163 /* only change fade_volume_reset if we're not fading. */
1164 if (mix_channel[which].fading == MIX_NO_FADING) {
1165 mix_channel[which].fade_volume_reset = mix_channel[which].volume;
1166 }
1167
1168 mix_channel[which].fading = MIX_FADING_OUT;
1169
1170 ++status;
1171 }
1172 Mix_UnlockAudio();
1173 }
1174 }
1175 return(status);
1176 }
1177
1178 /* Halt playing of a particular group of channels */
1179 int Mix_FadeOutGroup(int tag, int ms)
1180 {
1181 int i;
1182 int status = 0;
1183 for (i=0; i<num_channels; ++i) {
1184 if (mix_channel[i].tag == tag) {
1185 status += Mix_FadeOutChannel(i,ms);
1186 }
1187 }
1188 return(status);
1189 }
1190
1191 Mix_Fading Mix_FadingChannel(int which)
1192 {
1193 if (which < 0 || which >= num_channels) {
1194 return MIX_NO_FADING;
1195 }
1196 return mix_channel[which].fading;
1197 }
1198
1199 /* Check the status of a specific channel.
1200 If the specified mix_channel is -1, check all mix channels.
1201 */
1202 int Mix_Playing(int which)
1203 {
1204 int status;
1205
1206 status = 0;
1207 if (which == -1) {
1208 int i;
1209
1210 for (i=0; i<num_channels; ++i) {
1211 if ((mix_channel[i].playing > 0) ||
1212 mix_channel[i].looping)
1213 {
1214 ++status;
1215 }
1216 }
1217 } else if (which < num_channels) {
1218 if ((mix_channel[which].playing > 0) ||
1219 mix_channel[which].looping)
1220 {
1221 ++status;
1222 }
1223 }
1224 return(status);
1225 }
1226
1227 /* rcg06072001 Get the chunk associated with a channel. */
1228 Mix_Chunk *Mix_GetChunk(int channel)
1229 {
1230 Mix_Chunk *retval = NULL;
1231
1232 if ((channel >= 0) && (channel < num_channels)) {
1233 retval = mix_channel[channel].chunk;
1234 }
1235
1236 return(retval);
1237 }
1238
1239 /* Close the mixer, halting all playing audio */
1240 void Mix_CloseAudio(void)
1241 {
1242 int i;
1243
1244 if (audio_opened) {
1245 if (audio_opened == 1) {
1246 for (i = 0; i < num_channels; i++) {
1247 Mix_UnregisterAllEffects(i);
1248 }
1249 Mix_UnregisterAllEffects(MIX_CHANNEL_POST);
1250 close_music();
1251 Mix_SetMusicCMD(NULL);
1252 Mix_HaltChannel(-1);
1253 _Mix_DeinitEffects();
1254 SDL_CloseAudioDevice(audio_device);
1255 audio_device = 0;
1256 SDL_free(mix_channel);
1257 mix_channel = NULL;
1258
1259 /* rcg06042009 report available decoders at runtime. */
1260 SDL_free((void *)chunk_decoders);
1261 chunk_decoders = NULL;
1262 num_decoders = 0;
1263 }
1264 --audio_opened;
1265 }
1266 }
1267
1268 /* Pause a particular channel (or all) */
1269 void Mix_Pause(int which)
1270 {
1271 Uint32 sdl_ticks = SDL_GetTicks();
1272 if (which == -1) {
1273 int i;
1274
1275 for (i=0; i<num_channels; ++i) {
1276 if (Mix_Playing(i)) {
1277 mix_channel[i].paused = sdl_ticks;
1278 }
1279 }
1280 } else if (which < num_channels) {
1281 if (Mix_Playing(which)) {
1282 mix_channel[which].paused = sdl_ticks;
1283 }
1284 }
1285 }
1286
1287 /* Resume a paused channel */
1288 void Mix_Resume(int which)
1289 {
1290 Uint32 sdl_ticks = SDL_GetTicks();
1291
1292 Mix_LockAudio();
1293 if (which == -1) {
1294 int i;
1295
1296 for (i=0; i<num_channels; ++i) {
1297 if (Mix_Playing(i)) {
1298 if (mix_channel[i].expire > 0)
1299 mix_channel[i].expire += sdl_ticks - mix_channel[i].paused;
1300 mix_channel[i].paused = 0;
1301 }
1302 }
1303 } else if (which < num_channels) {
1304 if (Mix_Playing(which)) {
1305 if (mix_channel[which].expire > 0)
1306 mix_channel[which].expire += sdl_ticks - mix_channel[which].paused;
1307 mix_channel[which].paused = 0;
1308 }
1309 }
1310 Mix_UnlockAudio();
1311 }
1312
1313 int Mix_Paused(int which)
1314 {
1315 if (which < 0) {
1316 int status = 0;
1317 int i;
1318 for(i=0; i < num_channels; ++i) {
1319 if (mix_channel[i].paused) {
1320 ++ status;
1321 }
1322 }
1323 return(status);
1324 } else if (which < num_channels) {
1325 return(mix_channel[which].paused != 0);
1326 } else {
1327 return(0);
1328 }
1329 }
1330
1331 /* Change the group of a channel */
1332 int Mix_GroupChannel(int which, int tag)
1333 {
1334 if (which < 0 || which > num_channels)
1335 return(0);
1336
1337 Mix_LockAudio();
1338 mix_channel[which].tag = tag;
1339 Mix_UnlockAudio();
1340 return(1);
1341 }
1342
1343 /* Assign several consecutive channels to a group */
1344 int Mix_GroupChannels(int from, int to, int tag)
1345 {
1346 int status = 0;
1347 for(; from <= to; ++ from) {
1348 status += Mix_GroupChannel(from, tag);
1349 }
1350 return(status);
1351 }
1352
1353 /* Finds the first available channel in a group of channels */
1354 int Mix_GroupAvailable(int tag)
1355 {
1356 int i;
1357 for(i=0; i < num_channels; i ++) {
1358 if (((tag == -1) || (tag == mix_channel[i].tag)) &&
1359 (!Mix_Playing(i)))
1360 return i;
1361 }
1362 return(-1);
1363 }
1364
1365 int Mix_GroupCount(int tag)
1366 {
1367 int count = 0;
1368 int i;
1369 for(i=0; i < num_channels; i ++) {
1370 if (mix_channel[i].tag==tag || tag==-1)
1371 ++ count;
1372 }
1373 return(count);
1374 }
1375
1376 /* Finds the "oldest" sample playing in a group of channels */
1377 int Mix_GroupOldest(int tag)
1378 {
1379 int chan = -1;
1380 Uint32 mintime = SDL_GetTicks();
1381 int i;
1382 for(i=0; i < num_channels; i ++) {
1383 if ((mix_channel[i].tag==tag || tag==-1) && Mix_Playing(i)
1384 && mix_channel[i].start_time <= mintime) {
1385 mintime = mix_channel[i].start_time;
1386 chan = i;
1387 }
1388 }
1389 return(chan);
1390 }
1391
1392 /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
1393 int Mix_GroupNewer(int tag)
1394 {
1395 int chan = -1;
1396 Uint32 maxtime = 0;
1397 int i;
1398 for(i=0; i < num_channels; i ++) {
1399 if ((mix_channel[i].tag==tag || tag==-1) && Mix_Playing(i)
1400 && mix_channel[i].start_time >= maxtime) {
1401 maxtime = mix_channel[i].start_time;
1402 chan = i;
1403 }
1404 }
1405 return(chan);
1406 }
1407
1408
1409
1410 /*
1411 * rcg06122001 The special effects exportable API.
1412 * Please see effect_*.c for internally-implemented effects, such
1413 * as Mix_SetPanning().
1414 */
1415
1416 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1417 static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f,
1418 Mix_EffectDone_t d, void *arg)
1419 {
1420 effect_info *new_e;
1421
1422 if (!e) {
1423 Mix_SetError("Internal error");
1424 return(0);
1425 }
1426
1427 if (f == NULL) {
1428 Mix_SetError("NULL effect callback");
1429 return(0);
1430 }
1431
1432 new_e = SDL_malloc(sizeof (effect_info));
1433 if (new_e == NULL) {
1434 Mix_SetError("Out of memory");
1435 return(0);
1436 }
1437
1438 new_e->callback = f;
1439 new_e->done_callback = d;
1440 new_e->udata = arg;
1441 new_e->next = NULL;
1442
1443 /* add new effect to end of linked list... */
1444 if (*e == NULL) {
1445 *e = new_e;
1446 } else {
1447 effect_info *cur = *e;
1448 while (1) {
1449 if (cur->next == NULL) {
1450 cur->next = new_e;
1451 break;
1452 }
1453 cur = cur->next;
1454 }
1455 }
1456
1457 return(1);
1458 }
1459
1460
1461 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1462 static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f)
1463 {
1464 effect_info *cur;
1465 effect_info *prev = NULL;
1466 effect_info *next = NULL;
1467
1468 if (!e) {
1469 Mix_SetError("Internal error");
1470 return(0);
1471 }
1472
1473 for (cur = *e; cur != NULL; cur = cur->next) {
1474 if (cur->callback == f) {
1475 next = cur->next;
1476 if (cur->done_callback != NULL) {
1477 cur->done_callback(channel, cur->udata);
1478 }
1479 SDL_free(cur);
1480
1481 if (prev == NULL) { /* removing first item of list? */
1482 *e = next;
1483 } else {
1484 prev->next = next;
1485 }
1486 return(1);
1487 }
1488 prev = cur;
1489 }
1490
1491 Mix_SetError("No such effect registered");
1492 return(0);
1493 }
1494
1495
1496 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1497 static int _Mix_remove_all_effects(int channel, effect_info **e)
1498 {
1499 effect_info *cur;
1500 effect_info *next;
1501
1502 if (!e) {
1503 Mix_SetError("Internal error");
1504 return(0);
1505 }
1506
1507 for (cur = *e; cur != NULL; cur = next) {
1508 next = cur->next;
1509 if (cur->done_callback != NULL) {
1510 cur->done_callback(channel, cur->udata);
1511 }
1512 SDL_free(cur);
1513 }
1514 *e = NULL;
1515
1516 return(1);
1517 }
1518
1519
1520 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1521 int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
1522 Mix_EffectDone_t d, void *arg)
1523 {
1524 effect_info **e = NULL;
1525
1526 if (channel == MIX_CHANNEL_POST) {
1527 e = &posteffects;
1528 } else {
1529 if ((channel < 0) || (channel >= num_channels)) {
1530 Mix_SetError("Invalid channel number");
1531 return(0);
1532 }
1533 e = &mix_channel[channel].effects;
1534 }
1535
1536 return _Mix_register_effect(e, f, d, arg);
1537 }
1538
1539 int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f,
1540 Mix_EffectDone_t d, void *arg)
1541 {
1542 int retval;
1543 Mix_LockAudio();
1544 retval = _Mix_RegisterEffect_locked(channel, f, d, arg);
1545 Mix_UnlockAudio();
1546 return retval;
1547 }
1548
1549
1550 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1551 int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f)
1552 {
1553 effect_info **e = NULL;
1554
1555 if (channel == MIX_CHANNEL_POST) {
1556 e = &posteffects;
1557 } else {
1558 if ((channel < 0) || (channel >= num_channels)) {
1559 Mix_SetError("Invalid channel number");
1560 return(0);
1561 }
1562 e = &mix_channel[channel].effects;
1563 }
1564
1565 return _Mix_remove_effect(channel, e, f);
1566 }
1567
1568 int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
1569 {
1570 int retval;
1571 Mix_LockAudio();
1572 retval = _Mix_UnregisterEffect_locked(channel, f);
1573 Mix_UnlockAudio();
1574 return(retval);
1575 }
1576
1577 /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
1578 int _Mix_UnregisterAllEffects_locked(int channel)
1579 {
1580 effect_info **e = NULL;
1581
1582 if (channel == MIX_CHANNEL_POST) {
1583 e = &posteffects;
1584 } else {
1585 if ((channel < 0) || (channel >= num_channels)) {
1586 Mix_SetError("Invalid channel number");
1587 return(0);
1588 }
1589 e = &mix_channel[channel].effects;
1590 }
1591
1592 return _Mix_remove_all_effects(channel, e);
1593 }
1594
1595 int Mix_UnregisterAllEffects(int channel)
1596 {
1597 int retval;
1598 Mix_LockAudio();
1599 retval = _Mix_UnregisterAllEffects_locked(channel);
1600 Mix_UnlockAudio();
1601 return(retval);
1602 }
1603
1604 void Mix_LockAudio(void)
1605 {
1606 SDL_LockAudioDevice(audio_device);
1607 }
1608
1609 void Mix_UnlockAudio(void)
1610 {
1611 SDL_UnlockAudioDevice(audio_device);
1612 }
1613
1614 /* end of mixer.c ... */
1615
1616 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* Locking wrapper functions */
22 extern void Mix_LockAudio(void);
23 extern void Mix_UnlockAudio(void);
24
25 extern void add_chunk_decoder(const char *decoder);
26
27 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_hints.h"
21 #include "SDL_log.h"
22 #include "SDL_timer.h"
23
24 #include "SDL_mixer.h"
25 #include "mixer.h"
26 #include "music.h"
27
28 #include "music_cmd.h"
29 #include "music_wav.h"
30 #include "music_mikmod.h"
31 #include "music_modplug.h"
32 #include "music_xmp.h"
33 #include "music_nativemidi.h"
34 #include "music_fluidsynth.h"
35 #include "music_timidity.h"
36 #include "music_ogg.h"
37 #include "music_opus.h"
38 #include "music_mpg123.h"
39 #include "music_mad.h"
40 #include "music_flac.h"
41 #include "native_midi/native_midi.h"
42
43 #include "utils.h"
44
45 /* Check to make sure we are building with a new enough SDL */
46 #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 7)
47 #error You need SDL 2.0.7 or newer from http://www.libsdl.org
48 #endif
49
50 /* Set this hint to true if you want verbose logging of music interfaces */
51 #define SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES \
52 "SDL_MIXER_DEBUG_MUSIC_INTERFACES"
53
54 char *music_cmd = NULL;
55 static SDL_bool music_active = SDL_TRUE;
56 static int music_volume = MIX_MAX_VOLUME;
57 static Mix_Music * volatile music_playing = NULL;
58 SDL_AudioSpec music_spec;
59
60 struct _Mix_Music {
61 Mix_MusicInterface *interface;
62 void *context;
63
64 SDL_bool playing;
65 Mix_Fading fading;
66 int fade_step;
67 int fade_steps;
68
69 char filename[1024];
70 };
71
72 /* Used to calculate fading steps */
73 static int ms_per_step;
74
75 /* rcg06042009 report available decoders at runtime. */
76 static const char **music_decoders = NULL;
77 static int num_decoders = 0;
78
79 /* Semicolon-separated SoundFont paths */
80 static char* soundfont_paths = NULL;
81
82 /* full path of timidity config file */
83 static char* timidity_cfg = NULL;
84
85 /* Meta-Tags utility */
86 void meta_tags_init(Mix_MusicMetaTags *tags)
87 {
88 SDL_memset(tags, 0, sizeof(Mix_MusicMetaTags));
89 }
90
91 void meta_tags_clear(Mix_MusicMetaTags *tags)
92 {
93 size_t i = 0;
94 for (i = 0; i < MIX_META_LAST; i++) {
95 if (tags->tags[i]) {
96 SDL_free(tags->tags[i]);
97 tags->tags[i] = NULL;
98 }
99 }
100 }
101
102 void meta_tags_set(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type, const char *value)
103 {
104 char *out;
105 size_t len;
106
107 if (!value) {
108 return;
109 }
110 if (type >= MIX_META_LAST) {
111 return;
112 }
113
114 len = SDL_strlen(value);
115 out = (char *)SDL_malloc(sizeof(char) * len + 1);
116 SDL_strlcpy(out, value, len +1);
117
118 if (tags->tags[type]) {
119 SDL_free(tags->tags[type]);
120 }
121
122 tags->tags[type] = out;
123 }
124
125 const char *meta_tags_get(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type)
126 {
127 switch (type) {
128 case MIX_META_TITLE:
129 case MIX_META_ARTIST:
130 case MIX_META_ALBUM:
131 case MIX_META_COPYRIGHT:
132 return tags->tags[type] ? tags->tags[type] : "";
133 case MIX_META_LAST:
134 default:
135 break;
136 }
137 return "";
138 }
139
140 /* for music->filename */
141 #if defined(__WIN32__)||defined(__OS2__)
142 static SDL_INLINE const char *get_last_dirsep (const char *p) {
143 const char *p1 = SDL_strrchr(p, '/');
144 const char *p2 = SDL_strrchr(p, '\\');
145 if (!p1) return p2;
146 if (!p2) return p1;
147 return (p1 > p2)? p1 : p2;
148 }
149 #else /* unix */
150 static SDL_INLINE const char *get_last_dirsep (const char *p) {
151 return SDL_strrchr(p, '/');
152 }
153 #endif
154
155
156 /* Interfaces for the various music interfaces, ordered by priority */
157 static Mix_MusicInterface *s_music_interfaces[] =
158 {
159 #ifdef MUSIC_CMD
160 &Mix_MusicInterface_CMD,
161 #endif
162 #ifdef MUSIC_WAV
163 &Mix_MusicInterface_WAV,
164 #endif
165 #ifdef MUSIC_FLAC
166 &Mix_MusicInterface_FLAC,
167 #endif
168 #ifdef MUSIC_OGG
169 &Mix_MusicInterface_OGG,
170 #endif
171 #ifdef MUSIC_OPUS
172 &Mix_MusicInterface_Opus,
173 #endif
174 #ifdef MUSIC_MP3_MPG123
175 &Mix_MusicInterface_MPG123,
176 #endif
177 #ifdef MUSIC_MP3_MAD
178 &Mix_MusicInterface_MAD,
179 #endif
180 #ifdef MUSIC_MOD_XMP
181 &Mix_MusicInterface_XMP,
182 #endif
183 #ifdef MUSIC_MOD_MODPLUG
184 &Mix_MusicInterface_MODPLUG,
185 #endif
186 #ifdef MUSIC_MOD_MIKMOD
187 &Mix_MusicInterface_MIKMOD,
188 #endif
189 #ifdef MUSIC_MID_FLUIDSYNTH
190 &Mix_MusicInterface_FLUIDSYNTH,
191 #endif
192 #ifdef MUSIC_MID_TIMIDITY
193 &Mix_MusicInterface_TIMIDITY,
194 #endif
195 #ifdef MUSIC_MID_NATIVE
196 &Mix_MusicInterface_NATIVEMIDI,
197 #endif
198 };
199
200 int get_num_music_interfaces(void)
201 {
202 return SDL_arraysize(s_music_interfaces);
203 }
204
205 Mix_MusicInterface *get_music_interface(int index)
206 {
207 return s_music_interfaces[index];
208 }
209
210 int Mix_GetNumMusicDecoders(void)
211 {
212 return(num_decoders);
213 }
214
215 const char *Mix_GetMusicDecoder(int index)
216 {
217 if ((index < 0) || (index >= num_decoders)) {
218 return NULL;
219 }
220 return(music_decoders[index]);
221 }
222
223 SDL_bool Mix_HasMusicDecoder(const char *name)
224 {
225 int index;
226 for (index = 0; index < num_decoders; ++index) {
227 if (SDL_strcasecmp(name, music_decoders[index]) == 0) {
228 return SDL_TRUE;
229 }
230 }
231 return SDL_FALSE;
232 }
233
234 static void add_music_decoder(const char *decoder)
235 {
236 void *ptr;
237 int i;
238
239 /* Check to see if we already have this decoder */
240 for (i = 0; i < num_decoders; ++i) {
241 if (SDL_strcmp(music_decoders[i], decoder) == 0) {
242 return;
243 }
244 }
245
246 ptr = SDL_realloc((void *)music_decoders, ((size_t)num_decoders + 1) * sizeof (const char *));
247 if (ptr == NULL) {
248 return; /* oh well, go on without it. */
249 }
250 music_decoders = (const char **) ptr;
251 music_decoders[num_decoders++] = decoder;
252 }
253
254 /* Local low-level functions prototypes */
255 static void music_internal_initialize_volume(void);
256 static void music_internal_volume(int volume);
257 static int music_internal_play(Mix_Music *music, int play_count, double position);
258 static int music_internal_position(double position);
259 static SDL_bool music_internal_playing(void);
260 static void music_internal_halt(void);
261
262
263 /* Support for hooking when the music has finished */
264 static void (SDLCALL *music_finished_hook)(void) = NULL;
265
266 void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void))
267 {
268 Mix_LockAudio();
269 music_finished_hook = music_finished;
270 Mix_UnlockAudio();
271 }
272
273 /* Convenience function to fill audio and mix at the specified volume
274 This is called from many music player's GetAudio callback.
275 */
276 int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
277 int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done))
278 {
279 Uint8 *snd = (Uint8 *)data;
280 Uint8 *dst;
281 int len = bytes;
282 SDL_bool done = SDL_FALSE;
283
284 if (volume == MIX_MAX_VOLUME) {
285 dst = snd;
286 } else {
287 dst = SDL_stack_alloc(Uint8, (size_t)bytes);
288 }
289 while (len > 0 && !done) {
290 int consumed = GetSome(context, dst, len, &done);
291 if (consumed < 0) {
292 break;
293 }
294
295 if (volume == MIX_MAX_VOLUME) {
296 dst += consumed;
297 } else {
298 SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume);
299 snd += consumed;
300 }
301 len -= consumed;
302 }
303 if (volume != MIX_MAX_VOLUME) {
304 SDL_stack_free(dst);
305 }
306 return len;
307 }
308
309 /* Mixing function */
310 void SDLCALL music_mixer(void *udata, Uint8 *stream, int len)
311 {
312 (void)udata;
313
314 while (music_playing && music_active && len > 0) {
315 /* Handle fading */
316 if (music_playing->fading != MIX_NO_FADING) {
317 if (music_playing->fade_step++ < music_playing->fade_steps) {
318 int volume;
319 int fade_step = music_playing->fade_step;
320 int fade_steps = music_playing->fade_steps;
321
322 if (music_playing->fading == MIX_FADING_OUT) {
323 volume = (music_volume * (fade_steps-fade_step)) / fade_steps;
324 } else { /* Fading in */
325 volume = (music_volume * fade_step) / fade_steps;
326 }
327 music_internal_volume(volume);
328 } else {
329 if (music_playing->fading == MIX_FADING_OUT) {
330 music_internal_halt();
331 if (music_finished_hook) {
332 music_finished_hook();
333 }
334 return;
335 }
336 music_playing->fading = MIX_NO_FADING;
337 }
338 }
339
340 if (music_playing->interface->GetAudio) {
341 int left = music_playing->interface->GetAudio(music_playing->context, stream, len);
342 if (left != 0) {
343 /* Either an error or finished playing with data left */
344 music_playing->playing = SDL_FALSE;
345 }
346 if (left > 0) {
347 stream += (len - left);
348 len = left;
349 } else {
350 len = 0;
351 }
352 } else {
353 len = 0;
354 }
355
356 if (!music_internal_playing()) {
357 music_internal_halt();
358 if (music_finished_hook) {
359 music_finished_hook();
360 }
361 }
362 }
363 }
364
365 /* Load the music interface libraries for a given music type */
366 SDL_bool load_music_type(Mix_MusicType type)
367 {
368 size_t i;
369 int loaded = 0;
370 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
371 Mix_MusicInterface *interface = s_music_interfaces[i];
372 if (interface->type != type) {
373 continue;
374 }
375 if (!interface->loaded) {
376 char hint[64];
377 SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag);
378 if (SDL_GetHintBoolean(hint, SDL_FALSE)) {
379 continue;
380 }
381
382 if (interface->Load && interface->Load() < 0) {
383 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
384 SDL_Log("Couldn't load %s: %s\n", interface->tag, Mix_GetError());
385 }
386 continue;
387 }
388 interface->loaded = SDL_TRUE;
389 }
390 ++loaded;
391 }
392 return (loaded > 0) ? SDL_TRUE : SDL_FALSE;
393 }
394
395 /* Open the music interfaces for a given music type */
396 SDL_bool open_music_type(Mix_MusicType type)
397 {
398 size_t i;
399 int opened = 0;
400 SDL_bool use_native_midi = SDL_FALSE;
401
402 if (!music_spec.format) {
403 /* Music isn't opened yet */
404 return SDL_FALSE;
405 }
406
407 #ifdef MUSIC_MID_NATIVE
408 if (type == MUS_MID && SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) {
409 use_native_midi = SDL_TRUE;
410 }
411 #endif
412
413 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
414 Mix_MusicInterface *interface = s_music_interfaces[i];
415 if (!interface->loaded) {
416 continue;
417 }
418 if (type != MUS_NONE && interface->type != type) {
419 continue;
420 }
421
422 if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) {
423 continue;
424 }
425
426 if (!interface->opened) {
427 if (interface->Open && interface->Open(&music_spec) < 0) {
428 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
429 SDL_Log("Couldn't open %s: %s\n", interface->tag, Mix_GetError());
430 }
431 continue;
432 }
433 interface->opened = SDL_TRUE;
434 add_music_decoder(interface->tag);
435 }
436 ++opened;
437 }
438
439 if (has_music(MUS_MOD)) {
440 add_music_decoder("MOD");
441 add_chunk_decoder("MOD");
442 }
443 if (has_music(MUS_MID)) {
444 add_music_decoder("MIDI");
445 add_chunk_decoder("MID");
446 }
447 if (has_music(MUS_OGG)) {
448 add_music_decoder("OGG");
449 add_chunk_decoder("OGG");
450 }
451 if (has_music(MUS_OPUS)) {
452 add_music_decoder("OPUS");
453 add_chunk_decoder("OPUS");
454 }
455 if (has_music(MUS_MP3)) {
456 add_music_decoder("MP3");
457 add_chunk_decoder("MP3");
458 }
459 if (has_music(MUS_FLAC)) {
460 add_music_decoder("FLAC");
461 add_chunk_decoder("FLAC");
462 }
463
464 return (opened > 0) ? SDL_TRUE : SDL_FALSE;
465 }
466
467 /* Initialize the music interfaces with a certain desired audio format */
468 void open_music(const SDL_AudioSpec *spec)
469 {
470 #ifdef MIX_INIT_SOUNDFONT_PATHS
471 if (!soundfont_paths) {
472 soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS);
473 }
474 #endif
475
476 /* Load the music interfaces that don't have explicit initialization */
477 load_music_type(MUS_CMD);
478 load_music_type(MUS_WAV);
479
480 /* Open all the interfaces that are loaded */
481 music_spec = *spec;
482 open_music_type(MUS_NONE);
483
484 Mix_VolumeMusic(MIX_MAX_VOLUME);
485
486 /* Calculate the number of ms for each callback */
487 ms_per_step = (int) (((float)spec->samples * 1000.0f) / spec->freq);
488 }
489
490 /* Return SDL_TRUE if the music type is available */
491 SDL_bool has_music(Mix_MusicType type)
492 {
493 size_t i;
494 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
495 Mix_MusicInterface *interface = s_music_interfaces[i];
496 if (interface->type != type) {
497 continue;
498 }
499 if (interface->opened) {
500 return SDL_TRUE;
501 }
502 }
503 return SDL_FALSE;
504 }
505
506 Mix_MusicType detect_music_type(SDL_RWops *src)
507 {
508 Uint8 magic[12];
509
510 if (SDL_RWread(src, magic, 1, 12) != 12) {
511 Mix_SetError("Couldn't read first 12 bytes of audio data");
512 return MUS_NONE;
513 }
514 SDL_RWseek(src, -12, RW_SEEK_CUR);
515
516 /* WAVE files have the magic four bytes "RIFF"
517 AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */
518 if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) ||
519 (SDL_memcmp(magic, "FORM", 4) == 0)) {
520 return MUS_WAV;
521 }
522
523 /* Ogg Vorbis files have the magic four bytes "OggS" */
524 if (SDL_memcmp(magic, "OggS", 4) == 0) {
525 SDL_RWseek(src, 28, RW_SEEK_CUR);
526 SDL_RWread(src, magic, 1, 8);
527 SDL_RWseek(src,-36, RW_SEEK_CUR);
528 if (SDL_memcmp(magic, "OpusHead", 8) == 0) {
529 return MUS_OPUS;
530 }
531 return MUS_OGG;
532 }
533
534 /* FLAC files have the magic four bytes "fLaC" */
535 if (SDL_memcmp(magic, "fLaC", 4) == 0) {
536 return MUS_FLAC;
537 }
538
539 /* MIDI files have the magic four bytes "MThd" */
540 if (SDL_memcmp(magic, "MThd", 4) == 0) {
541 return MUS_MID;
542 }
543
544 if (SDL_memcmp(magic, "ID3", 3) == 0 ||
545 /* see: https://bugzilla.libsdl.org/show_bug.cgi?id=5322 */
546 (magic[0] == 0xFF && (magic[1] & 0xE6) == 0xE2)) {
547 return MUS_MP3;
548 }
549
550 /* Assume MOD format.
551 *
552 * Apparently there is no way to check if the file is really a MOD,
553 * or there are too many formats supported by MikMod/ModPlug, or
554 * MikMod/ModPlug does this check by itself. */
555 return MUS_MOD;
556 }
557
558 /* Load a music file */
559 Mix_Music *Mix_LoadMUS(const char *file)
560 {
561 size_t i;
562 void *context;
563 char *ext;
564 Mix_MusicType type;
565 SDL_RWops *src;
566
567 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
568 Mix_MusicInterface *interface = s_music_interfaces[i];
569 if (!interface->opened || !interface->CreateFromFile) {
570 continue;
571 }
572
573 context = interface->CreateFromFile(file);
574 if (context) {
575 const char *p;
576 /* Allocate memory for the music structure */
577 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
578 if (music == NULL) {
579 Mix_SetError("Out of memory");
580 return NULL;
581 }
582 music->interface = interface;
583 music->context = context;
584 p = get_last_dirsep(file);
585 SDL_strlcpy(music->filename, (p != NULL)? p + 1 : file, 1024);
586 return music;
587 }
588 }
589
590 src = SDL_RWFromFile(file, "rb");
591 if (src == NULL) {
592 Mix_SetError("Couldn't open '%s'", file);
593 return NULL;
594 }
595
596 /* Use the extension as a first guess on the file type */
597 type = MUS_NONE;
598 ext = SDL_strrchr(file, '.');
599 if (ext) {
600 ++ext; /* skip the dot in the extension */
601 if (SDL_strcasecmp(ext, "WAV") == 0) {
602 type = MUS_WAV;
603 } else if (SDL_strcasecmp(ext, "MID") == 0 ||
604 SDL_strcasecmp(ext, "MIDI") == 0 ||
605 SDL_strcasecmp(ext, "KAR") == 0) {
606 type = MUS_MID;
607 } else if (SDL_strcasecmp(ext, "OGG") == 0) {
608 type = MUS_OGG;
609 } else if (SDL_strcasecmp(ext, "OPUS") == 0) {
610 type = MUS_OPUS;
611 } else if (SDL_strcasecmp(ext, "FLAC") == 0) {
612 type = MUS_FLAC;
613 } else if (SDL_strcasecmp(ext, "MPG") == 0 ||
614 SDL_strcasecmp(ext, "MPEG") == 0 ||
615 SDL_strcasecmp(ext, "MP3") == 0 ||
616 SDL_strcasecmp(ext, "MAD") == 0) {
617 type = MUS_MP3;
618 } else if (SDL_strcasecmp(ext, "669") == 0 ||
619 SDL_strcasecmp(ext, "AMF") == 0 ||
620 SDL_strcasecmp(ext, "AMS") == 0 ||
621 SDL_strcasecmp(ext, "DBM") == 0 ||
622 SDL_strcasecmp(ext, "DSM") == 0 ||
623 SDL_strcasecmp(ext, "FAR") == 0 ||
624 SDL_strcasecmp(ext, "GDM") == 0 ||
625 SDL_strcasecmp(ext, "IT") == 0 ||
626 SDL_strcasecmp(ext, "MED") == 0 ||
627 SDL_strcasecmp(ext, "MDL") == 0 ||
628 SDL_strcasecmp(ext, "MOD") == 0 ||
629 SDL_strcasecmp(ext, "MOL") == 0 ||
630 SDL_strcasecmp(ext, "MTM") == 0 ||
631 SDL_strcasecmp(ext, "NST") == 0 ||
632 SDL_strcasecmp(ext, "OKT") == 0 ||
633 SDL_strcasecmp(ext, "PTM") == 0 ||
634 SDL_strcasecmp(ext, "S3M") == 0 ||
635 SDL_strcasecmp(ext, "STM") == 0 ||
636 SDL_strcasecmp(ext, "ULT") == 0 ||
637 SDL_strcasecmp(ext, "UMX") == 0 ||
638 SDL_strcasecmp(ext, "WOW") == 0 ||
639 SDL_strcasecmp(ext, "XM") == 0) {
640 type = MUS_MOD;
641 }
642 }
643 return Mix_LoadMUSType_RW(src, type, SDL_TRUE);
644 }
645
646 Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
647 {
648 return Mix_LoadMUSType_RW(src, MUS_NONE, freesrc);
649 }
650
651 Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc)
652 {
653 size_t i;
654 void *context;
655 Sint64 start;
656
657 if (!src) {
658 Mix_SetError("RWops pointer is NULL");
659 return NULL;
660 }
661 start = SDL_RWtell(src);
662
663 /* If the caller wants auto-detection, figure out what kind of file
664 * this is. */
665 if (type == MUS_NONE) {
666 if ((type = detect_music_type(src)) == MUS_NONE) {
667 /* Don't call Mix_SetError() since detect_music_type() does that. */
668 if (freesrc) {
669 SDL_RWclose(src);
670 }
671 return NULL;
672 }
673 }
674
675 Mix_ClearError();
676
677 if (load_music_type(type) && open_music_type(type)) {
678 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
679 Mix_MusicInterface *interface = s_music_interfaces[i];
680 if (!interface->opened || type != interface->type || !interface->CreateFromRW) {
681 continue;
682 }
683
684 context = interface->CreateFromRW(src, freesrc);
685 if (context) {
686 /* Allocate memory for the music structure */
687 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
688 if (music == NULL) {
689 interface->Delete(context);
690 Mix_SetError("Out of memory");
691 return NULL;
692 }
693 music->interface = interface;
694 music->context = context;
695
696 if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
697 SDL_Log("Loaded music with %s\n", interface->tag);
698 }
699 return music;
700 }
701
702 /* Reset the stream for the next decoder */
703 SDL_RWseek(src, start, RW_SEEK_SET);
704 }
705 }
706
707 if (!*Mix_GetError()) {
708 Mix_SetError("Unrecognized audio format");
709 }
710 if (freesrc) {
711 SDL_RWclose(src);
712 } else {
713 SDL_RWseek(src, start, RW_SEEK_SET);
714 }
715 return NULL;
716 }
717
718 /* Free a music chunk previously loaded */
719 void Mix_FreeMusic(Mix_Music *music)
720 {
721 if (music) {
722 /* Stop the music if it's currently playing */
723 Mix_LockAudio();
724 if (music == music_playing) {
725 /* Wait for any fade out to finish */
726 while (music->fading == MIX_FADING_OUT) {
727 Mix_UnlockAudio();
728 SDL_Delay(100);
729 Mix_LockAudio();
730 }
731 if (music == music_playing) {
732 music_internal_halt();
733 }
734 }
735 Mix_UnlockAudio();
736
737 music->interface->Delete(music->context);
738 SDL_free(music);
739 }
740 }
741
742 /* Find out the music format of a mixer music, or the currently playing
743 music, if 'music' is NULL.
744 */
745 Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
746 {
747 Mix_MusicType type = MUS_NONE;
748
749 if (music) {
750 type = music->interface->type;
751 } else {
752 Mix_LockAudio();
753 if (music_playing) {
754 type = music_playing->interface->type;
755 }
756 Mix_UnlockAudio();
757 }
758 return(type);
759 }
760
761 static const char * get_music_tag_internal(const Mix_Music *music, Mix_MusicMetaTag tag_type)
762 {
763 const char *tag = "";
764
765 Mix_LockAudio();
766 if (music && music->interface->GetMetaTag) {
767 tag = music->interface->GetMetaTag(music->context, tag_type);
768 } else if (music_playing && music_playing->interface->GetMetaTag) {
769 tag = music_playing->interface->GetMetaTag(music_playing->context, tag_type);
770 } else {
771 Mix_SetError("Music isn't playing");
772 }
773 Mix_UnlockAudio();
774 return tag;
775 }
776
777 const char *Mix_GetMusicTitleTag(const Mix_Music *music)
778 {
779 return get_music_tag_internal(music, MIX_META_TITLE);
780 }
781
782 /* Get music title from meta-tag if possible */
783 const char *Mix_GetMusicTitle(const Mix_Music *music)
784 {
785 const char *tag = Mix_GetMusicTitleTag(music);
786 if (SDL_strlen(tag) > 0) {
787 return tag;
788 }
789 if (music) {
790 return music->filename;
791 }
792 if (music_playing) {
793 return music_playing->filename;
794 }
795 return "";
796 }
797
798 const char *Mix_GetMusicArtistTag(const Mix_Music *music)
799 {
800 return get_music_tag_internal(music, MIX_META_ARTIST);
801 }
802
803 const char *Mix_GetMusicAlbumTag(const Mix_Music *music)
804 {
805 return get_music_tag_internal(music, MIX_META_ALBUM);
806 }
807
808 const char *Mix_GetMusicCopyrightTag(const Mix_Music *music)
809 {
810 return get_music_tag_internal(music, MIX_META_COPYRIGHT);
811 }
812
813 /* Play a music chunk. Returns 0, or -1 if there was an error.
814 */
815 static int music_internal_play(Mix_Music *music, int play_count, double position)
816 {
817 int retval = 0;
818
819 #if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE)
820 /* This fixes a bug with native MIDI on Mac OS X, where you
821 can't really stop and restart MIDI from the audio callback.
822 */
823 if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) {
824 /* Just a seek suffices to restart playing */
825 music_internal_position(position);
826 return 0;
827 }
828 #endif
829
830 /* Note the music we're playing */
831 if (music_playing) {
832 music_internal_halt();
833 }
834 music_playing = music;
835 music_playing->playing = SDL_TRUE;
836
837 /* Set the initial volume */
838 music_internal_initialize_volume();
839
840 /* Set up for playback */
841 retval = music->interface->Play(music->context, play_count);
842
843 /* Set the playback position, note any errors if an offset is used */
844 if (retval == 0) {
845 if (position > 0.0) {
846 if (music_internal_position(position) < 0) {
847 Mix_SetError("Position not implemented for music type");
848 retval = -1;
849 }
850 } else {
851 music_internal_position(0.0);
852 }
853 }
854
855 /* If the setup failed, we're not playing any music anymore */
856 if (retval < 0) {
857 music->playing = SDL_FALSE;
858 music_playing = NULL;
859 }
860 return(retval);
861 }
862
863 int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
864 {
865 int retval;
866
867 if (ms_per_step == 0) {
868 SDL_SetError("Audio device hasn't been opened");
869 return(-1);
870 }
871
872 /* Don't play null pointers :-) */
873 if (music == NULL) {
874 Mix_SetError("music parameter was NULL");
875 return(-1);
876 }
877
878 /* Setup the data */
879 if (ms) {
880 music->fading = MIX_FADING_IN;
881 } else {
882 music->fading = MIX_NO_FADING;
883 }
884 music->fade_step = 0;
885 music->fade_steps = ms/ms_per_step;
886
887 /* Play the puppy */
888 Mix_LockAudio();
889 /* If the current music is fading out, wait for the fade to complete */
890 while (music_playing && (music_playing->fading == MIX_FADING_OUT)) {
891 Mix_UnlockAudio();
892 SDL_Delay(100);
893 Mix_LockAudio();
894 }
895 if (loops == 0) {
896 /* Loop is the number of times to play the audio */
897 loops = 1;
898 }
899 retval = music_internal_play(music, loops, position);
900 /* Set music as active */
901 music_active = (retval == 0);
902 Mix_UnlockAudio();
903
904 return(retval);
905 }
906 int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
907 {
908 return Mix_FadeInMusicPos(music, loops, ms, 0.0);
909 }
910 int Mix_PlayMusic(Mix_Music *music, int loops)
911 {
912 return Mix_FadeInMusicPos(music, loops, 0, 0.0);
913 }
914
915 /* Jump to a given order in mod music. */
916 int Mix_ModMusicJumpToOrder(int order)
917 {
918 int retval = -1;
919
920 Mix_LockAudio();
921 if (music_playing) {
922 if (music_playing->interface->Jump) {
923 retval = music_playing->interface->Jump(music_playing->context, order);
924 } else {
925 Mix_SetError("Jump not implemented for music type");
926 }
927 } else {
928 Mix_SetError("Music isn't playing");
929 }
930 Mix_UnlockAudio();
931
932 return retval;
933 }
934
935 /* Set the playing music position */
936 int music_internal_position(double position)
937 {
938 if (music_playing->interface->Seek) {
939 return music_playing->interface->Seek(music_playing->context, position);
940 }
941 return -1;
942 }
943 int Mix_SetMusicPosition(double position)
944 {
945 int retval;
946
947 Mix_LockAudio();
948 if (music_playing) {
949 retval = music_internal_position(position);
950 if (retval < 0) {
951 Mix_SetError("Position not implemented for music type");
952 }
953 } else {
954 Mix_SetError("Music isn't playing");
955 retval = -1;
956 }
957 Mix_UnlockAudio();
958
959 return(retval);
960 }
961
962 /* Set the playing music position */
963 static double music_internal_position_get(Mix_Music *music)
964 {
965 if (music->interface->Tell) {
966 return music->interface->Tell(music->context);
967 }
968 return -1;
969 }
970 double Mix_GetMusicPosition(Mix_Music *music)
971 {
972 double retval;
973
974 Mix_LockAudio();
975 if (music) {
976 retval = music_internal_position_get(music);
977 } else if (music_playing) {
978 retval = music_internal_position_get(music_playing);
979 } else {
980 Mix_SetError("Music isn't playing");
981 retval = -1.0;
982 }
983 Mix_UnlockAudio();
984
985 return(retval);
986 }
987
988 static double music_internal_duration(Mix_Music *music)
989 {
990 if (music->interface->Duration) {
991 return music->interface->Duration(music->context);
992 } else {
993 Mix_SetError("Duration not implemented for music type");
994 return -1;
995 }
996 }
997 double Mix_MusicDuration(Mix_Music *music)
998 {
999 double retval;
1000
1001 Mix_LockAudio();
1002 if (music) {
1003 retval = music_internal_duration(music);
1004 } else if (music_playing) {
1005 retval = music_internal_duration(music_playing);
1006 } else {
1007 Mix_SetError("music is NULL and no playing music");
1008 retval = -1.0;
1009 }
1010 Mix_UnlockAudio();
1011
1012 return(retval);
1013 }
1014
1015 /* Get Loop start position */
1016 static double music_internal_loop_start(Mix_Music *music)
1017 {
1018 if (music->interface->LoopStart) {
1019 return music->interface->LoopStart(music->context);
1020 }
1021 return -1;
1022 }
1023 double Mix_GetMusicLoopStartTime(Mix_Music *music)
1024 {
1025 double retval;
1026
1027 Mix_LockAudio();
1028 if (music) {
1029 retval = music_internal_loop_start(music);
1030 } else if (music_playing) {
1031 retval = music_internal_loop_start(music_playing);
1032 } else {
1033 Mix_SetError("Music isn't playing");
1034 retval = -1.0;
1035 }
1036 Mix_UnlockAudio();
1037
1038 return(retval);
1039 }
1040
1041 /* Get Loop end position */
1042 static double music_internal_loop_end(Mix_Music *music)
1043 {
1044 if (music->interface->LoopEnd) {
1045 return music->interface->LoopEnd(music->context);
1046 }
1047 return -1;
1048 }
1049 double Mix_GetMusicLoopEndTime(Mix_Music *music)
1050 {
1051 double retval;
1052
1053 Mix_LockAudio();
1054 if (music) {
1055 retval = music_internal_loop_end(music);
1056 } else if (music_playing) {
1057 retval = music_internal_loop_end(music_playing);
1058 } else {
1059 Mix_SetError("Music isn't playing");
1060 retval = -1.0;
1061 }
1062 Mix_UnlockAudio();
1063
1064 return(retval);
1065 }
1066
1067 /* Get Loop end position */
1068 static double music_internal_loop_length(Mix_Music *music)
1069 {
1070 if (music->interface->LoopLength) {
1071 return music->interface->LoopLength(music->context);
1072 }
1073 return -1;
1074 }
1075 double Mix_GetMusicLoopLengthTime(Mix_Music *music)
1076 {
1077 double retval;
1078
1079 Mix_LockAudio();
1080 if (music) {
1081 retval = music_internal_loop_length(music);
1082 } else if (music_playing) {
1083 retval = music_internal_loop_length(music_playing);
1084 } else {
1085 Mix_SetError("Music isn't playing");
1086 retval = -1.0;
1087 }
1088 Mix_UnlockAudio();
1089
1090 return(retval);
1091 }
1092
1093 /* Set the music's initial volume */
1094 static void music_internal_initialize_volume(void)
1095 {
1096 if (music_playing->fading == MIX_FADING_IN) {
1097 music_internal_volume(0);
1098 } else {
1099 music_internal_volume(music_volume);
1100 }
1101 }
1102
1103 /* Set the music volume */
1104 static void music_internal_volume(int volume)
1105 {
1106 if (music_playing->interface->SetVolume) {
1107 music_playing->interface->SetVolume(music_playing->context, volume);
1108 }
1109 }
1110 int Mix_VolumeMusic(int volume)
1111 {
1112 int prev_volume;
1113
1114 prev_volume = music_volume;
1115 if (volume < 0) {
1116 return prev_volume;
1117 }
1118 if (volume > SDL_MIX_MAXVOLUME) {
1119 volume = SDL_MIX_MAXVOLUME;
1120 }
1121 music_volume = volume;
1122 Mix_LockAudio();
1123 if (music_playing) {
1124 music_internal_volume(music_volume);
1125 }
1126 Mix_UnlockAudio();
1127 return(prev_volume);
1128 }
1129
1130 int Mix_GetMusicVolume(Mix_Music *music)
1131 {
1132 int prev_volume;
1133
1134 if (music && music->interface->GetVolume)
1135 prev_volume = music->interface->GetVolume(music->context);
1136 else if (music_playing && music_playing->interface->GetVolume) {
1137 prev_volume = music_playing->interface->GetVolume(music_playing->context);
1138 } else {
1139 prev_volume = music_volume;
1140 }
1141
1142 return prev_volume;
1143 }
1144
1145 /* Halt playing of music */
1146 static void music_internal_halt(void)
1147 {
1148 if (music_playing->interface->Stop) {
1149 music_playing->interface->Stop(music_playing->context);
1150 }
1151
1152 music_playing->playing = SDL_FALSE;
1153 music_playing->fading = MIX_NO_FADING;
1154 music_playing = NULL;
1155 }
1156 int Mix_HaltMusic(void)
1157 {
1158 Mix_LockAudio();
1159 if (music_playing) {
1160 music_internal_halt();
1161 if (music_finished_hook) {
1162 music_finished_hook();
1163 }
1164 }
1165 Mix_UnlockAudio();
1166
1167 return(0);
1168 }
1169
1170 /* Progressively stop the music */
1171 int Mix_FadeOutMusic(int ms)
1172 {
1173 int retval = 0;
1174
1175 if (ms_per_step == 0) {
1176 SDL_SetError("Audio device hasn't been opened");
1177 return 0;
1178 }
1179
1180 if (ms <= 0) { /* just halt immediately. */
1181 Mix_HaltMusic();
1182 return 1;
1183 }
1184
1185 Mix_LockAudio();
1186 if (music_playing) {
1187 int fade_steps = (ms + ms_per_step - 1) / ms_per_step;
1188 if (music_playing->fading == MIX_NO_FADING) {
1189 music_playing->fade_step = 0;
1190 } else {
1191 int step;
1192 int old_fade_steps = music_playing->fade_steps;
1193 if (music_playing->fading == MIX_FADING_OUT) {
1194 step = music_playing->fade_step;
1195 } else {
1196 step = old_fade_steps - music_playing->fade_step + 1;
1197 }
1198 music_playing->fade_step = (step * fade_steps) / old_fade_steps;
1199 }
1200 music_playing->fading = MIX_FADING_OUT;
1201 music_playing->fade_steps = fade_steps;
1202 retval = 1;
1203 }
1204 Mix_UnlockAudio();
1205
1206 return(retval);
1207 }
1208
1209 Mix_Fading Mix_FadingMusic(void)
1210 {
1211 Mix_Fading fading = MIX_NO_FADING;
1212
1213 Mix_LockAudio();
1214 if (music_playing) {
1215 fading = music_playing->fading;
1216 }
1217 Mix_UnlockAudio();
1218
1219 return(fading);
1220 }
1221
1222 /* Pause/Resume the music stream */
1223 void Mix_PauseMusic(void)
1224 {
1225 Mix_LockAudio();
1226 if (music_playing) {
1227 if (music_playing->interface->Pause) {
1228 music_playing->interface->Pause(music_playing->context);
1229 }
1230 }
1231 music_active = SDL_FALSE;
1232 Mix_UnlockAudio();
1233 }
1234
1235 void Mix_ResumeMusic(void)
1236 {
1237 Mix_LockAudio();
1238 if (music_playing) {
1239 if (music_playing->interface->Resume) {
1240 music_playing->interface->Resume(music_playing->context);
1241 }
1242 }
1243 music_active = SDL_TRUE;
1244 Mix_UnlockAudio();
1245 }
1246
1247 void Mix_RewindMusic(void)
1248 {
1249 Mix_SetMusicPosition(0.0);
1250 }
1251
1252 int Mix_PausedMusic(void)
1253 {
1254 return (music_active == SDL_FALSE);
1255 }
1256
1257 /* Check the status of the music */
1258 static SDL_bool music_internal_playing(void)
1259 {
1260 if (!music_playing) {
1261 return SDL_FALSE;
1262 }
1263
1264 if (music_playing->interface->IsPlaying) {
1265 music_playing->playing = music_playing->interface->IsPlaying(music_playing->context);
1266 }
1267 return music_playing->playing;
1268 }
1269 int Mix_PlayingMusic(void)
1270 {
1271 SDL_bool playing;
1272
1273 Mix_LockAudio();
1274 playing = music_internal_playing();
1275 Mix_UnlockAudio();
1276
1277 return playing ? 1 : 0;
1278 }
1279
1280 /* Set the external music playback command */
1281 int Mix_SetMusicCMD(const char *command)
1282 {
1283 Mix_HaltMusic();
1284 if (music_cmd) {
1285 SDL_free(music_cmd);
1286 music_cmd = NULL;
1287 }
1288 if (command) {
1289 size_t length = SDL_strlen(command) + 1;
1290 music_cmd = (char *)SDL_malloc(length);
1291 if (music_cmd == NULL) {
1292 return SDL_OutOfMemory();
1293 }
1294 SDL_memcpy(music_cmd, command, length);
1295 }
1296 return 0;
1297 }
1298
1299 int Mix_SetSynchroValue(int i)
1300 {
1301 /* Not supported by any players at this time */
1302 (void) i;
1303 return -1;
1304 }
1305
1306 int Mix_GetSynchroValue(void)
1307 {
1308 /* Not supported by any players at this time */
1309 return -1;
1310 }
1311
1312
1313 /* Uninitialize the music interfaces */
1314 void close_music(void)
1315 {
1316 size_t i;
1317
1318 Mix_HaltMusic();
1319
1320 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
1321 Mix_MusicInterface *interface = s_music_interfaces[i];
1322 if (!interface || !interface->opened) {
1323 continue;
1324 }
1325
1326 if (interface->Close) {
1327 interface->Close();
1328 }
1329 interface->opened = SDL_FALSE;
1330 }
1331
1332 if (soundfont_paths) {
1333 SDL_free(soundfont_paths);
1334 soundfont_paths = NULL;
1335 }
1336
1337 /* rcg06042009 report available decoders at runtime. */
1338 if (music_decoders) {
1339 SDL_free((void *)music_decoders);
1340 music_decoders = NULL;
1341 }
1342 num_decoders = 0;
1343
1344 ms_per_step = 0;
1345 }
1346
1347 /* Unload the music interface libraries */
1348 void unload_music(void)
1349 {
1350 size_t i;
1351 for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
1352 Mix_MusicInterface *interface = s_music_interfaces[i];
1353 if (!interface || !interface->loaded) {
1354 continue;
1355 }
1356
1357 if (interface->Unload) {
1358 interface->Unload();
1359 }
1360 interface->loaded = SDL_FALSE;
1361 }
1362 }
1363
1364 int Mix_SetTimidityCfg(const char *path)
1365 {
1366 if (timidity_cfg) {
1367 SDL_free(timidity_cfg);
1368 timidity_cfg = NULL;
1369 }
1370
1371 if (path && *path) {
1372 if (!(timidity_cfg = SDL_strdup(path))) {
1373 Mix_SetError("Insufficient memory to set Timidity cfg file");
1374 return 0;
1375 }
1376 }
1377
1378 return 1;
1379 }
1380
1381 const char* Mix_GetTimidityCfg(void)
1382 {
1383 return timidity_cfg;
1384 }
1385
1386 int Mix_SetSoundFonts(const char *paths)
1387 {
1388 if (soundfont_paths) {
1389 SDL_free(soundfont_paths);
1390 soundfont_paths = NULL;
1391 }
1392
1393 if (paths) {
1394 if (!(soundfont_paths = SDL_strdup(paths))) {
1395 Mix_SetError("Insufficient memory to set SoundFonts");
1396 return 0;
1397 }
1398 }
1399 return 1;
1400 }
1401
1402 const char* Mix_GetSoundFonts(void)
1403 {
1404 const char *env_paths = SDL_getenv("SDL_SOUNDFONTS");
1405 SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE);
1406 if (force_env_paths && (!env_paths || !*env_paths)) {
1407 force_env_paths = SDL_FALSE;
1408 }
1409 if (soundfont_paths && *soundfont_paths && !force_env_paths) {
1410 return soundfont_paths;
1411 }
1412 if (env_paths) {
1413 return env_paths;
1414 }
1415
1416 /* We don't have any sound fonts set programmatically or in the environment
1417 Time to start guessing where they might be...
1418 */
1419 {
1420 static char *s_soundfont_paths[] = {
1421 "/usr/share/sounds/sf2/FluidR3_GM.sf2" /* Remember to add ',' here */
1422 };
1423 unsigned i;
1424
1425 for (i = 0; i < SDL_arraysize(s_soundfont_paths); ++i) {
1426 SDL_RWops *rwops = SDL_RWFromFile(s_soundfont_paths[i], "rb");
1427 if (rwops) {
1428 SDL_RWclose(rwops);
1429 return s_soundfont_paths[i];
1430 }
1431 }
1432 }
1433 return NULL;
1434 }
1435
1436 int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data)
1437 {
1438 char *context, *path, *paths;
1439 const char* cpaths = Mix_GetSoundFonts();
1440 int soundfonts_found = 0;
1441
1442 if (!cpaths) {
1443 Mix_SetError("No SoundFonts have been requested");
1444 return 0;
1445 }
1446
1447 if (!(paths = SDL_strdup(cpaths))) {
1448 Mix_SetError("Insufficient memory to iterate over SoundFonts");
1449 return 0;
1450 }
1451
1452 #if defined(_WIN32) || defined(__OS2__)
1453 #define PATHSEP ";"
1454 #else
1455 #define PATHSEP ":;"
1456 #endif
1457 for (path = SDL_strtokr(paths, PATHSEP, &context); path;
1458 path = SDL_strtokr(NULL, PATHSEP, &context)) {
1459 if (!function(path, data)) {
1460 continue;
1461 }
1462 soundfonts_found++;
1463 }
1464
1465 SDL_free(paths);
1466 return (soundfonts_found > 0);
1467 }
1468
1469 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20 #include "SDL_mixer.h"
21
22 #ifndef MUSIC_H_
23 #define MUSIC_H_
24
25 /* Supported music APIs, in order of preference */
26
27 typedef enum
28 {
29 MIX_MUSIC_CMD,
30 MIX_MUSIC_WAVE,
31 MIX_MUSIC_MODPLUG,
32 MIX_MUSIC_MIKMOD,
33 MIX_MUSIC_FLUIDSYNTH,
34 MIX_MUSIC_TIMIDITY,
35 MIX_MUSIC_NATIVEMIDI,
36 MIX_MUSIC_OGG,
37 MIX_MUSIC_MPG123,
38 MIX_MUSIC_MAD,
39 MIX_MUSIC_FLAC,
40 MIX_MUSIC_OPUS,
41 MIX_MUSIC_LIBXMP,
42 MIX_MUSIC_LAST
43 } Mix_MusicAPI;
44
45
46 /* Supported meta-tags */
47
48 typedef enum
49 {
50 MIX_META_TITLE,
51 MIX_META_ARTIST,
52 MIX_META_ALBUM,
53 MIX_META_COPYRIGHT,
54 MIX_META_LAST
55 } Mix_MusicMetaTag;
56
57
58 /* MIXER-X: Meta-tags utility structure */
59
60 typedef struct {
61 char *tags[4];
62 } Mix_MusicMetaTags;
63
64
65 extern void meta_tags_init(Mix_MusicMetaTags *tags);
66 extern void meta_tags_clear(Mix_MusicMetaTags *tags);
67 extern void meta_tags_set(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type, const char *value);
68 extern const char* meta_tags_get(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type);
69
70
71 /* Music API implementation */
72
73 typedef struct
74 {
75 const char *tag;
76 Mix_MusicAPI api;
77 Mix_MusicType type;
78 SDL_bool loaded;
79 SDL_bool opened;
80
81 /* Load the library */
82 int (*Load)(void);
83
84 /* Initialize for the audio output */
85 int (*Open)(const SDL_AudioSpec *spec);
86
87 /* Create a music object from an SDL_RWops stream
88 * If the function returns NULL, 'src' will be freed if needed by the caller.
89 */
90 void *(*CreateFromRW)(SDL_RWops *src, int freesrc);
91
92 /* Create a music object from a file, if SDL_RWops are not supported */
93 void *(*CreateFromFile)(const char *file);
94
95 /* Set the volume */
96 void (*SetVolume)(void *music, int volume);
97
98 /* Get the volume */
99 int (*GetVolume)(void *music);
100
101 /* Start playing music from the beginning with an optional loop count */
102 int (*Play)(void *music, int play_count);
103
104 /* Returns SDL_TRUE if music is still playing */
105 SDL_bool (*IsPlaying)(void *music);
106
107 /* Get music data, returns the number of bytes left */
108 int (*GetAudio)(void *music, void *data, int bytes);
109
110 /* Jump to a given order in mod music */
111 int (*Jump)(void *music, int order);
112
113 /* Seek to a play position (in seconds) */
114 int (*Seek)(void *music, double position);
115
116 /* Tell a play position (in seconds) */
117 double (*Tell)(void *music);
118
119 /* Get Music duration (in seconds) */
120 double (*Duration)(void *music);
121
122 /* Tell a loop start position (in seconds) */
123 double (*LoopStart)(void *music);
124
125 /* Tell a loop end position (in seconds) */
126 double (*LoopEnd)(void *music);
127
128 /* Tell a loop length position (in seconds) */
129 double (*LoopLength)(void *music);
130
131 /* Get a meta-tag string if available */
132 const char* (*GetMetaTag)(void *music, Mix_MusicMetaTag tag_type);
133
134 /* Pause playing music */
135 void (*Pause)(void *music);
136
137 /* Resume playing music */
138 void (*Resume)(void *music);
139
140 /* Stop playing music */
141 void (*Stop)(void *music);
142
143 /* Delete a music object */
144 void (*Delete)(void *music);
145
146 /* Close the library and clean up */
147 void (*Close)(void);
148
149 /* Unload the library */
150 void (*Unload)(void);
151
152 } Mix_MusicInterface;
153
154
155 extern int get_num_music_interfaces(void);
156 extern Mix_MusicInterface *get_music_interface(int index);
157 extern Mix_MusicType detect_music_type(SDL_RWops *src);
158 extern SDL_bool load_music_type(Mix_MusicType type);
159 extern SDL_bool open_music_type(Mix_MusicType type);
160 extern SDL_bool has_music(Mix_MusicType type);
161 extern void open_music(const SDL_AudioSpec *spec);
162 extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
163 int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done));
164 extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len);
165 extern void close_music(void);
166 extern void unload_music(void);
167
168 extern char *music_cmd;
169 extern SDL_AudioSpec music_spec;
170
171 #endif /* MUSIC_H_ */
172
173 /* vi: set ts=4 sw=4 expandtab: */
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 /* misc helper routines */
22
23 #include "utils.h"
24 #include <stddef.h>
25
26 #if !defined(HAVE_SDL_STRTOKR)
27 /*
28 * Adapted from _PDCLIB_strtok() of PDClib library at
29 * https://github.com/DevSolar/pdclib.git
30 *
31 * The code was under CC0 license:
32 * https://creativecommons.org/publicdomain/zero/1.0/legalcode :
33 *
34 * No Copyright
35 *
36 * The person who associated a work with this deed has dedicated the
37 * work to the public domain by waiving all of his or her rights to
38 * the work worldwide under copyright law, including all related and
39 * neighboring rights, to the extent allowed by law.
40 *
41 * You can copy, modify, distribute and perform the work, even for
42 * commercial purposes, all without asking permission. See Other
43 * Information below.
44 */
45 char *SDL_strtokr(char *s1, const char *s2, char **ptr)
46 {
47 const char *p = s2;
48
49 if (!s2 || !ptr || (!s1 && !*ptr)) return NULL;
50
51 if (s1 != NULL) { /* new string */
52 *ptr = s1;
53 } else { /* old string continued */
54 if (*ptr == NULL) {
55 /* No old string, no new string, nothing to do */
56 return NULL;
57 }
58 s1 = *ptr;
59 }
60
61 /* skip leading s2 characters */
62 while (*p && *s1) {
63 if (*s1 == *p) {
64 /* found separator; skip and start over */
65 ++s1;
66 p = s2;
67 continue;
68 }
69 ++p;
70 }
71
72 if (! *s1) { /* no more to parse */
73 *ptr = s1;
74 return NULL;
75 }
76
77 /* skipping non-s2 characters */
78 *ptr = s1;
79 while (**ptr) {
80 p = s2;
81 while (*p) {
82 if (**ptr == *p++) {
83 /* found separator; overwrite with '\0', position *ptr, return */
84 *((*ptr)++) = '\0';
85 return s1;
86 }
87 }
88 ++(*ptr);
89 }
90
91 /* parsed to end of string */
92 return s1;
93 }
94 #endif /* HAVE_SDL_STRTOKR */
95
96 /* Is given tag a loop tag? */
97 SDL_bool _Mix_IsLoopTag(const char *tag)
98 {
99 char buf[5];
100 SDL_strlcpy(buf, tag, 5);
101 return SDL_strcasecmp(buf, "LOOP") == 0;
102 }
103
104 /* Parse time string of the form HH:MM:SS.mmm and return equivalent sample
105 * position */
106 Sint64 _Mix_ParseTime(char *time, long samplerate_hz)
107 {
108 char *num_start, *p;
109 Sint64 result;
110 char c;
111 int val;
112
113 /* Time is directly expressed as a sample position */
114 if (SDL_strchr(time, ':') == NULL) {
115 return SDL_strtoll(time, NULL, 10);
116 }
117
118 result = 0;
119 num_start = time;
120
121 for (p = time; *p != '\0'; ++p) {
122 if (*p == '.' || *p == ':') {
123 c = *p; *p = '\0';
124 if ((val = SDL_atoi(num_start)) < 0)
125 return -1;
126 result = result * 60 + val;
127 num_start = p + 1;
128 *p = c;
129 }
130
131 if (*p == '.') {
132 double val_f = SDL_atof(p);
133 if (val_f < 0) return -1;
134 return result * samplerate_hz + (Sint64) (val_f * samplerate_hz);
135 }
136 }
137
138 if ((val = SDL_atoi(num_start)) < 0) return -1;
139 return (result * 60 + val) * samplerate_hz;
140 }
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #ifndef UTILS_H_
22 #define UTILS_H_
23
24 /* misc helper routines */
25
26 #include "SDL_stdinc.h"
27 #include "SDL_version.h"
28
29 #if SDL_VERSION_ATLEAST(2,0,12)
30 #define HAVE_SDL_STRTOKR
31 #else
32 #define SDL_strtokr _MIX_strtokr
33 extern char *SDL_strtokr(char *s1, const char *s2, char **saveptr);
34 #endif
35
36 /* Parse time string of the form HH:MM:SS.mmm and return equivalent sample
37 * position */
38 extern Sint64 _Mix_ParseTime(char *time, long samplerate_hz);
39
40 extern SDL_bool _Mix_IsLoopTag(const char *tag);
41
42 #endif /* UTILS_H_ */
43
+0
-24
timidity/Android.mk less more
0 LOCAL_PATH := $(call my-dir)
1
2 include $(CLEAR_VARS)
3
4 LOCAL_MODULE := timidity
5
6 LOCAL_C_INCLUDES :=
7
8 LOCAL_CFLAGS :=
9
10 LOCAL_SRC_FILES += \
11 common.c \
12 instrum.c \
13 mix.c \
14 output.c \
15 playmidi.c \
16 readmidi.c \
17 resample.c \
18 tables.c \
19 timidity.c
20
21 LOCAL_SHARED_LIBRARIES := SDL2
22
23 include $(BUILD_STATIC_LIBRARY)
+0
-77
timidity/CHANGES less more
0 This version of TiMidity should contain all the fixes from the
1 September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some
2 changes of my own, e.g.:
3
4 * All file access is done through SDL_RWops. This means the MIDI
5 stream no longer has to be a file. (The config file and instruments
6 still have to be though.)
7
8 * Replacing of TiMidity's endian-handling with SDL's.
9
10 * Removal of much unused or unnecessary code, such as
11
12 + The "hooks" for putting a user interface onto TiMidity.
13 + The antialias filter. It wasn't active, and even at 4 kHz I
14 couldn't hear any difference when activating it.
15 + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION.
16 According to the code comments they weren't very good anyway.
17 ("degrades sound quality noticeably"). I also removed the
18 disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM
19 to 8-bit uLaw tables" disclaimer, since I believe those were the
20 tables I removed.
21 + Removed LOOKUP_SINE since it was already commented out. I think we
22 can count on our target audience having math co-processors
23 nowadays.
24 + Removed USE_LDEXP since it wasn't being used and "it doesn't make
25 much of a difference either way".
26 + Removed decompress hack from open_file() since it didn't look very
27 portable.
28 + Removed heaps of unnecessary constants.
29 + Removed unused functions.
30 + Assume that LINEAR_INTERPOLATION is always used, so remove all
31 code dealing with it not being so. It's not that I think the
32 difference in audio quality is that great, but since it wouldn't
33 compile without code changes I assume no one's used it for quite
34 some time...
35 + Assume PRECALC_LOOPS is always defined. Judging by the comments it
36 may not make much of a difference either way, so why maintain two
37 versions of the same code?
38
39 * Moving several static globals into the MidiSong struct. This
40 includes sample rate, formate, etc. which are now all per-song.
41
42 * Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion
43 into the MIDI decoder.
44
45 * Added free_pathlist().
46
47 * Replaced TiMidity's own 8, 16 and 32-bit types with SDL's.
48
49 * Made TiMidity look for its configuration file in both /etc and
50 /usr/local/lib/timidity. (Windows version remains unchanged.)
51
52 * Timidity_PlaySome() now takes three arguments. A MidiSong, a decode
53 buffer and decode buffer size in bytes. (MidiSong is a new argument,
54 and buffer size used to be in samples.)
55
56 In addition, it will return the number of bytes decoded.
57
58 * Added Timidity_Exit().
59
60 * Removed Timidity_Stop() and Timidity_Active(). Stopping playback
61 should be handled by SDL_sound, and Timidity_PlaySome() will return
62 0 when the MIDI stream is finished.
63
64 * Modified the ToneBank stuff to allow some data to be shared between
65 MidiSongs.
66
67 * The following files have been removed: controls.c, controls.h,
68 filter.c, filter.h, sdl_a.c, sdl_c.c
69
70 * config.h has been renamed as options.h to avoid confusion with the
71 automatically generated config.h for SDL_sound.
72
73 * Added support for loading DLS format instruments:
74 Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong()
75
76 * Added Timidity_Init_NoConfig()
+0
-127
timidity/COPYING less more
0 The "Artistic License"
1
2 Preamble
3
4 The intent of this document is to state the conditions under which a
5 Package may be copied, such that the Copyright Holder maintains some
6 semblance of artistic control over the development of the package,
7 while giving the users of the package the right to use and distribute
8 the Package in a more-or-less customary fashion, plus the right to make
9 reasonable modifications.
10
11 Definitions:
12
13 "Package" refers to the collection of files distributed by the
14 Copyright Holder, and derivatives of that collection of files
15 created through textual modification.
16
17 "Standard Version" refers to such a Package if it has not been
18 modified, or has been modified in accordance with the wishes
19 of the Copyright Holder as specified below.
20
21 "Copyright Holder" is whoever is named in the copyright or
22 copyrights for the package.
23
24 "You" is you, if you're thinking about copying or distributing
25 this Package.
26
27 "Reasonable copying fee" is whatever you can justify on the
28 basis of media cost, duplication charges, time of people involved,
29 and so on. (You will not be required to justify it to the
30 Copyright Holder, but only to the computing community at large
31 as a market that must bear the fee.)
32
33 "Freely Available" means that no fee is charged for the item
34 itself, though there may be fees involved in handling the item.
35 It also means that recipients of the item may redistribute it
36 under the same conditions they received it.
37
38 1. You may make and give away verbatim copies of the source form of the
39 Standard Version of this Package without restriction, provided that you
40 duplicate all of the original copyright notices and associated disclaimers.
41
42 2. You may apply bug fixes, portability fixes and other modifications
43 derived from the Public Domain or from the Copyright Holder. A Package
44 modified in such a way shall still be considered the Standard Version.
45
46 3. You may otherwise modify your copy of this Package in any way, provided
47 that you insert a prominent notice in each changed file stating how and
48 when you changed that file, and provided that you do at least ONE of the
49 following:
50
51 a) place your modifications in the Public Domain or otherwise make them
52 Freely Available, such as by posting said modifications to Usenet or
53 an equivalent medium, or placing the modifications on a major archive
54 site such as uunet.uu.net, or by allowing the Copyright Holder to include
55 your modifications in the Standard Version of the Package.
56
57 b) use the modified Package only within your corporation or organization.
58
59 c) rename any non-standard executables so the names do not conflict
60 with standard executables, which must also be provided, and provide
61 a separate manual page for each non-standard executable that clearly
62 documents how it differs from the Standard Version.
63
64 d) make other distribution arrangements with the Copyright Holder.
65
66 4. You may distribute the programs of this Package in object code or
67 executable form, provided that you do at least ONE of the following:
68
69 a) distribute a Standard Version of the executables and library files,
70 together with instructions (in the manual page or equivalent) on where
71 to get the Standard Version.
72
73 b) accompany the distribution with the machine-readable source of
74 the Package with your modifications.
75
76 c) give non-standard executables non-standard names, and clearly
77 document the differences in manual pages (or equivalent), together
78 with instructions on where to get the Standard Version.
79
80 d) make other distribution arrangements with the Copyright Holder.
81
82 5. You may charge a reasonable copying fee for any distribution of this
83 Package. You may charge any fee you choose for support of this
84 Package. You may not charge a fee for this Package itself. However,
85 you may distribute this Package in aggregate with other (possibly
86 commercial) programs as part of a larger (possibly commercial) software
87 distribution provided that you do not advertise this Package as a
88 product of your own. You may embed this Package's interpreter within
89 an executable of yours (by linking); this shall be construed as a mere
90 form of aggregation, provided that the complete Standard Version of the
91 interpreter is so embedded.
92
93 6. The scripts and library files supplied as input to or produced as
94 output from the programs of this Package do not automatically fall
95 under the copyright of this Package, but belong to whoever generated
96 them, and may be sold commercially, and may be aggregated with this
97 Package. If such scripts or library files are aggregated with this
98 Package via the so-called "undump" or "unexec" methods of producing a
99 binary executable image, then distribution of such an image shall
100 neither be construed as a distribution of this Package nor shall it
101 fall under the restrictions of Paragraphs 3 and 4, provided that you do
102 not represent such an executable image as a Standard Version of this
103 Package.
104
105 7. C subroutines (or comparably compiled subroutines in other
106 languages) supplied by you and linked into this Package in order to
107 emulate subroutines and variables of the language defined by this
108 Package shall not be considered part of this Package, but are the
109 equivalent of input as in Paragraph 6, provided these subroutines do
110 not change the language in any way that would cause it to fail the
111 regression tests for the language.
112
113 8. Aggregation of this Package with a commercial distribution is always
114 permitted provided that the use of this Package is embedded; that is,
115 when no overt attempt is made to make this Package's interfaces visible
116 to the end user of the commercial distribution. Such use shall not be
117 construed as a distribution of this Package.
118
119 9. The name of the Copyright Holder may not be used to endorse or promote
120 products derived from this software without specific prior written permission.
121
122 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
123 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
124 WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
125
126 The End
+0
-100
timidity/FAQ less more
0 ---------------------------*-indented-text-*------------------------------
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 --------------------------------------------------------------------------
6
7 Frequently Asked Questions with answers:
8
9 --------------------------------------------------------------------------
10 Q: What is it?
11
12 A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI
13 renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines,
14 even (I've heard) a Netscape helper application. It takes a MIDI file
15 and writes a WAVE or raw PCM data or plays it on your digital audio
16 device. It sounds much more realistic than FM synthesis, but you need a
17 ~100Mhz processor to listen to 32kHz stereo music in the background while
18 you work. 11kHz mono can be played on a low-end 486, and, to some, it
19 still sounds better than FM.
20
21 --------------------------------------------------------------------------
22 Q: I don't have a GUS, can I use TiMidity?
23
24 A: Yes. That's the point. You don't need a Gravis Ultrasound to use
25 TiMidity, you just need GUS-compatible patches, which are freely
26 available on the Internet. See below for pointers.
27
28 --------------------------------------------------------------------------
29 Q: I have a GUS, can I use TiMidity?
30
31 A: The DOS port doesn't have GUS support, and TiMidity won't be taking
32 advantage of the board's internal synthesizer under other operating
33 systems either. So it kind of defeats the purpose. But you can use it.
34
35 --------------------------------------------------------------------------
36 Q: I tried playing a MIDI file I got off the Net but all I got was a
37 dozen warnings saying "No instrument mapped to tone bank 0, program
38 xx - this instrument will not be heard". What's wrong?
39
40 A: The General MIDI standard specifies 128 melodic instruments and
41 some sixty percussion sounds. If you wish to play arbitrary General
42 MIDI files, you'll need to get more patch files.
43
44 There's a program called Midia for SGI's, which also plays MIDI
45 files and has a lot more bells and whistles than TiMidity. It uses
46 GUS-compatible patches, too -- so you can get the 8 MB set at
47 ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility.
48
49 There are also many excellent patches on the Ultrasound FTP sites.
50 I can recommend Dustin McCartney's collections gsdrum*.zip and
51 wow*.zip in the "[.../]sound/patches/files" directory. The huge
52 ProPats series (pp3-*.zip) contains good patches as well. General
53 MIDI files can also be found on these sites.
54
55 This site list is from the GUS FAQ:
56
57 > FTP Sites Archive Directories
58 > --------- -------------------
59 > Main N.American Site: archive.orst.edu pub/packages/gravis
60 > wuarchive.wustl.edu systems/ibmpc/ultrasound
61 > Main Asian Site: nctuccca.edu.tw PC/ultrasound
62 > Main European Site: src.doc.ic.ac.uk packages/ultrasound
63 > Main Australian Site: ftp.mpx.com.au /ultrasound/general
64 > /ultrasound/submit
65 > South African Site: ftp.sun.ac.za /pub/packages/ultrasound
66 > Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit
67 > Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound
68 >
69 > Mirrors: garbo.uwasa.fi mirror/ultrasound
70 > ftp.st.nepean.uws.edu.au pc/ultrasound
71 > ftp.luth.se pub/msdos/ultrasound
72
73 --------------------------------------------------------------------------
74 Q: Some files have awful clicks and pops.
75
76 A: Find out which patch is responsible for the clicking (try "timidity
77 -P<patch> <midi/test-decay|midi/test-panning>". Add "strip=tail" in
78 the config file after its name. If this doesn't fix it, mail me the
79 patch.
80
81 --------------------------------------------------------------------------
82 Q: I'm playing Fantasie Impromptu in the background. When I run Netscape,
83 the sound gets choppy and it takes ten minutes to load. What can I do?
84
85 A: Here are some things to try:
86
87 - Use a lower sampling rate.
88
89 - Use mono output. This can improve performance by 10-30%.
90 (Using 8-bit instead of 16-bit output makes no difference.)
91
92 - Use a smaller number of simultaneous voices.
93
94 - Make sure you compiled with FAST_DECAY enabled in options.h
95
96 - Recompile with an Intel-optimized gcc for a 5-15%
97 performance increase.
98
99 --------------------------------------------------------------------------
+0
-58
timidity/README less more
0 [This version of timidity has been stripped for simplicity in porting to SDL,
1 and then even further for SDL_sound]
2 ---------------------------------*-text-*---------------------------------
3
4 From http://www.cgs.fi/~tt/discontinued.html :
5
6 If you'd like to continue hacking on TiMidity, feel free. I'm
7 hereby extending the TiMidity license agreement: you can now
8 select the most convenient license for your needs from (1) the
9 GNU GPL, (2) the GNU LGPL, or (3) the Perl Artistic License.
10
11 --------------------------------------------------------------------------
12
13 This is the README file for TiMidity v0.2i
14
15 TiMidity is a MIDI to WAVE converter that uses Gravis
16 Ultrasound(*)-compatible patch files to generate digital audio data
17 from General MIDI files. The audio data can be played through any
18 sound device or stored on disk. On a fast machine, music can be
19 played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and
20 Win32, and porting to other systems with gcc should be easy.
21
22 TiMidity Features:
23
24 * 32 or more dynamically allocated fully independent voices
25 * Compatibility with GUS patch files
26 * Output to 16- or 8-bit PCM or uLaw audio device, file, or
27 stdout at any sampling rate
28 * Optional interactive mode with real-time status display
29 under ncurses and SLang terminal control libraries. Also
30 a user friendly motif interface since version 0.2h
31 * Support for transparent loading of compressed MIDI files and
32 patch files
33
34 * Support for the following MIDI events:
35 - Program change
36 - Key pressure
37 - Channel main volume
38 - Tempo
39 - Panning
40 - Damper pedal (Sustain)
41 - Pitch wheel
42 - Pitch wheel sensitivity
43 - Change drum set
44
45 * TiMidity requires sampled instruments (patches) to play MIDI files. You
46 should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same
47 directory where you unpacked the source code archive. You'll want more
48 patches later -- read the file "FAQ" for pointers.
49
50 * Timidity is no longer supported, but can be found by searching the web.
51
52
53 Tuukka Toivonen <toivonen@clinet.fi>
54
55 [(*) Any Registered Trademarks used anywhere in the documentation or
56 source code for TiMidity are acknowledged as belonging to their
57 respective owners.]
+0
-37
timidity/TODO less more
0 * I don't like the indentation style at all, but for the most part
1 I've left it alone.
2
3 * Much of the code looks ugly to me.
4
5 * The return value from SDL_RWread() is checked inconsistenly.
6
7 * Group the members of MidiSong into logical units, i.e. structs?
8
9 * The debug messages are probably a bit too noisy. I've removed one
10 particularly annoying one, but...
11
12 Some of them should be turned into error messages instead.
13
14 * Can the instrument handling be made more efficient? At the moment
15 different MidiSongs may separately load the same instrument.
16
17 Note that the MidiSong's audio format affects how the instrument is
18 loaded, so it's not as easy as just letting all MidiSongs share tone
19 and drum banks.
20
21 At the moment they do share the data that is simply read from the
22 config file, but that's just a quick hack to avoid having to read
23 the config file every time a MIDI song is loaded.
24
25 * Check if any of MidiStruct's members can safely be made into static
26 globals again.
27
28 * TiMidity++ adds a number of undocumented (?) extensions to the
29 configuration syntax. These are not implemented here. In particular,
30 the "map" keyword used by the "eawpats".
31
32 * The other decoders generally only read as much of the file as is
33 necessary. Could we do that in this decoder as well? (Currently it
34 seems to convert the entire file into MIDI events first.)
35
36 * Can it be optimized?
+0
-123
timidity/common.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 common.c
9 */
10
11 #if HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18
19 #include "SDL.h"
20
21 #include "options.h"
22 #include "common.h"
23
24 /* The paths in this list will be tried whenever we're reading a file */
25 static PathList *pathlist = NULL; /* This is a linked list */
26
27 /* This is meant to find and open files for reading */
28 SDL_RWops *open_file(const char *name)
29 {
30 SDL_RWops *rw;
31
32 if (!name || !(*name))
33 {
34 SNDDBG(("Attempted to open nameless file.\n"));
35 return 0;
36 }
37
38 /* First try the given name */
39
40 SNDDBG(("Trying to open %s\n", name));
41 if ((rw = SDL_RWFromFile(name, "rb")))
42 return rw;
43
44 if (name[0] != PATH_SEP)
45 {
46 char current_filename[1024];
47 PathList *plp = pathlist;
48 size_t l;
49
50 while (plp) /* Try along the path then */
51 {
52 *current_filename = 0;
53 l = strlen(plp->path);
54 if(l)
55 {
56 strcpy(current_filename, plp->path);
57 if(current_filename[l - 1] != PATH_SEP)
58 {
59 current_filename[l] = PATH_SEP;
60 current_filename[l + 1] = '\0';
61 }
62 }
63 strcat(current_filename, name);
64 SNDDBG(("Trying to open %s\n", current_filename));
65 if ((rw = SDL_RWFromFile(current_filename, "rb")))
66 return rw;
67 plp = plp->next;
68 }
69 }
70
71 /* Nothing could be opened. */
72 SNDDBG(("Could not open %s\n", name));
73 return 0;
74 }
75
76 /* This'll allocate memory or die. */
77 void *safe_malloc(size_t count)
78 {
79 void *p;
80
81 p = malloc(count);
82 if (p == NULL) {
83 SNDDBG(("Sorry. Couldn't malloc %d bytes.\n", count));
84 }
85
86 return p;
87 }
88
89 /* This adds a directory to the path list */
90 void add_to_pathlist(const char *s)
91 {
92 PathList *plp = safe_malloc(sizeof(PathList));
93
94 if (plp == NULL)
95 return;
96
97 plp->path = safe_malloc(strlen(s) + 1);
98 if (plp->path == NULL)
99 {
100 free(plp);
101 return;
102 }
103
104 strcpy(plp->path, s);
105 plp->next = pathlist;
106 pathlist = plp;
107 }
108
109 void free_pathlist(void)
110 {
111 PathList *plp = pathlist;
112 PathList *next;
113
114 while (plp)
115 {
116 next = plp->next;
117 free(plp->path);
118 free(plp);
119 plp = next;
120 }
121 pathlist = NULL;
122 }
+0
-20
timidity/common.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 common.h
9 */
10
11 typedef struct {
12 char *path;
13 void *next;
14 } PathList;
15
16 extern SDL_RWops *open_file(const char *name);
17 extern void add_to_pathlist(const char *s);
18 extern void *safe_malloc(size_t count);
19 extern void free_pathlist(void);
+0
-609
timidity/instrum.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 instrum.c
9
10 Code to load and unload GUS-compatible instrument patches.
11
12 */
13
14 #if HAVE_CONFIG_H
15 # include <config.h>
16 #endif
17
18 #include <stdio.h>
19 #include <string.h>
20 #include <stdlib.h>
21
22 #include "SDL.h"
23
24 #include "timidity.h"
25 #include "options.h"
26 #include "common.h"
27 #include "instrum.h"
28 #include "resample.h"
29 #include "tables.h"
30
31 static void free_instrument(Instrument *ip)
32 {
33 Sample *sp;
34 int i;
35 if (!ip) return;
36 for (i=0; i<ip->samples; i++)
37 {
38 sp=&(ip->sample[i]);
39 free(sp->data);
40 }
41 free(ip->sample);
42 free(ip);
43 }
44
45 static void free_bank(MidiSong *song, int dr, int b)
46 {
47 int i;
48 ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]);
49 for (i=0; i<MAXBANK; i++)
50 if (bank->instrument[i])
51 {
52 /* Not that this could ever happen, of course */
53 if (bank->instrument[i] != MAGIC_LOAD_INSTRUMENT)
54 free_instrument(bank->instrument[i]);
55 bank->instrument[i]=0;
56 }
57 }
58
59 static Sint32 convert_envelope_rate(MidiSong *song, Uint8 rate)
60 {
61 Sint32 r;
62
63 r = 3 - ((rate >> 6) & 0x3);
64 r *= 3;
65 r = (Sint32) (rate & 0x3f) << r; /* 6.9 fixed point */
66
67 /* 15.15 fixed point. */
68 r = ((r * 44100) / song->rate) * song->control_ratio;
69
70 #ifdef FAST_DECAY
71 return r << 10;
72 #else
73 return r << 9;
74 #endif
75 }
76
77 static Sint32 convert_envelope_offset(Uint8 offset)
78 {
79 /* This is not too good... Can anyone tell me what these values mean?
80 Are they GUS-style "exponential" volumes? And what does that mean? */
81
82 /* 15.15 fixed point */
83 return offset << (7+15);
84 }
85
86 static Sint32 convert_tremolo_sweep(MidiSong *song, Uint8 sweep)
87 {
88 if (!sweep)
89 return 0;
90
91 return
92 ((song->control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) /
93 (song->rate * sweep);
94 }
95
96 static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep,
97 Sint32 vib_control_ratio)
98 {
99 if (!sweep)
100 return 0;
101
102 return
103 (Sint32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT)
104 / (double)(song->rate * sweep));
105
106 /* this was overflowing with seashore.pat
107
108 ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) /
109 (song->rate * sweep); */
110 }
111
112 static Sint32 convert_tremolo_rate(MidiSong *song, Uint8 rate)
113 {
114 return
115 ((SINE_CYCLE_LENGTH * song->control_ratio * rate) << RATE_SHIFT) /
116 (TREMOLO_RATE_TUNING * song->rate);
117 }
118
119 static Sint32 convert_vibrato_rate(MidiSong *song, Uint8 rate)
120 {
121 /* Return a suitable vibrato_control_ratio value */
122 return
123 (VIBRATO_RATE_TUNING * song->rate) /
124 (rate * 2 * VIBRATO_SAMPLE_INCREMENTS);
125 }
126
127 static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le)
128 {
129 Sint16 s, *ep=sp+le;
130 sp+=ls;
131 le-=ls;
132 le/=2;
133 while (le--)
134 {
135 s=*sp;
136 *sp++=*ep;
137 *ep--=s;
138 }
139 }
140
141 /*
142 If panning or note_to_use != -1, it will be used for all samples,
143 instead of the sample-specific values in the instrument file.
144
145 For note_to_use, any value <0 or >127 will be forced to 0.
146
147 For other parameters, 1 means yes, 0 means no, other values are
148 undefined.
149
150 TODO: do reverse loops right */
151 static Instrument *load_instrument(MidiSong *song, char *name, int percussion,
152 int panning, int amp, int note_to_use,
153 int strip_loop, int strip_envelope,
154 int strip_tail)
155 {
156 Instrument *ip;
157 Sample *sp;
158 SDL_RWops *rw;
159 char tmp[1024];
160 int i,j,noluck=0;
161 static char *patch_ext[] = PATCH_EXT_LIST;
162
163 if (!name) return 0;
164
165 /* Open patch file */
166 if ((rw=open_file(name)) == NULL)
167 {
168 noluck=1;
169 /* Try with various extensions */
170 for (i=0; patch_ext[i]; i++)
171 {
172 if (strlen(name)+strlen(patch_ext[i])<1024)
173 {
174 strcpy(tmp, name);
175 strcat(tmp, patch_ext[i]);
176 if ((rw=open_file(tmp)) != NULL)
177 {
178 noluck=0;
179 break;
180 }
181 }
182 }
183 }
184
185 if (noluck)
186 {
187 SNDDBG(("Instrument `%s' can't be found.\n", name));
188 return 0;
189 }
190
191 SNDDBG(("Loading instrument %s\n", tmp));
192
193 /* Read some headers and do cursory sanity checks. There are loads
194 of magic offsets. This could be rewritten... */
195
196 if ((239 != SDL_RWread(rw, tmp, 1, 239)) ||
197 (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) &&
198 memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the
199 differences are */
200 {
201 SNDDBG(("%s: not an instrument\n", name));
202 SDL_RWclose(rw);
203 return 0;
204 }
205
206 if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers,
207 0 means 1 */
208 {
209 SNDDBG(("Can't handle patches with %d instruments\n", tmp[82]));
210 SDL_RWclose(rw);
211 return 0;
212 }
213
214 if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */
215 {
216 SNDDBG(("Can't handle instruments with %d layers\n", tmp[151]));
217 SDL_RWclose(rw);
218 return 0;
219 }
220
221 ip=safe_malloc(sizeof(Instrument));
222 ip->samples = tmp[198];
223 ip->sample = safe_malloc(sizeof(Sample) * ip->samples);
224 for (i=0; i<ip->samples; i++)
225 {
226
227 Uint8 fractions;
228 Sint32 tmplong;
229 Uint16 tmpshort;
230 Uint8 tmpchar;
231
232 #define READ_CHAR(thing) \
233 if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto fail; \
234 thing = tmpchar;
235 #define READ_SHORT(thing) \
236 if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto fail; \
237 thing = SDL_SwapLE16(tmpshort);
238 #define READ_LONG(thing) \
239 if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto fail; \
240 thing = SDL_SwapLE32(tmplong);
241
242 SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */
243
244 if (1 != SDL_RWread(rw, &fractions, 1, 1))
245 {
246 fail:
247 SNDDBG(("Error reading sample %d\n", i));
248 for (j=0; j<i; j++)
249 free(ip->sample[j].data);
250 free(ip->sample);
251 free(ip);
252 SDL_RWclose(rw);
253 return 0;
254 }
255
256 sp=&(ip->sample[i]);
257
258 READ_LONG(sp->data_length);
259 READ_LONG(sp->loop_start);
260 READ_LONG(sp->loop_end);
261 READ_SHORT(sp->sample_rate);
262 READ_LONG(sp->low_freq);
263 READ_LONG(sp->high_freq);
264 READ_LONG(sp->root_freq);
265 SDL_RWseek(rw, 2, RW_SEEK_CUR); /* Why have a "root frequency" and then
266 * "tuning"?? */
267
268 READ_CHAR(tmp[0]);
269
270 if (panning==-1)
271 sp->panning = (tmp[0] * 8 + 4) & 0x7f;
272 else
273 sp->panning=(Uint8)(panning & 0x7F);
274
275 /* envelope, tremolo, and vibrato */
276 if (18 != SDL_RWread(rw, tmp, 1, 18)) goto fail;
277
278 if (!tmp[13] || !tmp[14])
279 {
280 sp->tremolo_sweep_increment=
281 sp->tremolo_phase_increment=sp->tremolo_depth=0;
282 SNDDBG((" * no tremolo\n"));
283 }
284 else
285 {
286 sp->tremolo_sweep_increment=convert_tremolo_sweep(song, tmp[12]);
287 sp->tremolo_phase_increment=convert_tremolo_rate(song, tmp[13]);
288 sp->tremolo_depth=tmp[14];
289 SNDDBG((" * tremolo: sweep %d, phase %d, depth %d\n",
290 sp->tremolo_sweep_increment, sp->tremolo_phase_increment,
291 sp->tremolo_depth));
292 }
293
294 if (!tmp[16] || !tmp[17])
295 {
296 sp->vibrato_sweep_increment=
297 sp->vibrato_control_ratio=sp->vibrato_depth=0;
298 SNDDBG((" * no vibrato\n"));
299 }
300 else
301 {
302 sp->vibrato_control_ratio=convert_vibrato_rate(song, tmp[16]);
303 sp->vibrato_sweep_increment=
304 convert_vibrato_sweep(song, tmp[15], sp->vibrato_control_ratio);
305 sp->vibrato_depth=tmp[17];
306 SNDDBG((" * vibrato: sweep %d, ctl %d, depth %d\n",
307 sp->vibrato_sweep_increment, sp->vibrato_control_ratio,
308 sp->vibrato_depth));
309
310 }
311
312 READ_CHAR(sp->modes);
313
314 SDL_RWseek(rw, 40, RW_SEEK_CUR); /* skip the useless scale frequency, scale
315 factor (what's it mean?), and reserved
316 space */
317
318 /* Mark this as a fixed-pitch instrument if such a deed is desired. */
319 if (note_to_use!=-1)
320 sp->note_to_use=(Uint8)(note_to_use);
321 else
322 sp->note_to_use=0;
323
324 /* seashore.pat in the Midia patch set has no Sustain. I don't
325 understand why, and fixing it by adding the Sustain flag to
326 all looped patches probably breaks something else. We do it
327 anyway. */
328
329 if (sp->modes & MODES_LOOPING)
330 sp->modes |= MODES_SUSTAIN;
331
332 /* Strip any loops and envelopes we're permitted to */
333 if ((strip_loop==1) &&
334 (sp->modes & (MODES_SUSTAIN | MODES_LOOPING |
335 MODES_PINGPONG | MODES_REVERSE)))
336 {
337 SNDDBG((" - Removing loop and/or sustain\n"));
338 sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING |
339 MODES_PINGPONG | MODES_REVERSE);
340 }
341
342 if (strip_envelope==1)
343 {
344 if (sp->modes & MODES_ENVELOPE) {
345 SNDDBG((" - Removing envelope\n"));
346 }
347 sp->modes &= ~MODES_ENVELOPE;
348 }
349 else if (strip_envelope != 0)
350 {
351 /* Have to make a guess. */
352 if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE)))
353 {
354 /* No loop? Then what's there to sustain? No envelope needed
355 either... */
356 sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE);
357 SNDDBG((" - No loop, removing sustain and envelope\n"));
358 }
359 else if (!memcmp(tmp, "??????", 6) || tmp[11] >= 100)
360 {
361 /* Envelope rates all maxed out? Envelope end at a high "offset"?
362 That's a weird envelope. Take it out. */
363 sp->modes &= ~MODES_ENVELOPE;
364 SNDDBG((" - Weirdness, removing envelope\n"));
365 }
366 else if (!(sp->modes & MODES_SUSTAIN))
367 {
368 /* No sustain? Then no envelope. I don't know if this is
369 justified, but patches without sustain usually don't need the
370 envelope either... at least the Gravis ones. They're mostly
371 drums. I think. */
372 sp->modes &= ~MODES_ENVELOPE;
373 SNDDBG((" - No sustain, removing envelope\n"));
374 }
375 }
376
377 for (j=0; j<6; j++)
378 {
379 sp->envelope_rate[j]=
380 convert_envelope_rate(song, tmp[j]);
381 sp->envelope_offset[j]=
382 convert_envelope_offset(tmp[6+j]);
383 }
384
385 /* Then read the sample data */
386 sp->data = (sample_t *) safe_malloc(sp->data_length+4);
387 if (1 != SDL_RWread(rw, sp->data, sp->data_length, 1))
388 goto fail;
389
390 if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */
391 {
392 Sint32 k=sp->data_length;
393 Uint8 *cp=(Uint8 *)(sp->data);
394 Uint16 *tmp16,*new16;
395 sp->data_length *= 2;
396 sp->loop_start *= 2;
397 sp->loop_end *= 2;
398 tmp16 = new16 = (Uint16 *) safe_malloc(sp->data_length+4);
399 while (k--)
400 *tmp16++ = (Uint16)(*cp++) << 8;
401 free(sp->data);
402 sp->data = (sample_t *)new16;
403 }
404 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
405 else
406 /* convert to machine byte order */
407 {
408 Sint32 k=sp->data_length/2;
409 Sint16 *tmp16=(Sint16 *)sp->data,s;
410 while (k--)
411 {
412 s=SDL_SwapLE16(*tmp16);
413 *tmp16++=s;
414 }
415 }
416 #endif
417
418 if (sp->modes & MODES_UNSIGNED) /* convert to signed data */
419 {
420 Sint32 k=sp->data_length/2;
421 Sint16 *tmp16=(Sint16 *)sp->data;
422 while (k--)
423 *tmp16++ ^= 0x8000;
424 }
425
426 /* Reverse reverse loops and pass them off as normal loops */
427 if (sp->modes & MODES_REVERSE)
428 {
429 Sint32 t;
430 /* The GUS apparently plays reverse loops by reversing the
431 whole sample. We do the same because the GUS does not SUCK. */
432
433 SNDDBG(("Reverse loop in %s\n", name));
434 reverse_data((Sint16 *)sp->data, 0, sp->data_length/2);
435
436 t=sp->loop_start;
437 sp->loop_start=sp->data_length - sp->loop_end;
438 sp->loop_end=sp->data_length - t;
439
440 sp->modes &= ~MODES_REVERSE;
441 sp->modes |= MODES_LOOPING; /* just in case */
442 }
443
444 #ifdef ADJUST_SAMPLE_VOLUMES
445 if (amp!=-1)
446 sp->volume=(float)((amp) / 100.0);
447 else
448 {
449 /* Try to determine a volume scaling factor for the sample.
450 This is a very crude adjustment, but things sound more
451 balanced with it. Still, this should be a runtime option. */
452 Sint32 k=sp->data_length/2;
453 Sint16 maxamp=0,a;
454 Sint16 *tmp16=(Sint16 *)sp->data;
455 while (k--)
456 {
457 a=*tmp16++;
458 if (a<0) a=-a;
459 if (a>maxamp)
460 maxamp=a;
461 }
462 sp->volume=(float)(32768.0 / maxamp);
463 SNDDBG((" * volume comp: %f\n", sp->volume));
464 }
465 #else
466 if (amp!=-1)
467 sp->volume=(double)(amp) / 100.0;
468 else
469 sp->volume=1.0;
470 #endif
471
472 sp->data_length /= 2; /* These are in bytes. Convert into samples. */
473 sp->loop_start /= 2;
474 sp->loop_end /= 2;
475
476 /* initialize the added extra sample space (see the +4 bytes in
477 allocation) using the last actual sample: */
478 sp->data[sp->data_length] = sp->data[sp->data_length+1] = 0;
479
480 /* Then fractional samples */
481 sp->data_length <<= FRACTION_BITS;
482 sp->loop_start <<= FRACTION_BITS;
483 sp->loop_end <<= FRACTION_BITS;
484
485 /* Adjust for fractional loop points. This is a guess. Does anyone
486 know what "fractions" really stands for? */
487 sp->loop_start |=
488 (fractions & 0x0F) << (FRACTION_BITS-4);
489 sp->loop_end |=
490 ((fractions>>4) & 0x0F) << (FRACTION_BITS-4);
491
492 /* If this instrument will always be played on the same note,
493 and it's not looped, we can resample it now. */
494 if (sp->note_to_use && !(sp->modes & MODES_LOOPING))
495 pre_resample(song, sp);
496
497 if (strip_tail==1)
498 {
499 /* Let's not really, just say we did. */
500 SNDDBG((" - Stripping tail\n"));
501 sp->data_length = sp->loop_end;
502 }
503 }
504
505 SDL_RWclose(rw);
506 return ip;
507 }
508
509 static int fill_bank(MidiSong *song, int dr, int b)
510 {
511 int i, errors=0;
512 ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]);
513 if (!bank)
514 {
515 SNDDBG(("Huh. Tried to load instruments in non-existent %s %d\n",
516 (dr) ? "drumset" : "tone bank", b));
517 return 0;
518 }
519 for (i=0; i<MAXBANK; i++)
520 {
521 if (bank->instrument[i]==MAGIC_LOAD_INSTRUMENT)
522 {
523 if (!(bank->tone[i].name))
524 {
525 SNDDBG(("No instrument mapped to %s %d, program %d%s\n",
526 (dr)? "drum set" : "tone bank", b, i,
527 (b!=0) ? "" : " - this instrument will not be heard"));
528 if (b!=0)
529 {
530 /* Mark the corresponding instrument in the default
531 bank / drumset for loading (if it isn't already) */
532 if (!dr)
533 {
534 if (!(song->tonebank[0]->instrument[i]))
535 song->tonebank[0]->instrument[i] =
536 MAGIC_LOAD_INSTRUMENT;
537 }
538 else
539 {
540 if (!(song->drumset[0]->instrument[i]))
541 song->drumset[0]->instrument[i] =
542 MAGIC_LOAD_INSTRUMENT;
543 }
544 }
545 bank->instrument[i] = 0;
546 errors++;
547 }
548 else if (!(bank->instrument[i] =
549 load_instrument(song,
550 bank->tone[i].name,
551 (dr) ? 1 : 0,
552 bank->tone[i].pan,
553 bank->tone[i].amp,
554 (bank->tone[i].note!=-1) ?
555 bank->tone[i].note :
556 ((dr) ? i : -1),
557 (bank->tone[i].strip_loop!=-1) ?
558 bank->tone[i].strip_loop :
559 ((dr) ? 1 : -1),
560 (bank->tone[i].strip_envelope != -1) ?
561 bank->tone[i].strip_envelope :
562 ((dr) ? 1 : -1),
563 bank->tone[i].strip_tail )))
564 {
565 SNDDBG(("Couldn't load instrument %s (%s %d, program %d)\n",
566 bank->tone[i].name,
567 (dr)? "drum set" : "tone bank", b, i));
568 errors++;
569 }
570 }
571 }
572 return errors;
573 }
574
575 int load_missing_instruments(MidiSong *song)
576 {
577 int i=MAXBANK,errors=0;
578 while (i--)
579 {
580 if (song->tonebank[i])
581 errors+=fill_bank(song,0,i);
582 if (song->drumset[i])
583 errors+=fill_bank(song,1,i);
584 }
585 return errors;
586 }
587
588 void free_instruments(MidiSong *song)
589 {
590 int i=MAXBANK;
591 while(i--)
592 {
593 if (song->tonebank[i])
594 free_bank(song, 0, i);
595 if (song->drumset[i])
596 free_bank(song, 1, i);
597 }
598 }
599
600 int set_default_instrument(MidiSong *song, char *name)
601 {
602 Instrument *ip;
603 if (!(ip=load_instrument(song, name, 0, -1, -1, -1, 0, 0, 0)))
604 return -1;
605 song->default_instrument = ip;
606 song->default_program = SPECIAL_PROGRAM;
607 return 0;
608 }
+0
-30
timidity/instrum.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 instrum.h
9
10 */
11
12 /* Bits in modes: */
13 #define MODES_16BIT (1<<0)
14 #define MODES_UNSIGNED (1<<1)
15 #define MODES_LOOPING (1<<2)
16 #define MODES_PINGPONG (1<<3)
17 #define MODES_REVERSE (1<<4)
18 #define MODES_SUSTAIN (1<<5)
19 #define MODES_ENVELOPE (1<<6)
20
21 /* A hack to delay instrument loading until after reading the
22 entire MIDI file. */
23 #define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1))
24
25 #define SPECIAL_PROGRAM -1
26
27 extern int load_missing_instruments(MidiSong *song);
28 extern void free_instruments(MidiSong *song);
29 extern int set_default_instrument(MidiSong *song, char *name);
+0
-557
timidity/mix.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 mix.c */
9
10 #if HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13
14 #include <math.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17
18 #include "SDL.h"
19
20 #include "timidity.h"
21 #include "options.h"
22 #include "instrum.h"
23 #include "playmidi.h"
24 #include "output.h"
25 #include "tables.h"
26 #include "resample.h"
27 #include "mix.h"
28
29 /* Returns 1 if envelope runs out */
30 int recompute_envelope(MidiSong *song, int v)
31 {
32 int stage;
33
34 stage = song->voice[v].envelope_stage;
35
36 if (stage>5)
37 {
38 /* Envelope ran out. */
39 song->voice[v].status = VOICE_FREE;
40 return 1;
41 }
42
43 if (song->voice[v].sample->modes & MODES_ENVELOPE)
44 {
45 if (song->voice[v].status==VOICE_ON || song->voice[v].status==VOICE_SUSTAINED)
46 {
47 if (stage>2)
48 {
49 /* Freeze envelope until note turns off. Trumpets want this. */
50 song->voice[v].envelope_increment=0;
51 return 0;
52 }
53 }
54 }
55 song->voice[v].envelope_stage=stage+1;
56
57 if (song->voice[v].envelope_volume==song->voice[v].sample->envelope_offset[stage] ||
58 (stage > 2 && song->voice[v].envelope_volume <
59 song->voice[v].sample->envelope_offset[stage]))
60 return recompute_envelope(song, v);
61 song->voice[v].envelope_target = song->voice[v].sample->envelope_offset[stage];
62 song->voice[v].envelope_increment = song->voice[v].sample->envelope_rate[stage];
63 if (song->voice[v].envelope_target < song->voice[v].envelope_volume)
64 song->voice[v].envelope_increment = -song->voice[v].envelope_increment;
65 return 0;
66 }
67
68 void apply_envelope_to_amp(MidiSong *song, int v)
69 {
70 float lamp = song->voice[v].left_amp, ramp;
71 Sint32 la,ra;
72 if (song->voice[v].panned == PANNED_MYSTERY)
73 {
74 ramp = song->voice[v].right_amp;
75 if (song->voice[v].tremolo_phase_increment)
76 {
77 lamp *= song->voice[v].tremolo_volume;
78 ramp *= song->voice[v].tremolo_volume;
79 }
80 if (song->voice[v].sample->modes & MODES_ENVELOPE)
81 {
82 lamp *= (float)vol_table[song->voice[v].envelope_volume>>23];
83 ramp *= (float)vol_table[song->voice[v].envelope_volume>>23];
84 }
85
86 la = (Sint32)FSCALE(lamp,AMP_BITS);
87
88 if (la>MAX_AMP_VALUE)
89 la=MAX_AMP_VALUE;
90
91 ra = (Sint32)FSCALE(ramp,AMP_BITS);
92 if (ra>MAX_AMP_VALUE)
93 ra=MAX_AMP_VALUE;
94
95 song->voice[v].left_mix = la;
96 song->voice[v].right_mix = ra;
97 }
98 else
99 {
100 if (song->voice[v].tremolo_phase_increment)
101 lamp *= song->voice[v].tremolo_volume;
102 if (song->voice[v].sample->modes & MODES_ENVELOPE)
103 lamp *= (float)vol_table[song->voice[v].envelope_volume>>23];
104
105 la = (Sint32)FSCALE(lamp,AMP_BITS);
106
107 if (la>MAX_AMP_VALUE)
108 la=MAX_AMP_VALUE;
109
110 song->voice[v].left_mix = la;
111 }
112 }
113
114 static int update_envelope(MidiSong *song, int v)
115 {
116 song->voice[v].envelope_volume += song->voice[v].envelope_increment;
117 /* Why is there no ^^ operator?? */
118 if (((song->voice[v].envelope_increment < 0) &&
119 (song->voice[v].envelope_volume <= song->voice[v].envelope_target)) ||
120 ((song->voice[v].envelope_increment > 0) &&
121 (song->voice[v].envelope_volume >= song->voice[v].envelope_target)))
122 {
123 song->voice[v].envelope_volume = song->voice[v].envelope_target;
124 if (recompute_envelope(song, v))
125 return 1;
126 }
127 return 0;
128 }
129
130 static void update_tremolo(MidiSong *song, int v)
131 {
132 Sint32 depth = song->voice[v].sample->tremolo_depth << 7;
133
134 if (song->voice[v].tremolo_sweep)
135 {
136 /* Update sweep position */
137
138 song->voice[v].tremolo_sweep_position += song->voice[v].tremolo_sweep;
139 if (song->voice[v].tremolo_sweep_position >= (1 << SWEEP_SHIFT))
140 song->voice[v].tremolo_sweep=0; /* Swept to max amplitude */
141 else
142 {
143 /* Need to adjust depth */
144 depth *= song->voice[v].tremolo_sweep_position;
145 depth >>= SWEEP_SHIFT;
146 }
147 }
148
149 song->voice[v].tremolo_phase += song->voice[v].tremolo_phase_increment;
150
151 /* if (song->voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<<RATE_SHIFT))
152 song->voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<<RATE_SHIFT; */
153
154 song->voice[v].tremolo_volume = (float)
155 (1.0 - FSCALENEG((sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0)
156 * depth * TREMOLO_AMPLITUDE_TUNING,
157 17));
158
159 /* I'm not sure about the +1.0 there -- it makes tremoloed voices'
160 volumes on average the lower the higher the tremolo amplitude. */
161 }
162
163 /* Returns 1 if the note died */
164 static int update_signal(MidiSong *song, int v)
165 {
166 if (song->voice[v].envelope_increment && update_envelope(song, v))
167 return 1;
168
169 if (song->voice[v].tremolo_phase_increment)
170 update_tremolo(song, v);
171
172 apply_envelope_to_amp(song, v);
173 return 0;
174 }
175
176 #define MIXATION(a) *lp++ += (a)*s;
177
178 static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
179 int count)
180 {
181 Voice *vp = song->voice + v;
182 final_volume_t
183 left=vp->left_mix,
184 right=vp->right_mix;
185 int cc;
186 sample_t s;
187
188 if (!(cc = vp->control_counter))
189 {
190 cc = song->control_ratio;
191 if (update_signal(song, v))
192 return; /* Envelope ran out */
193 left = vp->left_mix;
194 right = vp->right_mix;
195 }
196
197 while (count)
198 if (cc < count)
199 {
200 count -= cc;
201 while (cc--)
202 {
203 s = *sp++;
204 MIXATION(left);
205 MIXATION(right);
206 }
207 cc = song->control_ratio;
208 if (update_signal(song, v))
209 return; /* Envelope ran out */
210 left = vp->left_mix;
211 right = vp->right_mix;
212 }
213 else
214 {
215 vp->control_counter = cc - count;
216 while (count--)
217 {
218 s = *sp++;
219 MIXATION(left);
220 MIXATION(right);
221 }
222 return;
223 }
224 }
225
226 static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
227 int count)
228 {
229 Voice *vp = song->voice + v;
230 final_volume_t
231 left=vp->left_mix;
232 int cc;
233 sample_t s;
234
235 if (!(cc = vp->control_counter))
236 {
237 cc = song->control_ratio;
238 if (update_signal(song, v))
239 return; /* Envelope ran out */
240 left = vp->left_mix;
241 }
242
243 while (count)
244 if (cc < count)
245 {
246 count -= cc;
247 while (cc--)
248 {
249 s = *sp++;
250 MIXATION(left);
251 MIXATION(left);
252 }
253 cc = song->control_ratio;
254 if (update_signal(song, v))
255 return; /* Envelope ran out */
256 left = vp->left_mix;
257 }
258 else
259 {
260 vp->control_counter = cc - count;
261 while (count--)
262 {
263 s = *sp++;
264 MIXATION(left);
265 MIXATION(left);
266 }
267 return;
268 }
269 }
270
271 static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
272 int count)
273 {
274 Voice *vp = song->voice + v;
275 final_volume_t
276 left=vp->left_mix;
277 int cc;
278 sample_t s;
279
280 if (!(cc = vp->control_counter))
281 {
282 cc = song->control_ratio;
283 if (update_signal(song, v))
284 return; /* Envelope ran out */
285 left = vp->left_mix;
286 }
287
288 while (count)
289 if (cc < count)
290 {
291 count -= cc;
292 while (cc--)
293 {
294 s = *sp++;
295 MIXATION(left);
296 lp++;
297 }
298 cc = song->control_ratio;
299 if (update_signal(song, v))
300 return; /* Envelope ran out */
301 left = vp->left_mix;
302 }
303 else
304 {
305 vp->control_counter = cc - count;
306 while (count--)
307 {
308 s = *sp++;
309 MIXATION(left);
310 lp++;
311 }
312 return;
313 }
314 }
315
316 static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
317 int count)
318 {
319 Voice *vp = song->voice + v;
320 final_volume_t
321 left=vp->left_mix;
322 int cc;
323 sample_t s;
324
325 if (!(cc = vp->control_counter))
326 {
327 cc = song->control_ratio;
328 if (update_signal(song, v))
329 return; /* Envelope ran out */
330 left = vp->left_mix;
331 }
332
333 while (count)
334 if (cc < count)
335 {
336 count -= cc;
337 while (cc--)
338 {
339 s = *sp++;
340 MIXATION(left);
341 }
342 cc = song->control_ratio;
343 if (update_signal(song, v))
344 return; /* Envelope ran out */
345 left = vp->left_mix;
346 }
347 else
348 {
349 vp->control_counter = cc - count;
350 while (count--)
351 {
352 s = *sp++;
353 MIXATION(left);
354 }
355 return;
356 }
357 }
358
359 static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
360 {
361 final_volume_t
362 left = song->voice[v].left_mix,
363 right = song->voice[v].right_mix;
364 sample_t s;
365
366 while (count--)
367 {
368 s = *sp++;
369 MIXATION(left);
370 MIXATION(right);
371 }
372 }
373
374 static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
375 {
376 final_volume_t
377 left = song->voice[v].left_mix;
378 sample_t s;
379
380 while (count--)
381 {
382 s = *sp++;
383 MIXATION(left);
384 MIXATION(left);
385 }
386 }
387
388 static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
389 {
390 final_volume_t
391 left = song->voice[v].left_mix;
392 sample_t s;
393
394 while (count--)
395 {
396 s = *sp++;
397 MIXATION(left);
398 lp++;
399 }
400 }
401
402 static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
403 {
404 final_volume_t
405 left = song->voice[v].left_mix;
406 sample_t s;
407
408 while (count--)
409 {
410 s = *sp++;
411 MIXATION(left);
412 }
413 }
414
415 /* Ramp a note out in c samples */
416 static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c)
417 {
418
419 /* should be final_volume_t, but Uint8 gives trouble. */
420 Sint32 left, right, li, ri;
421
422 sample_t s=0; /* silly warning about uninitialized s */
423
424 left=song->voice[v].left_mix;
425 li=-(left/c);
426 if (!li) li=-1;
427
428 /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */
429
430 if (!(song->encoding & PE_MONO))
431 {
432 if (song->voice[v].panned==PANNED_MYSTERY)
433 {
434 right=song->voice[v].right_mix;
435 ri=-(right/c);
436 while (c--)
437 {
438 left += li;
439 if (left<0)
440 left=0;
441 right += ri;
442 if (right<0)
443 right=0;
444 s=*sp++;
445 MIXATION(left);
446 MIXATION(right);
447 }
448 }
449 else if (song->voice[v].panned==PANNED_CENTER)
450 {
451 while (c--)
452 {
453 left += li;
454 if (left<0)
455 return;
456 s=*sp++;
457 MIXATION(left);
458 MIXATION(left);
459 }
460 }
461 else if (song->voice[v].panned==PANNED_LEFT)
462 {
463 while (c--)
464 {
465 left += li;
466 if (left<0)
467 return;
468 s=*sp++;
469 MIXATION(left);
470 lp++;
471 }
472 }
473 else if (song->voice[v].panned==PANNED_RIGHT)
474 {
475 while (c--)
476 {
477 left += li;
478 if (left<0)
479 return;
480 s=*sp++;
481 lp++;
482 MIXATION(left);
483 }
484 }
485 }
486 else
487 {
488 /* Mono output. */
489 while (c--)
490 {
491 left += li;
492 if (left<0)
493 return;
494 s=*sp++;
495 MIXATION(left);
496 }
497 }
498 }
499
500
501 /**************** interface function ******************/
502
503 void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c)
504 {
505 Voice *vp = song->voice + v;
506 sample_t *sp;
507 if (vp->status==VOICE_DIE)
508 {
509 if (c>=MAX_DIE_TIME)
510 c=MAX_DIE_TIME;
511 sp=resample_voice(song, v, &c);
512 if(c > 0)
513 ramp_out(song, sp, buf, v, c);
514 vp->status=VOICE_FREE;
515 }
516 else
517 {
518 sp=resample_voice(song, v, &c);
519 if (song->encoding & PE_MONO)
520 {
521 /* Mono output. */
522 if (vp->envelope_increment || vp->tremolo_phase_increment)
523 mix_mono_signal(song, sp, buf, v, c);
524 else
525 mix_mono(song, sp, buf, v, c);
526 }
527 else
528 {
529 if (vp->panned == PANNED_MYSTERY)
530 {
531 if (vp->envelope_increment || vp->tremolo_phase_increment)
532 mix_mystery_signal(song, sp, buf, v, c);
533 else
534 mix_mystery(song, sp, buf, v, c);
535 }
536 else if (vp->panned == PANNED_CENTER)
537 {
538 if (vp->envelope_increment || vp->tremolo_phase_increment)
539 mix_center_signal(song, sp, buf, v, c);
540 else
541 mix_center(song, sp, buf, v, c);
542 }
543 else
544 {
545 /* It's either full left or full right. In either case,
546 every other sample is 0. Just get the offset right: */
547 if (vp->panned == PANNED_RIGHT) buf++;
548
549 if (vp->envelope_increment || vp->tremolo_phase_increment)
550 mix_single_signal(song, sp, buf, v, c);
551 else
552 mix_single(song, sp, buf, v, c);
553 }
554 }
555 }
556 }
+0
-15
timidity/mix.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 mix.h
9
10 */
11
12 extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c);
13 extern int recompute_envelope(MidiSong *song, int v);
14 extern void apply_envelope_to_amp(MidiSong *song, int v);
+0
-117
timidity/options.h less more
0 /*
1 TiMidity -- Experimental MIDI to WAVE converter
2 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Perl Artistic License, available in COPYING.
6 */
7
8 /* When a patch file can't be opened, one of these extensions is
9 appended to the filename and the open is tried again.
10 */
11 #define PATCH_EXT_LIST { ".pat", 0 }
12
13 /* Acoustic Grand Piano seems to be the usual default instrument. */
14 #define DEFAULT_PROGRAM 0
15
16 /* 9 here is MIDI channel 10, which is the standard percussion channel.
17 Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
18 On the other hand, some files know that 16 is not a drum channel and
19 try to play music on it. This is now a runtime option, so this isn't
20 a critical choice anymore. */
21 #define DEFAULT_DRUMCHANNELS (1<<9)
22
23 /* In percent. */
24 #define DEFAULT_AMPLIFICATION 70
25
26 /* Default polyphony */
27 /* #define DEFAULT_VOICES 32 */
28 #define DEFAULT_VOICES 256
29
30 /* 1000 here will give a control ratio of 22:1 with 22 kHz output.
31 Higher CONTROLS_PER_SECOND values allow more accurate rendering
32 of envelopes and tremolo. The cost is CPU time. */
33 #define CONTROLS_PER_SECOND 1000
34
35 /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
36 faster) and sounds more like a GUS. There is now a command line
37 option to toggle this as well. */
38 #define FAST_DECAY
39
40 /* How many bits to use for the fractional part of sample positions.
41 This affects tonal accuracy. The entire position counter must fit
42 in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
43 a sample is 1048576 samples (2 megabytes in memory). The GUS gets
44 by with just 9 bits and a little help from its friends...
45 "The GUS does not SUCK!!!" -- a happy user :) */
46 #define FRACTION_BITS 12
47
48 /* For some reason the sample volume is always set to maximum in all
49 patch files. Define this for a crude adjustment that may help
50 equalize instrument volumes. */
51 #define ADJUST_SAMPLE_VOLUMES
52
53 /* The number of samples to use for ramping out a dying note. Affects
54 click removal. */
55 #define MAX_DIE_TIME 20
56
57 /**************************************************************************/
58 /* Anything below this shouldn't need to be changed unless you're porting
59 to a new machine with other than 32-bit, big-endian words. */
60 /**************************************************************************/
61
62 /* change FRACTION_BITS above, not these */
63 #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
64 #define FRACTION_MASK (~ INTEGER_MASK)
65
66 /* This is enforced by some computations that must fit in an int */
67 #define MAX_CONTROL_RATIO 255
68
69 #define MAX_AMPLIFICATION 800
70
71 /* You could specify a complete path, e.g. "/etc/timidity.cfg", and
72 then specify the library directory in the configuration file. */
73 #define CONFIG_FILE "timidity.cfg"
74 #define CONFIG_FILE_ETC "/etc/timidity.cfg"
75 #define CONFIG_FILE_ETC_TIMIDITY_FREEPATS "/etc/timidity/freepats.cfg"
76
77 #if defined(__WIN32__) || defined(__OS2__)
78 #define DEFAULT_PATH "C:\\TIMIDITY"
79 #else
80 #define DEFAULT_PATH "/etc/timidity"
81 #define DEFAULT_PATH1 "/usr/share/timidity"
82 #define DEFAULT_PATH2 "/usr/local/share/timidity"
83 #define DEFAULT_PATH3 "/usr/local/lib/timidity"
84 #endif
85
86 /* These affect general volume */
87 #define GUARD_BITS 3
88 #define AMP_BITS (15-GUARD_BITS)
89
90 #define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
91
92 #define FSCALE(a,b) (float)((a) * (double)(1<<(b)))
93 #define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
94
95 /* Vibrato and tremolo Choices of the Day */
96 #define SWEEP_TUNING 38
97 #define VIBRATO_AMPLITUDE_TUNING 1.0L
98 #define VIBRATO_RATE_TUNING 38
99 #define TREMOLO_AMPLITUDE_TUNING 1.0L
100 #define TREMOLO_RATE_TUNING 38
101
102 #define SWEEP_SHIFT 16
103 #define RATE_SHIFT 5
104
105 #ifndef PI
106 #define PI 3.14159265358979323846
107 #endif
108
109 /* The path separator (D.M.) */
110 #if defined(__WIN32__) || defined(__OS2__)
111 # define PATH_SEP '\\'
112 #else
113 # define PATH_SEP '/'
114 #endif
115
116 #define SNDDBG(X)
+0
-129
timidity/output.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 output.c
9
10 Audio output (to file / device) functions.
11 */
12
13 #if HAVE_CONFIG_H
14 # include <config.h>
15 #endif
16
17 #include "SDL.h"
18
19 #include "options.h"
20 #include "output.h"
21
22 /*****************************************************************/
23 /* Some functions to convert signed 32-bit data to other formats */
24
25 void s32tos8(void *dp, Sint32 *lp, Sint32 c)
26 {
27 Sint8 *cp=(Sint8 *)(dp);
28 Sint32 l;
29 while (c--)
30 {
31 l=(*lp++)>>(32-8-GUARD_BITS);
32 if (l>127) l=127;
33 else if (l<-128) l=-128;
34 *cp++ = (Sint8) (l);
35 }
36 }
37
38 void s32tou8(void *dp, Sint32 *lp, Sint32 c)
39 {
40 Uint8 *cp=(Uint8 *)(dp);
41 Sint32 l;
42 while (c--)
43 {
44 l=(*lp++)>>(32-8-GUARD_BITS);
45 if (l>127) l=127;
46 else if (l<-128) l=-128;
47 *cp++ = 0x80 ^ ((Uint8) l);
48 }
49 }
50
51 void s32tos16(void *dp, Sint32 *lp, Sint32 c)
52 {
53 Sint16 *sp=(Sint16 *)(dp);
54 Sint32 l;
55 while (c--)
56 {
57 l=(*lp++)>>(32-16-GUARD_BITS);
58 if (l > 32767) l=32767;
59 else if (l<-32768) l=-32768;
60 *sp++ = (Sint16)(l);
61 }
62 }
63
64 void s32tou16(void *dp, Sint32 *lp, Sint32 c)
65 {
66 Uint16 *sp=(Uint16 *)(dp);
67 Sint32 l;
68 while (c--)
69 {
70 l=(*lp++)>>(32-16-GUARD_BITS);
71 if (l > 32767) l=32767;
72 else if (l<-32768) l=-32768;
73 *sp++ = 0x8000 ^ (Uint16)(l);
74 }
75 }
76
77 void s32tos16x(void *dp, Sint32 *lp, Sint32 c)
78 {
79 Sint16 *sp=(Sint16 *)(dp);
80 Sint32 l;
81 while (c--)
82 {
83 l=(*lp++)>>(32-16-GUARD_BITS);
84 if (l > 32767) l=32767;
85 else if (l<-32768) l=-32768;
86 *sp++ = SDL_Swap16((Sint16)(l));
87 }
88 }
89
90 void s32tou16x(void *dp, Sint32 *lp, Sint32 c)
91 {
92 Uint16 *sp=(Uint16 *)(dp);
93 Sint32 l;
94 while (c--)
95 {
96 l=(*lp++)>>(32-16-GUARD_BITS);
97 if (l > 32767) l=32767;
98 else if (l<-32768) l=-32768;
99 *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l));
100 }
101 }
102
103 void s32tof32(void *dp, Sint32 *lp, Sint32 c)
104 {
105 float *sp=(float *)(dp);
106 while (c--)
107 {
108 *sp++ = (float)(*lp++) / 2147483647.0f;
109 }
110 }
111
112 void s32tos32(void *dp, Sint32 *lp, Sint32 c)
113 {
114 Sint32 *sp=(Sint32 *)(dp);
115 while (c--)
116 {
117 *sp++ = (*lp++);
118 }
119 }
120
121 void s32tos32x(void *dp, Sint32 *lp, Sint32 c)
122 {
123 Sint32 *sp=(Sint32 *)(dp);
124 while (c--)
125 {
126 *sp++ = SDL_Swap32(*lp++);
127 }
128 }
+0
-57
timidity/output.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 output.h
9
10 */
11
12 /* Data format encoding bits */
13
14 #define PE_MONO 0x01 /* versus stereo */
15 #define PE_SIGNED 0x02 /* versus unsigned */
16 #define PE_16BIT 0x04 /* versus 8-bit */
17 #define PE_32BIT 0x08 /* versus 8-bit or 16-bit */
18
19 /* Conversion functions -- These overwrite the Sint32 data in *lp with
20 data in another format */
21
22 /* 8-bit signed and unsigned*/
23 extern void s32tos8(void *dp, Sint32 *lp, Sint32 c);
24 extern void s32tou8(void *dp, Sint32 *lp, Sint32 c);
25
26 /* 16-bit */
27 extern void s32tos16(void *dp, Sint32 *lp, Sint32 c);
28 extern void s32tou16(void *dp, Sint32 *lp, Sint32 c);
29
30 /* byte-exchanged 16-bit */
31 extern void s32tos16x(void *dp, Sint32 *lp, Sint32 c);
32 extern void s32tou16x(void *dp, Sint32 *lp, Sint32 c);
33
34 /* 32-bit */
35 extern void s32tof32(void *dp, Sint32 *lp, Sint32 c);
36 extern void s32tos32(void *dp, Sint32 *lp, Sint32 c);
37
38 /* byte-exchanged 32-bit */
39 extern void s32tos32x(void *dp, Sint32 *lp, Sint32 c);
40
41 /* little-endian and big-endian specific */
42 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
43 #define s32tos16l s32tos16
44 #define s32tos16b s32tos16x
45 #define s32tou16l s32tou16
46 #define s32tou16b s32tou16x
47 #define s32tos32l s32tos32
48 #define s32tos32b s32tos32x
49 #else
50 #define s32tos16l s32tos16x
51 #define s32tos16b s32tos16
52 #define s32tou16l s32tou16x
53 #define s32tou16b s32tou16
54 #define s32tos32l s32tos32x
55 #define s32tos32b s32tos32
56 #endif
+0
-800
timidity/playmidi.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 playmidi.c -- random stuff in need of rearrangement
9
10 */
11
12 #if HAVE_CONFIG_H
13 # include <config.h>
14 #endif
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 #include "SDL.h"
21
22 #include "timidity.h"
23 #include "options.h"
24 #include "instrum.h"
25 #include "playmidi.h"
26 #include "output.h"
27 #include "mix.h"
28 #include "tables.h"
29
30 static void adjust_amplification(MidiSong *song)
31 {
32 song->master_volume = (float)(song->amplification) / (float)100.0;
33 }
34
35 static void reset_voices(MidiSong *song)
36 {
37 int i;
38 for (i=0; i<MAX_VOICES; i++)
39 song->voice[i].status=VOICE_FREE;
40 }
41
42 /* Process the Reset All Controllers event */
43 static void reset_controllers(MidiSong *song, int c)
44 {
45 song->channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */
46 song->channel[c].expression=127; /* SCC-1 does this. */
47 song->channel[c].sustain=0;
48 song->channel[c].pitchbend=0x2000;
49 song->channel[c].pitchfactor=0; /* to be computed */
50 }
51
52 static void reset_midi(MidiSong *song)
53 {
54 int i;
55 for (i=0; i<MAXCHAN; i++)
56 {
57 reset_controllers(song, i);
58 /* The rest of these are unaffected by the Reset All Controllers event */
59 song->channel[i].program=song->default_program;
60 song->channel[i].panning=NO_PANNING;
61 song->channel[i].pitchsens=2;
62 song->channel[i].bank=0; /* tone bank or drum set */
63 }
64 reset_voices(song);
65 }
66
67 static void select_sample(MidiSong *song, int v, Instrument *ip, int vel)
68 {
69 Sint32 f, cdiff, diff;
70 int s,i;
71 Sample *sp, *closest;
72
73 s=ip->samples;
74 sp=ip->sample;
75
76 if (s==1)
77 {
78 song->voice[v].sample=sp;
79 return;
80 }
81
82 f=song->voice[v].orig_frequency;
83 for (i=0; i<s; i++)
84 {
85 if (sp->low_freq <= f && sp->high_freq >= f)
86 {
87 song->voice[v].sample=sp;
88 return;
89 }
90 sp++;
91 }
92
93 /*
94 No suitable sample found! We'll select the sample whose root
95 frequency is closest to the one we want. (Actually we should
96 probably convert the low, high, and root frequencies to MIDI note
97 values and compare those.) */
98
99 cdiff=0x7FFFFFFF;
100 closest=sp=ip->sample;
101 for(i=0; i<s; i++)
102 {
103 diff=sp->root_freq - f;
104 if (diff<0) diff=-diff;
105 if (diff<cdiff)
106 {
107 cdiff=diff;
108 closest=sp;
109 }
110 sp++;
111 }
112 song->voice[v].sample=closest;
113 return;
114 }
115
116 static void recompute_freq(MidiSong *song, int v)
117 {
118 int
119 sign=(song->voice[v].sample_increment < 0), /* for bidirectional loops */
120 pb=song->channel[song->voice[v].channel].pitchbend;
121 double a;
122
123 if (!song->voice[v].sample->sample_rate)
124 return;
125
126 if (song->voice[v].vibrato_control_ratio)
127 {
128 /* This instrument has vibrato. Invalidate any precomputed
129 sample_increments. */
130
131 int i=VIBRATO_SAMPLE_INCREMENTS;
132 while (i--)
133 song->voice[v].vibrato_sample_increment[i]=0;
134 }
135
136 if (pb==0x2000 || pb<0 || pb>0x3FFF)
137 song->voice[v].frequency = song->voice[v].orig_frequency;
138 else
139 {
140 pb-=0x2000;
141 if (!(song->channel[song->voice[v].channel].pitchfactor))
142 {
143 /* Damn. Somebody bent the pitch. */
144 Sint32 i=pb*song->channel[song->voice[v].channel].pitchsens;
145 if (pb<0)
146 i=-i;
147 song->channel[song->voice[v].channel].pitchfactor=
148 (float)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]);
149 }
150 if (pb>0)
151 song->voice[v].frequency=
152 (Sint32)(song->channel[song->voice[v].channel].pitchfactor *
153 (double)(song->voice[v].orig_frequency));
154 else
155 song->voice[v].frequency=
156 (Sint32)((double)(song->voice[v].orig_frequency) /
157 song->channel[song->voice[v].channel].pitchfactor);
158 }
159
160 a = FSCALE(((double)(song->voice[v].sample->sample_rate) *
161 (double)(song->voice[v].frequency)) /
162 ((double)(song->voice[v].sample->root_freq) *
163 (double)(song->rate)),
164 FRACTION_BITS);
165
166 if (sign)
167 a = -a; /* need to preserve the loop direction */
168
169 song->voice[v].sample_increment = (Sint32)(a);
170 }
171
172 static void recompute_amp(MidiSong *song, int v)
173 {
174 Sint32 tempamp;
175
176 /* TODO: use fscale */
177
178 tempamp= (song->voice[v].velocity *
179 song->channel[song->voice[v].channel].volume *
180 song->channel[song->voice[v].channel].expression); /* 21 bits */
181
182 if (!(song->encoding & PE_MONO))
183 {
184 if (song->voice[v].panning > 60 && song->voice[v].panning < 68)
185 {
186 song->voice[v].panned=PANNED_CENTER;
187
188 song->voice[v].left_amp=
189 FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
190 21);
191 }
192 else if (song->voice[v].panning<5)
193 {
194 song->voice[v].panned = PANNED_LEFT;
195
196 song->voice[v].left_amp=
197 FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
198 20);
199 }
200 else if (song->voice[v].panning>123)
201 {
202 song->voice[v].panned = PANNED_RIGHT;
203
204 song->voice[v].left_amp= /* left_amp will be used */
205 FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
206 20);
207 }
208 else
209 {
210 song->voice[v].panned = PANNED_MYSTERY;
211
212 song->voice[v].left_amp=
213 FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
214 27);
215 song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning);
216 song->voice[v].left_amp *= (float)(127 - song->voice[v].panning);
217 }
218 }
219 else
220 {
221 song->voice[v].panned = PANNED_CENTER;
222
223 song->voice[v].left_amp=
224 FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
225 21);
226 }
227 }
228
229 static void start_note(MidiSong *song, MidiEvent *e, int i)
230 {
231 Instrument *ip;
232 int j;
233
234 if (ISDRUMCHANNEL(song, e->channel))
235 {
236 if (!(ip=song->drumset[song->channel[e->channel].bank]->instrument[e->a]))
237 {
238 if (!(ip=song->drumset[0]->instrument[e->a]))
239 return; /* No instrument? Then we can't play. */
240 }
241 if (ip->samples != 1)
242 {
243 SNDDBG(("Strange: percussion instrument with %d samples!",
244 ip->samples));
245 }
246
247 if (ip->sample->note_to_use) /* Do we have a fixed pitch? */
248 song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)];
249 else
250 song->voice[i].orig_frequency = freq_table[e->a & 0x7F];
251
252 /* drums are supposed to have only one sample */
253 song->voice[i].sample = ip->sample;
254 }
255 else
256 {
257 if (song->channel[e->channel].program == SPECIAL_PROGRAM)
258 ip=song->default_instrument;
259 else if (!(ip=song->tonebank[song->channel[e->channel].bank]->
260 instrument[song->channel[e->channel].program]))
261 {
262 if (!(ip=song->tonebank[0]->instrument[song->channel[e->channel].program]))
263 return; /* No instrument? Then we can't play. */
264 }
265
266 if (ip->sample->note_to_use) /* Fixed-pitch instrument? */
267 song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)];
268 else
269 song->voice[i].orig_frequency = freq_table[e->a & 0x7F];
270 select_sample(song, i, ip, e->b);
271 }
272
273 song->voice[i].status = VOICE_ON;
274 song->voice[i].channel = e->channel;
275 song->voice[i].note = e->a;
276 song->voice[i].velocity = e->b;
277 song->voice[i].sample_offset = 0;
278 song->voice[i].sample_increment = 0; /* make sure it isn't negative */
279
280 song->voice[i].tremolo_phase = 0;
281 song->voice[i].tremolo_phase_increment = song->voice[i].sample->tremolo_phase_increment;
282 song->voice[i].tremolo_sweep = song->voice[i].sample->tremolo_sweep_increment;
283 song->voice[i].tremolo_sweep_position = 0;
284
285 song->voice[i].vibrato_sweep = song->voice[i].sample->vibrato_sweep_increment;
286 song->voice[i].vibrato_sweep_position = 0;
287 song->voice[i].vibrato_control_ratio = song->voice[i].sample->vibrato_control_ratio;
288 song->voice[i].vibrato_control_counter = song->voice[i].vibrato_phase = 0;
289 for (j=0; j<VIBRATO_SAMPLE_INCREMENTS; j++)
290 song->voice[i].vibrato_sample_increment[j] = 0;
291
292 if (song->channel[e->channel].panning != NO_PANNING)
293 song->voice[i].panning = song->channel[e->channel].panning;
294 else
295 song->voice[i].panning = song->voice[i].sample->panning;
296
297 recompute_freq(song, i);
298 recompute_amp(song, i);
299 if (song->voice[i].sample->modes & MODES_ENVELOPE)
300 {
301 /* Ramp up from 0 */
302 song->voice[i].envelope_stage = 0;
303 song->voice[i].envelope_volume = 0;
304 song->voice[i].control_counter = 0;
305 recompute_envelope(song, i);
306 apply_envelope_to_amp(song, i);
307 }
308 else
309 {
310 song->voice[i].envelope_increment = 0;
311 apply_envelope_to_amp(song, i);
312 }
313 }
314
315 static void kill_note(MidiSong *song, int i)
316 {
317 song->voice[i].status = VOICE_DIE;
318 }
319
320 /* Only one instance of a note can be playing on a single channel. */
321 static void note_on(MidiSong *song)
322 {
323 int i = song->voices, lowest=-1;
324 Sint32 lv=0x7FFFFFFF, v;
325 MidiEvent *e = song->current_event;
326
327 while (i--)
328 {
329 if (song->voice[i].status == VOICE_FREE)
330 lowest=i; /* Can't get a lower volume than silence */
331 else if (song->voice[i].channel==e->channel &&
332 (song->voice[i].note==e->a || song->channel[song->voice[i].channel].mono))
333 kill_note(song, i);
334 }
335
336 if (lowest != -1)
337 {
338 /* Found a free voice. */
339 start_note(song,e,lowest);
340 return;
341 }
342
343 /* Look for the decaying note with the lowest volume */
344 i = song->voices;
345 while (i--)
346 {
347 if ((song->voice[i].status != VOICE_ON) &&
348 (song->voice[i].status != VOICE_DIE))
349 {
350 v = song->voice[i].left_mix;
351 if ((song->voice[i].panned == PANNED_MYSTERY)
352 && (song->voice[i].right_mix > v))
353 v = song->voice[i].right_mix;
354 if (v<lv)
355 {
356 lv=v;
357 lowest=i;
358 }
359 }
360 }
361
362 if (lowest != -1)
363 {
364 /* This can still cause a click, but if we had a free voice to
365 spare for ramping down this note, we wouldn't need to kill it
366 in the first place... Still, this needs to be fixed. Perhaps
367 we could use a reserve of voices to play dying notes only. */
368
369 song->cut_notes++;
370 song->voice[lowest].status=VOICE_FREE;
371 start_note(song,e,lowest);
372 }
373 else
374 song->lost_notes++;
375 }
376
377 static void finish_note(MidiSong *song, int i)
378 {
379 if (song->voice[i].sample->modes & MODES_ENVELOPE)
380 {
381 /* We need to get the envelope out of Sustain stage */
382 song->voice[i].envelope_stage = 3;
383 song->voice[i].status = VOICE_OFF;
384 recompute_envelope(song, i);
385 apply_envelope_to_amp(song, i);
386 }
387 else
388 {
389 /* Set status to OFF so resample_voice() will let this voice out
390 of its loop, if any. In any case, this voice dies when it
391 hits the end of its data (ofs>=data_length). */
392 song->voice[i].status = VOICE_OFF;
393 }
394 }
395
396 static void note_off(MidiSong *song)
397 {
398 int i = song->voices;
399 MidiEvent *e = song->current_event;
400
401 while (i--)
402 if (song->voice[i].status == VOICE_ON &&
403 song->voice[i].channel == e->channel &&
404 song->voice[i].note == e->a)
405 {
406 if (song->channel[e->channel].sustain)
407 {
408 song->voice[i].status = VOICE_SUSTAINED;
409 }
410 else
411 finish_note(song, i);
412 return;
413 }
414 }
415
416 /* Process the All Notes Off event */
417 static void all_notes_off(MidiSong *song)
418 {
419 int i = song->voices;
420 int c = song->current_event->channel;
421
422 SNDDBG(("All notes off on channel %d", c));
423 while (i--)
424 if (song->voice[i].status == VOICE_ON &&
425 song->voice[i].channel == c)
426 {
427 if (song->channel[c].sustain)
428 song->voice[i].status = VOICE_SUSTAINED;
429 else
430 finish_note(song, i);
431 }
432 }
433
434 /* Process the All Sounds Off event */
435 static void all_sounds_off(MidiSong *song)
436 {
437 int i = song->voices;
438 int c = song->current_event->channel;
439
440 while (i--)
441 if (song->voice[i].channel == c &&
442 song->voice[i].status != VOICE_FREE &&
443 song->voice[i].status != VOICE_DIE)
444 {
445 kill_note(song, i);
446 }
447 }
448
449 static void adjust_pressure(MidiSong *song)
450 {
451 MidiEvent *e = song->current_event;
452 int i = song->voices;
453
454 while (i--)
455 if (song->voice[i].status == VOICE_ON &&
456 song->voice[i].channel == e->channel &&
457 song->voice[i].note == e->a)
458 {
459 song->voice[i].velocity = e->b;
460 recompute_amp(song, i);
461 apply_envelope_to_amp(song, i);
462 return;
463 }
464 }
465
466 static void drop_sustain(MidiSong *song)
467 {
468 int i = song->voices;
469 int c = song->current_event->channel;
470
471 while (i--)
472 if (song->voice[i].status == VOICE_SUSTAINED && song->voice[i].channel == c)
473 finish_note(song, i);
474 }
475
476 static void adjust_pitchbend(MidiSong *song)
477 {
478 int c = song->current_event->channel;
479 int i = song->voices;
480
481 while (i--)
482 if (song->voice[i].status != VOICE_FREE && song->voice[i].channel == c)
483 {
484 recompute_freq(song, i);
485 }
486 }
487
488 static void adjust_volume(MidiSong *song)
489 {
490 int c = song->current_event->channel;
491 int i = song->voices;
492
493 while (i--)
494 if (song->voice[i].channel == c &&
495 (song->voice[i].status==VOICE_ON || song->voice[i].status==VOICE_SUSTAINED))
496 {
497 recompute_amp(song, i);
498 apply_envelope_to_amp(song, i);
499 }
500 }
501
502 static void seek_forward(MidiSong *song, Sint32 until_time)
503 {
504 reset_voices(song);
505 while (song->current_event->time < until_time)
506 {
507 switch(song->current_event->type)
508 {
509 /* All notes stay off. Just handle the parameter changes. */
510
511 case ME_PITCH_SENS:
512 song->channel[song->current_event->channel].pitchsens =
513 song->current_event->a;
514 song->channel[song->current_event->channel].pitchfactor = 0;
515 break;
516
517 case ME_PITCHWHEEL:
518 song->channel[song->current_event->channel].pitchbend =
519 song->current_event->a + song->current_event->b * 128;
520 song->channel[song->current_event->channel].pitchfactor = 0;
521 break;
522
523 case ME_MAINVOLUME:
524 song->channel[song->current_event->channel].volume =
525 song->current_event->a;
526 break;
527
528 case ME_PAN:
529 song->channel[song->current_event->channel].panning =
530 song->current_event->a;
531 break;
532
533 case ME_EXPRESSION:
534 song->channel[song->current_event->channel].expression =
535 song->current_event->a;
536 break;
537
538 case ME_PROGRAM:
539 if (ISDRUMCHANNEL(song, song->current_event->channel))
540 /* Change drum set */
541 song->channel[song->current_event->channel].bank =
542 song->current_event->a;
543 else
544 song->channel[song->current_event->channel].program =
545 song->current_event->a;
546 break;
547
548 case ME_SUSTAIN:
549 song->channel[song->current_event->channel].sustain =
550 song->current_event->a;
551 break;
552
553 case ME_RESET_CONTROLLERS:
554 reset_controllers(song, song->current_event->channel);
555 break;
556
557 case ME_TONE_BANK:
558 song->channel[song->current_event->channel].bank =
559 song->current_event->a;
560 break;
561
562 case ME_EOT:
563 song->current_sample = song->current_event->time;
564 return;
565 }
566 song->current_event++;
567 }
568 /*song->current_sample=song->current_event->time;*/
569 if (song->current_event != song->events)
570 song->current_event--;
571 song->current_sample=until_time;
572 }
573
574 static void skip_to(MidiSong *song, Sint32 until_time)
575 {
576 if (song->current_sample > until_time)
577 song->current_sample = 0;
578
579 reset_midi(song);
580 song->buffered_count = 0;
581 song->buffer_pointer = song->common_buffer;
582 song->current_event = song->events;
583
584 if (until_time)
585 seek_forward(song, until_time);
586 }
587
588 static void do_compute_data(MidiSong *song, Sint32 count)
589 {
590 int i;
591 memset(song->buffer_pointer, 0,
592 (song->encoding & PE_MONO) ? (count * 4) : (count * 8));
593 for (i = 0; i < song->voices; i++)
594 {
595 if(song->voice[i].status != VOICE_FREE)
596 mix_voice(song, song->buffer_pointer, i, count);
597 }
598 song->current_sample += count;
599 }
600
601 /* count=0 means flush remaining buffered data to output device, then
602 flush the device itself */
603 static void compute_data(MidiSong *song, void *stream, Sint32 count)
604 {
605 int channels;
606
607 if ( song->encoding & PE_MONO )
608 channels = 1;
609 else
610 channels = 2;
611
612 if (!count)
613 {
614 if (song->buffered_count)
615 song->write(stream, song->common_buffer, channels * song->buffered_count);
616 song->buffer_pointer = song->common_buffer;
617 song->buffered_count = 0;
618 return;
619 }
620
621 while ((count + song->buffered_count) >= song->buffer_size)
622 {
623 do_compute_data(song, song->buffer_size - song->buffered_count);
624 count -= song->buffer_size - song->buffered_count;
625 song->write(stream, song->common_buffer, channels * song->buffer_size);
626 song->buffer_pointer = song->common_buffer;
627 song->buffered_count = 0;
628 }
629 if (count>0)
630 {
631 do_compute_data(song, count);
632 song->buffered_count += count;
633 song->buffer_pointer += (song->encoding & PE_MONO) ? count : count*2;
634 }
635 }
636
637 void Timidity_Start(MidiSong *song)
638 {
639 song->playing = 1;
640 adjust_amplification(song);
641 skip_to(song, 0);
642 }
643
644 void Timidity_Seek(MidiSong *song, Uint32 ms)
645 {
646 skip_to(song, (ms * song->rate) / 1000);
647 }
648
649 Uint32 Timidity_GetSongLength(MidiSong *song)
650 {
651 MidiEvent *last_event = &song->events[song->groomed_event_count - 1];
652 /* We want last_event->time * 1000 / song->rate */
653 Uint32 retvalue = (last_event->time / song->rate) * 1000;
654 retvalue += (last_event->time % song->rate) * 1000 / song->rate;
655 return retvalue;
656 }
657
658 int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len)
659 {
660 Sint32 start_sample, end_sample, samples;
661 int bytes_per_sample;
662
663 if (!song->playing)
664 return 0;
665
666 bytes_per_sample = 1;
667 bytes_per_sample *= ((song->encoding & PE_32BIT) ? 4 : ((song->encoding & PE_16BIT) ? 2 : 1));
668 bytes_per_sample *= ((song->encoding & PE_MONO) ? 1 : 2);
669 samples = len / bytes_per_sample;
670
671 start_sample = song->current_sample;
672 end_sample = song->current_sample+samples;
673 while ( song->current_sample < end_sample ) {
674 /* Handle all events that should happen at this time */
675 while (song->current_event->time <= song->current_sample) {
676 switch(song->current_event->type) {
677
678 /* Effects affecting a single note */
679
680 case ME_NOTEON:
681 if (!(song->current_event->b)) /* Velocity 0? */
682 note_off(song);
683 else
684 note_on(song);
685 break;
686
687 case ME_NOTEOFF:
688 note_off(song);
689 break;
690
691 case ME_KEYPRESSURE:
692 adjust_pressure(song);
693 break;
694
695 /* Effects affecting a single channel */
696
697 case ME_PITCH_SENS:
698 song->channel[song->current_event->channel].pitchsens =
699 song->current_event->a;
700 song->channel[song->current_event->channel].pitchfactor = 0;
701 break;
702
703 case ME_PITCHWHEEL:
704 song->channel[song->current_event->channel].pitchbend =
705 song->current_event->a + song->current_event->b * 128;
706 song->channel[song->current_event->channel].pitchfactor = 0;
707 /* Adjust pitch for notes already playing */
708 adjust_pitchbend(song);
709 break;
710
711 case ME_MAINVOLUME:
712 song->channel[song->current_event->channel].volume =
713 song->current_event->a;
714 adjust_volume(song);
715 break;
716
717 case ME_PAN:
718 song->channel[song->current_event->channel].panning =
719 song->current_event->a;
720 break;
721
722 case ME_EXPRESSION:
723 song->channel[song->current_event->channel].expression =
724 song->current_event->a;
725 adjust_volume(song);
726 break;
727
728 case ME_PROGRAM:
729 if (ISDRUMCHANNEL(song, song->current_event->channel)) {
730 /* Change drum set */
731 song->channel[song->current_event->channel].bank =
732 song->current_event->a;
733 }
734 else
735 song->channel[song->current_event->channel].program =
736 song->current_event->a;
737 break;
738
739 case ME_SUSTAIN:
740 song->channel[song->current_event->channel].sustain =
741 song->current_event->a;
742 if (!song->current_event->a)
743 drop_sustain(song);
744 break;
745
746 case ME_RESET_CONTROLLERS:
747 reset_controllers(song, song->current_event->channel);
748 break;
749
750 case ME_ALL_NOTES_OFF:
751 all_notes_off(song);
752 break;
753
754 case ME_ALL_SOUNDS_OFF:
755 all_sounds_off(song);
756 break;
757
758 case ME_TONE_BANK:
759 song->channel[song->current_event->channel].bank =
760 song->current_event->a;
761 break;
762
763 case ME_EOT:
764 /* Give the last notes a couple of seconds to decay */
765 SNDDBG(("Playing time: ~%d seconds\n",
766 song->current_sample/song->rate+2));
767 SNDDBG(("Notes cut: %d\n", song->cut_notes));
768 SNDDBG(("Notes lost totally: %d\n", song->lost_notes));
769 song->playing = 0;
770 return (song->current_sample - start_sample) * bytes_per_sample;
771 }
772 song->current_event++;
773 }
774 if (song->current_event->time > end_sample)
775 compute_data(song, stream, end_sample-song->current_sample);
776 else
777 compute_data(song, stream, song->current_event->time-song->current_sample);
778 }
779 return samples * bytes_per_sample;
780 }
781
782 void Timidity_SetVolume(MidiSong *song, int volume)
783 {
784 int i;
785 if (volume > MAX_AMPLIFICATION)
786 song->amplification = MAX_AMPLIFICATION;
787 else
788 if (volume < 0)
789 song->amplification = 0;
790 else
791 song->amplification = volume;
792 adjust_amplification(song);
793 for (i = 0; i < song->voices; i++)
794 if (song->voice[i].status != VOICE_FREE)
795 {
796 recompute_amp(song, i);
797 apply_envelope_to_amp(song, i);
798 }
799 }
+0
-53
timidity/playmidi.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 playmidi.h
9
10 */
11
12 /* Midi events */
13 #define ME_NONE 0
14 #define ME_NOTEON 1
15 #define ME_NOTEOFF 2
16 #define ME_KEYPRESSURE 3
17 #define ME_MAINVOLUME 4
18 #define ME_PAN 5
19 #define ME_SUSTAIN 6
20 #define ME_EXPRESSION 7
21 #define ME_PITCHWHEEL 8
22 #define ME_PROGRAM 9
23 #define ME_TEMPO 10
24 #define ME_PITCH_SENS 11
25
26 #define ME_ALL_SOUNDS_OFF 12
27 #define ME_RESET_CONTROLLERS 13
28 #define ME_ALL_NOTES_OFF 14
29 #define ME_TONE_BANK 15
30
31 #define ME_LYRIC 16
32
33 #define ME_EOT 99
34
35 /* Causes the instrument's default panning to be used. */
36 #define NO_PANNING -1
37
38 /* Voice status options: */
39 #define VOICE_FREE 0
40 #define VOICE_ON 1
41 #define VOICE_SUSTAINED 2
42 #define VOICE_OFF 3
43 #define VOICE_DIE 4
44
45 /* Voice panned options: */
46 #define PANNED_MYSTERY 0
47 #define PANNED_LEFT 1
48 #define PANNED_RIGHT 2
49 #define PANNED_CENTER 3
50 /* Anything but PANNED_MYSTERY only uses the left volume */
51
52 #define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c))))
+0
-614
timidity/readmidi.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7 */
8
9 #if HAVE_CONFIG_H
10 # include <config.h>
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include "SDL.h"
18
19 #include "options.h"
20 #include "timidity.h"
21 #include "common.h"
22 #include "instrum.h"
23 #include "playmidi.h"
24
25 /* Computes how many (fractional) samples one MIDI delta-time unit contains */
26 static void compute_sample_increment(MidiSong *song, Sint32 tempo,
27 Sint32 divisions)
28 {
29 double a;
30 a = (double) (tempo) * (double) (song->rate) * (65536.0/1000000.0) /
31 (double)(divisions);
32
33 song->sample_correction = (Sint32)(a) & 0xFFFF;
34 song->sample_increment = (Sint32)(a) >> 16;
35
36 SNDDBG(("Samples per delta-t: %d (correction %d)",
37 song->sample_increment, song->sample_correction));
38 }
39
40 /* Read variable-length number (7 bits per byte, MSB first) */
41 static Sint32 getvl(SDL_RWops *rw)
42 {
43 Sint32 l=0;
44 Uint8 c;
45 for (;;)
46 {
47 if (!SDL_RWread(rw, &c, 1, 1)) return l;
48 l += (c & 0x7f);
49 if (!(c & 0x80)) return l;
50 l<<=7;
51 }
52 }
53
54 /* Print a string from the file, followed by a newline. Any non-ASCII
55 or unprintable characters will be converted to periods. */
56 static int dumpstring(SDL_RWops *rw, Sint32 len, char *label)
57 {
58 signed char *s=safe_malloc(len+1);
59 if (len != (Sint32) SDL_RWread(rw, s, 1, len))
60 {
61 free(s);
62 return -1;
63 }
64 s[len]='\0';
65 while (len--)
66 {
67 if (s[len]<32)
68 s[len]='.';
69 }
70 SNDDBG(("%s%s", label, s));
71 free(s);
72 return 0;
73 }
74
75 #define MIDIEVENT(at,t,ch,pa,pb) \
76 new=safe_malloc(sizeof(MidiEventList)); \
77 new->event.time=at; new->event.type=t; new->event.channel=ch; \
78 new->event.a=pa; new->event.b=pb; new->next=0;\
79 return new;
80
81 #define MAGIC_EOT ((MidiEventList *)(-1))
82
83 /* Read a MIDI event, returning a freshly allocated element that can
84 be linked to the event list */
85 static MidiEventList *read_midi_event(MidiSong *song)
86 {
87 static Uint8 laststatus, lastchan;
88 static Uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */
89 Uint8 me, type, a,b,c;
90 Sint32 len;
91 MidiEventList *new;
92
93 for (;;)
94 {
95 song->at += getvl(song->rw);
96 if (SDL_RWread(song->rw, &me, 1, 1) != 1)
97 {
98 SNDDBG(("read_midi_event: SDL_RWread() failure\n"));
99 return NULL;
100 }
101
102 if(me==0xF0 || me == 0xF7) /* SysEx event */
103 {
104 len=getvl(song->rw);
105 SDL_RWseek(song->rw, len, RW_SEEK_CUR);
106 }
107 else if(me==0xFF) /* Meta event */
108 {
109 SDL_RWread(song->rw, &type, 1, 1);
110 len=getvl(song->rw);
111 if (type>0 && type<16)
112 {
113 static char *label[]={
114 "Text event: ", "Text: ", "Copyright: ", "Track name: ",
115 "Instrument: ", "Lyric: ", "Marker: ", "Cue point: "};
116 dumpstring(song->rw, len, label[(type>7) ? 0 : type]);
117 }
118 else
119 switch(type)
120 {
121 case 0x2F: /* End of Track */
122 return MAGIC_EOT;
123
124 case 0x51: /* Tempo */
125 SDL_RWread(song->rw, &a, 1, 1);
126 SDL_RWread(song->rw, &b, 1, 1);
127 SDL_RWread(song->rw, &c, 1, 1);
128 MIDIEVENT(song->at, ME_TEMPO, c, a, b);
129
130 default:
131 SNDDBG(("(Meta event type 0x%02x, length %d)\n", type, len));
132 SDL_RWseek(song->rw, len, RW_SEEK_CUR);
133 break;
134 }
135 }
136 else
137 {
138 a=me;
139 if (a & 0x80) /* status byte */
140 {
141 lastchan=a & 0x0F;
142 laststatus=(a>>4) & 0x07;
143 SDL_RWread(song->rw, &a, 1, 1);
144 a &= 0x7F;
145 }
146 switch(laststatus)
147 {
148 case 0: /* Note off */
149 SDL_RWread(song->rw, &b, 1, 1);
150 b &= 0x7F;
151 MIDIEVENT(song->at, ME_NOTEOFF, lastchan, a,b);
152
153 case 1: /* Note on */
154 SDL_RWread(song->rw, &b, 1, 1);
155 b &= 0x7F;
156 MIDIEVENT(song->at, ME_NOTEON, lastchan, a,b);
157
158 case 2: /* Key Pressure */
159 SDL_RWread(song->rw, &b, 1, 1);
160 b &= 0x7F;
161 MIDIEVENT(song->at, ME_KEYPRESSURE, lastchan, a, b);
162
163 case 3: /* Control change */
164 SDL_RWread(song->rw, &b, 1, 1);
165 b &= 0x7F;
166 {
167 int control=255;
168 switch(a)
169 {
170 case 7: control=ME_MAINVOLUME; break;
171 case 10: control=ME_PAN; break;
172 case 11: control=ME_EXPRESSION; break;
173 case 64: control=ME_SUSTAIN; b = (b >= 64); break;
174 case 120: control=ME_ALL_SOUNDS_OFF; break;
175 case 121: control=ME_RESET_CONTROLLERS; break;
176 case 123: control=ME_ALL_NOTES_OFF; break;
177
178 /* These should be the SCC-1 tone bank switch
179 commands. I don't know why there are two, or
180 why the latter only allows switching to bank 0.
181 Also, some MIDI files use 0 as some sort of
182 continuous controller. This will cause lots of
183 warnings about undefined tone banks. */
184 case 0: control=ME_TONE_BANK; break;
185 case 32:
186 if (b!=0) {
187 SNDDBG(("(Strange: tone bank change 0x%02x)\n", b));
188 }
189 #if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */
190 else
191 control=ME_TONE_BANK;
192 #endif
193 break;
194
195 case 100: nrpn=0; rpn_msb[lastchan]=b; break;
196 case 101: nrpn=0; rpn_lsb[lastchan]=b; break;
197 case 99: nrpn=1; rpn_msb[lastchan]=b; break;
198 case 98: nrpn=1; rpn_lsb[lastchan]=b; break;
199
200 case 6:
201 if (nrpn)
202 {
203 SNDDBG(("(Data entry (MSB) for NRPN %02x,%02x: %d)\n",
204 rpn_msb[lastchan], rpn_lsb[lastchan], b));
205 break;
206 }
207
208 switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan])
209 {
210 case 0x0000: /* Pitch bend sensitivity */
211 control=ME_PITCH_SENS;
212 break;
213
214 case 0x7F7F: /* RPN reset */
215 /* reset pitch bend sensitivity to 2 */
216 MIDIEVENT(song->at, ME_PITCH_SENS, lastchan, 2, 0);
217
218 default:
219 SNDDBG(("(Data entry (MSB) for RPN %02x,%02x: %d)\n",
220 rpn_msb[lastchan], rpn_lsb[lastchan], b));
221 break;
222 }
223 break;
224
225 default:
226 SNDDBG(("(Control %d: %d)\n", a, b));
227 break;
228 }
229 if (control != 255)
230 {
231 MIDIEVENT(song->at, control, lastchan, b, 0);
232 }
233 }
234 break;
235
236 case 4: /* Program change */
237 a &= 0x7f;
238 MIDIEVENT(song->at, ME_PROGRAM, lastchan, a, 0);
239
240 case 5: /* Channel pressure - NOT IMPLEMENTED */
241 break;
242
243 case 6: /* Pitch wheel */
244 SDL_RWread(song->rw, &b, 1, 1);
245 b &= 0x7F;
246 MIDIEVENT(song->at, ME_PITCHWHEEL, lastchan, a, b);
247
248 default:
249 SNDDBG(("*** Can't happen: status 0x%02X, channel 0x%02X\n",
250 laststatus, lastchan));
251 break;
252 }
253 }
254 }
255
256 return new;
257 }
258
259 #undef MIDIEVENT
260
261 /* Read a midi track into the linked list, either merging with any previous
262 tracks or appending to them. */
263 static int read_track(MidiSong *song, int append)
264 {
265 MidiEventList *meep;
266 MidiEventList *next, *new;
267 Sint32 len;
268 Sint64 next_pos, pos;
269 char tmp[4];
270
271 meep = song->evlist;
272 if (append && meep)
273 {
274 /* find the last event in the list */
275 for (; meep->next; meep=meep->next)
276 ;
277 song->at = meep->event.time;
278 }
279 else
280 song->at=0;
281
282 /* Check the formalities */
283
284 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
285 {
286 SNDDBG(("Can't read track header.\n"));
287 return -1;
288 }
289 len=SDL_SwapBE32(len);
290 next_pos = SDL_RWtell(song->rw) + len;
291 if (memcmp(tmp, "MTrk", 4))
292 {
293 SNDDBG(("Corrupt MIDI file.\n"));
294 return -2;
295 }
296
297 for (;;)
298 {
299 if (!(new=read_midi_event(song))) /* Some kind of error */
300 return -2;
301
302 if (new==MAGIC_EOT) /* End-of-track Hack. */
303 {
304 pos = SDL_RWtell(song->rw);
305 if (pos < next_pos)
306 SDL_RWseek(song->rw, next_pos - pos, RW_SEEK_CUR);
307 return 0;
308 }
309
310 next=meep->next;
311 while (next && (next->event.time < new->event.time))
312 {
313 meep=next;
314 next=meep->next;
315 }
316
317 new->next=next;
318 meep->next=new;
319
320 song->event_count++; /* Count the event. (About one?) */
321 meep=new;
322 }
323 }
324
325 /* Free the linked event list from memory. */
326 static void free_midi_list(MidiSong *song)
327 {
328 MidiEventList *meep, *next;
329 if (!(meep = song->evlist)) return;
330 while (meep)
331 {
332 next=meep->next;
333 free(meep);
334 meep=next;
335 }
336 song->evlist=NULL;
337 }
338
339 /* Allocate an array of MidiEvents and fill it from the linked list of
340 events, marking used instruments for loading. Convert event times to
341 samples: handle tempo changes. Strip unnecessary events from the list.
342 Free the linked list. */
343 static MidiEvent *groom_list(MidiSong *song, Sint32 divisions,Sint32 *eventsp,
344 Sint32 *samplesp)
345 {
346 MidiEvent *groomed_list, *lp;
347 MidiEventList *meep;
348 Sint32 i, our_event_count, tempo, skip_this_event, new_value;
349 Sint32 sample_cum, samples_to_do, at, st, dt, counting_time;
350
351 int current_bank[MAXCHAN], current_set[MAXCHAN], current_program[MAXCHAN];
352 /* Or should each bank have its own current program? */
353
354 for (i=0; i<MAXCHAN; i++)
355 {
356 current_bank[i]=0;
357 current_set[i]=0;
358 current_program[i]=song->default_program;
359 }
360
361 tempo=500000;
362 compute_sample_increment(song, tempo, divisions);
363
364 /* This may allocate a bit more than we need */
365 groomed_list=lp=safe_malloc(sizeof(MidiEvent) * (song->event_count+1));
366 meep=song->evlist;
367
368 our_event_count=0;
369 st=at=sample_cum=0;
370 counting_time=2; /* We strip any silence before the first NOTE ON. */
371
372 for (i = 0; i < song->event_count; i++)
373 {
374 skip_this_event=0;
375
376 if (meep->event.type==ME_TEMPO)
377 {
378 skip_this_event=1;
379 }
380 else if (meep->event.channel >= MAXCHAN)
381 skip_this_event=1;
382 else switch (meep->event.type)
383 {
384 case ME_PROGRAM:
385 if (ISDRUMCHANNEL(song, meep->event.channel))
386 {
387 if (song->drumset[meep->event.a]) /* Is this a defined drumset? */
388 new_value=meep->event.a;
389 else
390 {
391 SNDDBG(("Drum set %d is undefined\n", meep->event.a));
392 new_value=meep->event.a=0;
393 }
394 if (current_set[meep->event.channel] != new_value)
395 current_set[meep->event.channel]=new_value;
396 else
397 skip_this_event=1;
398 }
399 else
400 {
401 new_value=meep->event.a;
402 if ((current_program[meep->event.channel] != SPECIAL_PROGRAM)
403 && (current_program[meep->event.channel] != new_value))
404 current_program[meep->event.channel] = new_value;
405 else
406 skip_this_event=1;
407 }
408 break;
409
410 case ME_NOTEON:
411 if (counting_time)
412 counting_time=1;
413 if (ISDRUMCHANNEL(song, meep->event.channel))
414 {
415 /* Mark this instrument to be loaded */
416 if (!(song->drumset[current_set[meep->event.channel]]
417 ->instrument[meep->event.a]))
418 song->drumset[current_set[meep->event.channel]]
419 ->instrument[meep->event.a] = MAGIC_LOAD_INSTRUMENT;
420 }
421 else
422 {
423 if (current_program[meep->event.channel]==SPECIAL_PROGRAM)
424 break;
425 /* Mark this instrument to be loaded */
426 if (!(song->tonebank[current_bank[meep->event.channel]]
427 ->instrument[current_program[meep->event.channel]]))
428 song->tonebank[current_bank[meep->event.channel]]
429 ->instrument[current_program[meep->event.channel]] =
430 MAGIC_LOAD_INSTRUMENT;
431 }
432 break;
433
434 case ME_TONE_BANK:
435 if (ISDRUMCHANNEL(song, meep->event.channel))
436 {
437 skip_this_event=1;
438 break;
439 }
440 if (song->tonebank[meep->event.a]) /* Is this a defined tone bank? */
441 new_value=meep->event.a;
442 else
443 {
444 SNDDBG(("Tone bank %d is undefined\n", meep->event.a));
445 new_value=meep->event.a=0;
446 }
447 if (current_bank[meep->event.channel]!=new_value)
448 current_bank[meep->event.channel]=new_value;
449 else
450 skip_this_event=1;
451 break;
452 }
453
454 /* Recompute time in samples*/
455 if ((dt=meep->event.time - at) && !counting_time)
456 {
457 if (song->sample_increment > 2147483647/dt ||
458 song->sample_correction > 2147483647/dt) {
459 goto _overflow;
460 }
461 samples_to_do = song->sample_increment * dt;
462 sample_cum += song->sample_correction * dt;
463 if (sample_cum & 0xFFFF0000)
464 {
465 samples_to_do += ((sample_cum >> 16) & 0xFFFF);
466 sample_cum &= 0x0000FFFF;
467 }
468 if (st >= 2147483647 - samples_to_do) {
469 _overflow:
470 SNDDBG(("Overflow in sample counter\n"));
471 free_midi_list(song);
472 free(groomed_list);
473 return NULL;
474 }
475 st += samples_to_do;
476 }
477 else if (counting_time==1) counting_time=0;
478 if (meep->event.type==ME_TEMPO)
479 {
480 tempo=
481 meep->event.channel + meep->event.b * 256 + meep->event.a * 65536;
482 compute_sample_increment(song, tempo, divisions);
483 }
484 if (!skip_this_event)
485 {
486 /* Add the event to the list */
487 *lp=meep->event;
488 lp->time=st;
489 lp++;
490 our_event_count++;
491 }
492 at=meep->event.time;
493 meep=meep->next;
494 }
495 /* Add an End-of-Track event */
496 lp->time=st;
497 lp->type=ME_EOT;
498 our_event_count++;
499 free_midi_list(song);
500
501 *eventsp=our_event_count;
502 *samplesp=st;
503 return groomed_list;
504 }
505
506 MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp)
507 {
508 Sint32 len, divisions;
509 Sint16 format, tracks, divisions_tmp;
510 int i;
511 char tmp[4];
512
513 song->event_count=0;
514 song->at=0;
515 song->evlist = NULL;
516
517 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
518 {
519 SNDDBG(("Not a MIDI file!\n"));
520 return NULL;
521 }
522 if (memcmp(tmp, "RIFF", 4) == 0) { /* RMID ?? */
523 if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || memcmp(tmp, "RMID", 4) != 0 ||
524 SDL_RWread(song->rw, tmp, 1, 4) != 4 || memcmp(tmp, "data", 4) != 0 ||
525 SDL_RWread(song->rw, tmp, 1, 4) != 4 ||
526 /* SMF must begin from here onwards: */
527 SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1)
528 {
529 SNDDBG(("Not an RMID file!\n"));
530 return NULL;
531 }
532 }
533 len=SDL_SwapBE32(len);
534 if (memcmp(tmp, "MThd", 4) || len < 6)
535 {
536 SNDDBG(("Not a MIDI file!\n"));
537 return NULL;
538 }
539
540 SDL_RWread(song->rw, &format, 2, 1);
541 SDL_RWread(song->rw, &tracks, 2, 1);
542 SDL_RWread(song->rw, &divisions_tmp, 2, 1);
543 format=SDL_SwapBE16(format);
544 tracks=SDL_SwapBE16(tracks);
545 divisions_tmp=SDL_SwapBE16(divisions_tmp);
546
547 if (divisions_tmp<0)
548 {
549 /* SMPTE time -- totally untested. Got a MIDI file that uses this? */
550 divisions=
551 (Sint32)(-(divisions_tmp/256)) * (Sint32)(divisions_tmp & 0xFF);
552 }
553 else divisions=(Sint32)(divisions_tmp);
554
555 if (len > 6)
556 {
557 SNDDBG(("MIDI file header size %u bytes", len));
558 SDL_RWseek(song->rw, len-6, RW_SEEK_CUR); /* skip the excess */
559 }
560 if (format<0 || format >2)
561 {
562 SNDDBG(("Unknown MIDI file format %d\n", format));
563 return NULL;
564 }
565 if (tracks<1)
566 {
567 SNDDBG(("Bad number of tracks %d\n", tracks));
568 return NULL;
569 }
570 if (format==0 && tracks!=1)
571 {
572 SNDDBG(("%d tracks with Type-0 MIDI (must be 1.)\n", tracks));
573 return NULL;
574 }
575 SNDDBG(("Format: %d Tracks: %d Divisions: %d\n",
576 format, tracks, divisions));
577
578 /* Put a do-nothing event first in the list for easier processing */
579 song->evlist=safe_malloc(sizeof(MidiEventList));
580 memset(song->evlist, 0, sizeof(MidiEventList));
581 song->event_count++;
582
583 switch(format)
584 {
585 case 0:
586 if (read_track(song, 0))
587 {
588 free_midi_list(song);
589 return NULL;
590 }
591 break;
592
593 case 1:
594 for (i=0; i<tracks; i++)
595 if (read_track(song, 0))
596 {
597 free_midi_list(song);
598 return NULL;
599 }
600 break;
601
602 case 2: /* We simply play the tracks sequentially */
603 for (i=0; i<tracks; i++)
604 if (read_track(song, 1))
605 {
606 free_midi_list(song);
607 return NULL;
608 }
609 break;
610 }
611
612 return groom_list(song, divisions, count, sp);
613 }
+0
-13
timidity/readmidi.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 readmidi.h
9
10 */
11
12 extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp);
+0
-613
timidity/resample.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 resample.c
9 */
10
11 #if HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14
15 #include <math.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include "SDL.h"
20
21 #include "timidity.h"
22 #include "options.h"
23 #include "common.h"
24 #include "instrum.h"
25 #include "playmidi.h"
26 #include "tables.h"
27 #include "resample.h"
28
29 #define PRECALC_LOOP_COUNT(start, end, incr) (((end) - (start) + (incr) - 1) / (incr))
30
31 /*************** resampling with fixed increment *****************/
32
33 static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr)
34 {
35
36 /* Play sample until end, then free the voice. */
37
38 sample_t v1, v2;
39 Voice
40 *vp=&(song->voice[v]);
41 sample_t
42 *dest=song->resample_buffer,
43 *src=vp->sample->data;
44 Sint32
45 ofs=vp->sample_offset,
46 incr=vp->sample_increment,
47 le=vp->sample->data_length,
48 count=*countptr;
49 Sint32 i, j;
50
51 if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */
52
53 /* Precalc how many times we should go through the loop.
54 NOTE: Assumes that incr > 0 and that ofs <= le */
55 i = PRECALC_LOOP_COUNT(ofs, le, incr);
56
57 if (i > count)
58 {
59 i = count;
60 count = 0;
61 }
62 else count -= i;
63
64 for (j = 0; j < i; j++)
65 {
66 v1 = src[ofs >> FRACTION_BITS];
67 v2 = src[(ofs >> FRACTION_BITS)+1];
68 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
69 ofs += incr;
70 }
71
72 if (ofs >= le)
73 {
74 if (ofs == le)
75 *dest++ = src[(ofs>>FRACTION_BITS)-1]/2;
76 vp->status=VOICE_FREE;
77 *countptr-=count+1;
78 }
79
80 vp->sample_offset=ofs; /* Update offset */
81 return song->resample_buffer;
82 }
83
84 static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count)
85 {
86
87 /* Play sample until end-of-loop, skip back and continue. */
88
89 sample_t v1, v2;
90 Sint32
91 ofs=vp->sample_offset,
92 incr=vp->sample_increment,
93 le=vp->sample->loop_end,
94 ll=le - vp->sample->loop_start;
95 sample_t
96 *dest=song->resample_buffer,
97 *src=vp->sample->data;
98 Sint32 i, j;
99
100 while (count)
101 {
102 while (ofs >= le)
103 ofs -= ll;
104 /* Precalc how many times we should go through the loop */
105 i = PRECALC_LOOP_COUNT(ofs, le, incr);
106 if (i > count)
107 {
108 i = count;
109 count = 0;
110 }
111 else count -= i;
112 for (j = 0; j < i; j++)
113 {
114 v1 = src[ofs >> FRACTION_BITS];
115 v2 = src[(ofs >> FRACTION_BITS)+1];
116 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
117 ofs += incr;
118 }
119 }
120
121 vp->sample_offset=ofs; /* Update offset */
122 return song->resample_buffer;
123 }
124
125 static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count)
126 {
127 sample_t v1, v2;
128 Sint32
129 ofs=vp->sample_offset,
130 incr=vp->sample_increment,
131 le=vp->sample->loop_end,
132 ls=vp->sample->loop_start;
133 sample_t
134 *dest=song->resample_buffer,
135 *src=vp->sample->data;
136 Sint32
137 le2 = le<<1,
138 ls2 = ls<<1,
139 i, j;
140 /* Play normally until inside the loop region */
141
142 if (incr > 0 && ofs < ls)
143 {
144 /* NOTE: Assumes that incr > 0, which is NOT always the case
145 when doing bidirectional looping. I have yet to see a case
146 where both ofs <= ls AND incr < 0, however. */
147 i = PRECALC_LOOP_COUNT(ofs, ls, incr);
148 if (i > count)
149 {
150 i = count;
151 count = 0;
152 }
153 else count -= i;
154 for (j = 0; j < i; j++)
155 {
156 v1 = src[ofs >> FRACTION_BITS];
157 v2 = src[(ofs >> FRACTION_BITS)+1];
158 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
159 ofs += incr;
160 }
161 }
162
163 /* Then do the bidirectional looping */
164
165 while(count)
166 {
167 /* Precalc how many times we should go through the loop */
168 i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr);
169 if (i > count)
170 {
171 i = count;
172 count = 0;
173 }
174 else count -= i;
175 for (j = 0; j < i; j++)
176 {
177 v1 = src[ofs >> FRACTION_BITS];
178 v2 = src[(ofs >> FRACTION_BITS)+1];
179 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
180 ofs += incr;
181 }
182 if (ofs>=le)
183 {
184 /* fold the overshoot back in */
185 ofs = le2 - ofs;
186 incr *= -1;
187 }
188 else if (ofs <= ls)
189 {
190 ofs = ls2 - ofs;
191 incr *= -1;
192 }
193 }
194
195 vp->sample_increment=incr;
196 vp->sample_offset=ofs; /* Update offset */
197 return song->resample_buffer;
198 }
199
200 /*********************** vibrato versions ***************************/
201
202 /* We only need to compute one half of the vibrato sine cycle */
203 static int vib_phase_to_inc_ptr(int phase)
204 {
205 if (phase < VIBRATO_SAMPLE_INCREMENTS/2)
206 return VIBRATO_SAMPLE_INCREMENTS/2-1-phase;
207 else if (phase >= 3*VIBRATO_SAMPLE_INCREMENTS/2)
208 return 5*VIBRATO_SAMPLE_INCREMENTS/2-1-phase;
209 else
210 return phase-VIBRATO_SAMPLE_INCREMENTS/2;
211 }
212
213 static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign)
214 {
215 Sint32 depth;
216 int phase, pb;
217 double a;
218
219 if (vp->vibrato_phase++ >= 2*VIBRATO_SAMPLE_INCREMENTS-1)
220 vp->vibrato_phase=0;
221 phase=vib_phase_to_inc_ptr(vp->vibrato_phase);
222
223 if (vp->vibrato_sample_increment[phase])
224 {
225 if (sign)
226 return -vp->vibrato_sample_increment[phase];
227 else
228 return vp->vibrato_sample_increment[phase];
229 }
230
231 /* Need to compute this sample increment. */
232
233 depth=vp->sample->vibrato_depth<<7;
234
235 if (vp->vibrato_sweep)
236 {
237 /* Need to update sweep */
238 vp->vibrato_sweep_position += vp->vibrato_sweep;
239 if (vp->vibrato_sweep_position >= (1<<SWEEP_SHIFT))
240 vp->vibrato_sweep=0;
241 else
242 {
243 /* Adjust depth */
244 depth *= vp->vibrato_sweep_position;
245 depth >>= SWEEP_SHIFT;
246 }
247 }
248
249 a = FSCALE(((double)(vp->sample->sample_rate) *
250 (double)(vp->frequency)) /
251 ((double)(vp->sample->root_freq) *
252 (double)(song->rate)),
253 FRACTION_BITS);
254
255 pb=(int)((sine(vp->vibrato_phase *
256 (SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS)))
257 * (double)(depth) * VIBRATO_AMPLITUDE_TUNING));
258
259 if (pb<0)
260 {
261 pb=-pb;
262 a /= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13];
263 }
264 else
265 a *= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13];
266
267 /* If the sweep's over, we can store the newly computed sample_increment */
268 if (!vp->vibrato_sweep)
269 vp->vibrato_sample_increment[phase]=(Sint32) a;
270
271 if (sign)
272 a = -a; /* need to preserve the loop direction */
273
274 return (Sint32) a;
275 }
276
277 static sample_t *rs_vib_plain(MidiSong *song, int v, Sint32 *countptr)
278 {
279
280 /* Play sample until end, then free the voice. */
281
282 sample_t v1, v2;
283 Voice *vp=&(song->voice[v]);
284 sample_t
285 *dest=song->resample_buffer,
286 *src=vp->sample->data;
287 Sint32
288 le=vp->sample->data_length,
289 ofs=vp->sample_offset,
290 incr=vp->sample_increment,
291 count=*countptr;
292 int
293 cc=vp->vibrato_control_counter;
294
295 /* This has never been tested */
296
297 if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */
298
299 while (count--)
300 {
301 if (!cc--)
302 {
303 cc=vp->vibrato_control_ratio;
304 incr=update_vibrato(song, vp, 0);
305 }
306 v1 = src[ofs >> FRACTION_BITS];
307 v2 = src[(ofs >> FRACTION_BITS)+1];
308 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
309 ofs += incr;
310 if (ofs >= le)
311 {
312 if (ofs == le)
313 *dest++ = src[(ofs>>FRACTION_BITS)-1]/2;
314 vp->status=VOICE_FREE;
315 *countptr-=count+1;
316 break;
317 }
318 }
319
320 vp->vibrato_control_counter=cc;
321 vp->sample_increment=incr;
322 vp->sample_offset=ofs; /* Update offset */
323 return song->resample_buffer;
324 }
325
326 static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count)
327 {
328
329 /* Play sample until end-of-loop, skip back and continue. */
330
331 sample_t v1, v2;
332 Sint32
333 ofs=vp->sample_offset,
334 incr=vp->sample_increment,
335 le=vp->sample->loop_end,
336 ll=le - vp->sample->loop_start;
337 sample_t
338 *dest=song->resample_buffer,
339 *src=vp->sample->data;
340 int
341 cc=vp->vibrato_control_counter;
342 Sint32 i, j;
343 int
344 vibflag=0;
345
346 while (count)
347 {
348 /* Hopefully the loop is longer than an increment */
349 while(ofs >= le)
350 ofs -= ll;
351 /* Precalc how many times to go through the loop, taking
352 the vibrato control ratio into account this time. */
353 i = PRECALC_LOOP_COUNT(ofs, le, incr);
354 if(i > count) i = count;
355 if(i > cc)
356 {
357 i = cc;
358 vibflag = 1;
359 }
360 else cc -= i;
361 count -= i;
362 for (j = 0; j < i; j++)
363 {
364 v1 = src[ofs >> FRACTION_BITS];
365 v2 = src[(ofs >> FRACTION_BITS)+1];
366 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
367 ofs += incr;
368 }
369 if(vibflag)
370 {
371 cc = vp->vibrato_control_ratio;
372 incr = update_vibrato(song, vp, 0);
373 vibflag = 0;
374 }
375 }
376
377 vp->vibrato_control_counter=cc;
378 vp->sample_increment=incr;
379 vp->sample_offset=ofs; /* Update offset */
380 return song->resample_buffer;
381 }
382
383 static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count)
384 {
385 sample_t v1, v2;
386 Sint32
387 ofs=vp->sample_offset,
388 incr=vp->sample_increment,
389 le=vp->sample->loop_end,
390 ls=vp->sample->loop_start;
391 sample_t
392 *dest=song->resample_buffer,
393 *src=vp->sample->data;
394 int
395 cc=vp->vibrato_control_counter;
396 Sint32
397 le2=le<<1,
398 ls2=ls<<1,
399 i, j;
400 int
401 vibflag = 0;
402
403 /* Play normally until inside the loop region */
404 while (count && incr > 0 && ofs < ls)
405 {
406 i = PRECALC_LOOP_COUNT(ofs, ls, incr);
407 if (i > count) i = count;
408 if (i > cc)
409 {
410 i = cc;
411 vibflag = 1;
412 }
413 else cc -= i;
414 count -= i;
415 for (j = 0; j < i; j++)
416 {
417 v1 = src[ofs >> FRACTION_BITS];
418 v2 = src[(ofs >> FRACTION_BITS)+1];
419 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
420 ofs += incr;
421 }
422 if (vibflag)
423 {
424 cc = vp->vibrato_control_ratio;
425 incr = update_vibrato(song, vp, 0);
426 vibflag = 0;
427 }
428 }
429
430 /* Then do the bidirectional looping */
431
432 while (count)
433 {
434 /* Precalc how many times we should go through the loop */
435 i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr);
436 if(i > count) i = count;
437 if(i > cc)
438 {
439 i = cc;
440 vibflag = 1;
441 }
442 else cc -= i;
443 count -= i;
444 while (i--)
445 {
446 v1 = src[ofs >> FRACTION_BITS];
447 v2 = src[(ofs >> FRACTION_BITS)+1];
448 *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS);
449 ofs += incr;
450 }
451 if (vibflag)
452 {
453 cc = vp->vibrato_control_ratio;
454 incr = update_vibrato(song, vp, (incr < 0));
455 vibflag = 0;
456 }
457 if (ofs >= le)
458 {
459 /* fold the overshoot back in */
460 ofs = le2 - ofs;
461 incr *= -1;
462 }
463 else if (ofs <= ls)
464 {
465 ofs = ls2 - ofs;
466 incr *= -1;
467 }
468 }
469
470 vp->vibrato_control_counter=cc;
471 vp->sample_increment=incr;
472 vp->sample_offset=ofs; /* Update offset */
473 return song->resample_buffer;
474 }
475
476 sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr)
477 {
478 Sint32 ofs;
479 Uint8 modes;
480 Voice *vp=&(song->voice[v]);
481
482 if (!(vp->sample->sample_rate))
483 {
484 /* Pre-resampled data -- just update the offset and check if
485 we're out of data. */
486 ofs=vp->sample_offset >> FRACTION_BITS; /* Kind of silly to use
487 FRACTION_BITS here... */
488 if (*countptr >= (vp->sample->data_length>>FRACTION_BITS) - ofs)
489 {
490 /* Note finished. Free the voice. */
491 vp->status = VOICE_FREE;
492
493 /* Let the caller know how much data we had left */
494 *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs;
495 }
496 else
497 vp->sample_offset += *countptr << FRACTION_BITS;
498
499 return vp->sample->data+ofs;
500 }
501
502 /* Need to resample. Use the proper function. */
503 modes=vp->sample->modes;
504
505 if (vp->vibrato_control_ratio)
506 {
507 if ((modes & MODES_LOOPING) &&
508 ((modes & MODES_ENVELOPE) ||
509 (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED)))
510 {
511 if (modes & MODES_PINGPONG)
512 return rs_vib_bidir(song, vp, *countptr);
513 else
514 return rs_vib_loop(song, vp, *countptr);
515 }
516 else
517 return rs_vib_plain(song, v, countptr);
518 }
519 else
520 {
521 if ((modes & MODES_LOOPING) &&
522 ((modes & MODES_ENVELOPE) ||
523 (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED)))
524 {
525 if (modes & MODES_PINGPONG)
526 return rs_bidir(song, vp, *countptr);
527 else
528 return rs_loop(song, vp, *countptr);
529 }
530 else
531 return rs_plain(song, v, countptr);
532 }
533 }
534
535 void pre_resample(MidiSong *song, Sample *sp)
536 {
537 double a, xdiff;
538 Sint32 incr, ofs, newlen, count;
539 Sint16 *newdata, *dest, *src = (Sint16 *) sp->data, *vptr;
540 Sint32 v, v1, v2, v3, v4, v5, i;
541 #ifdef DEBUG_CHATTER
542 static const char note_name[12][3] =
543 {
544 "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
545 };
546
547 SNDDBG((" * pre-resampling for note %d (%s%d)\n",
548 sp->note_to_use,
549 note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12));
550 #endif
551
552 a = ((double) (sp->root_freq) * song->rate) /
553 ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]);
554 if(sp->data_length * a >= 0x7fffffffL) { /* Too large to compute */
555 SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use));
556 return;
557 }
558
559 newlen = (Sint32)(sp->data_length * a);
560 count = (newlen >> FRACTION_BITS) - 1;
561 ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count;
562
563 if((double)newlen + incr >= 0x7fffffffL) { /* Too large to compute */
564 SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use));
565 return;
566 }
567
568 dest = newdata = (Sint16 *) safe_malloc((newlen >> (FRACTION_BITS - 1)) + 2);
569 if (!dest)
570 return;
571
572 if (--count)
573 *dest++ = src[0];
574
575 /* Since we're pre-processing and this doesn't have to be done in
576 real-time, we go ahead and do the full sliding cubic interpolation. */
577 count--;
578 for(i = 0; i < count; i++)
579 {
580 vptr = src + (ofs >> FRACTION_BITS);
581 v1 = ((vptr>=src+1)? *(vptr - 1):0);
582 v2 = *vptr;
583 v3 = *(vptr + 1);
584 v4 = *(vptr + 2);
585 v5 = v2 - v3;
586 xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS);
587 v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 +
588 xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1))));
589 *dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v));
590 ofs += incr;
591 }
592
593 if (ofs & FRACTION_MASK)
594 {
595 v1 = src[ofs >> FRACTION_BITS];
596 v2 = src[(ofs >> FRACTION_BITS) + 1];
597 *dest++ = (Sint16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS));
598 }
599 else
600 *dest++ = src[ofs >> FRACTION_BITS];
601
602 *dest = *(dest - 1) / 2;
603 ++dest;
604 *dest = *(dest - 1) / 2;
605
606 sp->data_length = newlen;
607 sp->loop_start = (Sint32)(sp->loop_start * a);
608 sp->loop_end = (Sint32)(sp->loop_end * a);
609 free(sp->data);
610 sp->data = (sample_t *) newdata;
611 sp->sample_rate = 0;
612 }
+0
-13
timidity/resample.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 resample.h
9 */
10
11 extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr);
12 extern void pre_resample(MidiSong *song, Sample *sp);
+0
-203
timidity/tables.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7 */
8
9 #if HAVE_CONFIG_H
10 # include <config.h>
11 #endif
12
13 #include <stdio.h>
14
15 #include "SDL.h"
16
17 #include "tables.h"
18
19 const Sint32 freq_table[128]=
20 {
21 8176, 8662, 9177, 9723,
22 10301, 10913, 11562, 12250,
23 12978, 13750, 14568, 15434,
24
25 16352, 17324, 18354, 19445,
26 20602, 21827, 23125, 24500,
27 25957, 27500, 29135, 30868,
28
29 32703, 34648, 36708, 38891,
30 41203, 43654, 46249, 48999,
31 51913, 55000, 58270, 61735,
32
33 65406, 69296, 73416, 77782,
34 82407, 87307, 92499, 97999,
35 103826, 110000, 116541, 123471,
36
37 130813, 138591, 146832, 155563,
38 164814, 174614, 184997, 195998,
39 207652, 220000, 233082, 246942,
40
41 261626, 277183, 293665, 311127,
42 329628, 349228, 369994, 391995,
43 415305, 440000, 466164, 493883,
44
45 523251, 554365, 587330, 622254,
46 659255, 698456, 739989, 783991,
47 830609, 880000, 932328, 987767,
48
49 1046502, 1108731, 1174659, 1244508,
50 1318510, 1396913, 1479978, 1567982,
51 1661219, 1760000, 1864655, 1975533,
52
53 2093005, 2217461, 2349318, 2489016,
54 2637020, 2793826, 2959955, 3135963,
55 3322438, 3520000, 3729310, 3951066,
56
57 4186009, 4434922, 4698636, 4978032,
58 5274041, 5587652, 5919911, 6271927,
59 6644875, 7040000, 7458620, 7902133,
60
61 8372018, 8869844, 9397273, 9956063,
62 10548082, 11175303, 11839822, 12543854
63 };
64
65 /* v=2.^((x/127-1) * 6) */
66 const double vol_table[128] =
67 {
68 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438,
69 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921,
70 0.020304632921913132, 0.020980557880044631, 0.021678983838355849, 0.02240065983711079,
71 0.023146359851523596, 0.023916883621822989, 0.024713057510949051, 0.025535735390801884,
72 0.026385799557992876, 0.027264161680080529, 0.028171763773305786, 0.029109579212875332,
73 0.030078613776876421, 0.031079906724942836, 0.032114531912828696, 0.033183598944085631,
74 0.034288254360078256, 0.035429682869614412, 0.036609108619508737, 0.037827796507442342,
75 0.039087053538526394, 0.040388230227024875, 0.041732722044739302, 0.043121970917609151,
76 0.044557466772132896, 0.046040749133268132, 0.047573408775524545, 0.049157089429020417,
77 0.050793489542332405, 0.05248436410402918, 0.054231526524842463, 0.056036850582493913,
78 0.057902272431264008, 0.059829792678457581, 0.061821478529993396, 0.063879466007418645,
79 0.066005962238725971, 0.068203247825430205, 0.070473679288442961, 0.072819691595368496,
80 0.075243800771931268, 0.077748606600335793, 0.080336795407452768, 0.083011142945821612,
81 0.085774517370559328, 0.088629882315368294, 0.091580300070941839, 0.094628934869176312,
82 0.097779056276712184, 0.10103404270144323, 0.1043973850157546, 0.1078726903003755,
83 0.11146368571286204, 0.11517422248485852, 0.11900828005242428, 0.12296997032385605,
84 0.12706354208958254, 0.13129338557886089, 0.13566403716816194, 0.14018018424629392,
85 0.14484667024148207, 0.14966849981579558, 0.15465084423249356, 0.15979904690204472,
86 0.16511862911277009, 0.17061529595225433, 0.17629494242587571, 0.18216365977901747,
87 0.18822774202974024, 0.19449369271892172, 0.20096823188510385, 0.20765830327152621,
88 0.21457108177307616, 0.22171398113114205, 0.2290946618846218, 0.23672103958561411,
89 0.2446012932886038, 0.25274387432224471, 0.26115751535314891, 0.26985123975140174,
90 0.27883437126784744, 0.28811654403352405, 0.29770771289197112, 0.30761816407549192,
91 0.31785852623682015, 0.32843978184802081, 0.33937327897885317, 0.3506707434672246,
92 0.36234429149478936, 0.37440644258117928, 0.38687013301080181, 0.39974872970660535,
93 0.41305604456569134, 0.42680634927214656, 0.44101439060298442, 0.45569540624360722,
94 0.47086514112975281, 0.48653986433345225, 0.50273638651110641, 0.51947207793239625,
95 0.53676488710936021, 0.55463336004561792, 0.57309666012638816, 0.59217458867062556,
96 0.61188760616732485, 0.63225685421876243, 0.65330417821421161, 0.67505215075844849,
97 0.69752409588017272, 0.72074411404630734, 0.74473710800900605, 0.76952880951308478,
98 0.79514580689252357, 0.82161557358563286, 0.84896649759946774, 0.87722791195508854,
99 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1
100 };
101
102 const double bend_fine[256] = {
103 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664,
104 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274,
105 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551,
106 1.0027112750502025, 1.0029375461797159, 1.0031638683694153, 1.0033902416308227,
107 1.0036166659754628, 1.0038431414148634, 1.0040696679605541, 1.0042962456240678,
108 1.0045228744169397, 1.0047495543507072, 1.0049762854369111, 1.0052030676870944,
109 1.0054299011128027, 1.0056567857255843, 1.00588372153699, 1.006110708558573,
110 1.0063377468018897, 1.0065648362784985, 1.0067919769999607, 1.0070191689778405,
111 1.0072464122237039, 1.0074737067491204, 1.0077010525656616, 1.0079284496849015,
112 1.0081558981184175, 1.008383397877789, 1.008610948974598, 1.0088385514204294,
113 1.0090662052268706, 1.0092939104055114, 1.0095216669679448, 1.0097494749257656,
114 1.009977334290572, 1.0102052450739643, 1.0104332072875455, 1.0106612209429215,
115 1.0108892860517005, 1.0111174026254934, 1.0113455706759138, 1.0115737902145781,
116 1.0118020612531047, 1.0120303838031153, 1.0122587578762337, 1.012487183484087,
117 1.0127156606383041, 1.0129441893505169, 1.0131727696323602, 1.0134014014954713,
118 1.0136300849514894, 1.0138588200120575, 1.0140876066888203, 1.0143164449934257,
119 1.0145453349375237, 1.0147742765327674, 1.0150032697908125, 1.0152323147233171,
120 1.015461411341942, 1.0156905596583505, 1.0159197596842091, 1.0161490114311862,
121 1.0163783149109531, 1.0166076701351838, 1.0168370771155553, 1.0170665358637463,
122 1.0172960463914391, 1.0175256087103179, 1.0177552228320703, 1.0179848887683858,
123 1.0182146065309567, 1.0184443761314785, 1.0186741975816487, 1.0189040708931674,
124 1.0191339960777379, 1.0193639731470658, 1.0195940021128593, 1.0198240829868295,
125 1.0200542157806898, 1.0202844005061564, 1.0205146371749483, 1.0207449257987866,
126 1.0209752663893958, 1.0212056589585028, 1.0214361035178368, 1.0216666000791297,
127 1.0218971486541166, 1.0221277492545349, 1.0223584018921241, 1.0225891065786274,
128 1.0228198633257899, 1.0230506721453596, 1.023281533049087, 1.0235124460487257,
129 1.0237434111560313, 1.0239744283827625, 1.0242054977406807, 1.0244366192415495,
130 1.0246677928971357, 1.0248990187192082, 1.025130296719539, 1.0253616269099028,
131 1.0255930093020766, 1.0258244439078401, 1.0260559307389761, 1.0262874698072693,
132 1.0265190611245079, 1.0267507047024822, 1.0269824005529853, 1.027214148687813,
133 1.0274459491187637, 1.0276778018576387, 1.0279097069162415, 1.0281416643063788,
134 1.0283736740398595, 1.0286057361284953, 1.0288378505841009, 1.0290700174184932,
135 1.0293022366434921, 1.0295345082709197, 1.0297668323126017, 1.0299992087803651,
136 1.030231637686041, 1.0304641190414621, 1.0306966528584645, 1.0309292391488862,
137 1.0311618779245688, 1.0313945691973556, 1.0316273129790936, 1.0318601092816313,
138 1.0320929581168212, 1.0323258594965172, 1.0325588134325767, 1.0327918199368598,
139 1.0330248790212284, 1.0332579906975481, 1.0334911549776868, 1.033724371873515,
140 1.0339576413969056, 1.0341909635597348, 1.0344243383738811, 1.0346577658512259,
141 1.034891246003653, 1.0351247788430489, 1.0353583643813031, 1.0355920026303078,
142 1.0358256936019572, 1.0360594373081489, 1.0362932337607829, 1.0365270829717617,
143 1.0367609849529913, 1.0369949397163791, 1.0372289472738365, 1.0374630076372766,
144 1.0376971208186156, 1.0379312868297725, 1.0381655056826686, 1.0383997773892284,
145 1.0386341019613787, 1.0388684794110492, 1.0391029097501721, 1.0393373929906822,
146 1.0395719291445176, 1.0398065182236185, 1.0400411602399278, 1.0402758552053915,
147 1.0405106031319582, 1.0407454040315787, 1.0409802579162071, 1.0412151647977996,
148 1.0414501246883161, 1.0416851375997183, 1.0419202035439705, 1.0421553225330404,
149 1.042390494578898, 1.042625719693516, 1.0428609978888699, 1.043096329176938,
150 1.0433317135697009, 1.0435671510791424, 1.0438026417172486, 1.0440381854960086,
151 1.0442737824274138, 1.044509432523459, 1.044745135796141, 1.0449808922574599,
152 1.0452167019194181, 1.0454525647940205, 1.0456884808932754, 1.0459244502291931,
153 1.0461604728137874, 1.0463965486590741, 1.046632677777072, 1.0468688601798024,
154 1.0471050958792898, 1.047341384887561, 1.0475777272166455, 1.047814122878576,
155 1.048050571885387, 1.0482870742491166, 1.0485236299818055, 1.0487602390954964,
156 1.0489969016022356, 1.0492336175140715, 1.0494703868430555, 1.0497072096012419,
157 1.0499440858006872, 1.0501810154534512, 1.050417998571596, 1.0506550351671864,
158 1.0508921252522903, 1.0511292688389782, 1.0513664659393229, 1.0516037165654004,
159 1.0518410207292894, 1.0520783784430709, 1.0523157897188296, 1.0525532545686513,
160 1.0527907730046264, 1.0530283450388465, 1.0532659706834067, 1.0535036499504049,
161 1.0537413828519411, 1.0539791694001188, 1.0542170096070436, 1.0544549034848243,
162 1.0546928510455722, 1.0549308523014012, 1.0551689072644284, 1.0554070159467728,
163 1.0556451783605572, 1.0558833945179062, 1.0561216644309479, 1.0563599881118126,
164 1.0565983655726334, 1.0568367968255465, 1.0570752818826903, 1.0573138207562065,
165 1.057552413458239, 1.0577910600009348, 1.0580297603964437, 1.058268514656918,
166 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123
167 };
168
169 const double bend_coarse[128] = {
170 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721,
171 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815,
172 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868,
173 2, 2.1189261887185906, 2.244924096618746, 2.3784142300054421,
174 2.5198420997897464, 2.6696797083400687, 2.8284271247461903, 2.996614153753363,
175 3.1748021039363992, 3.363585661014858, 3.5635948725613571, 3.7754972507267741,
176 4, 4.2378523774371812, 4.4898481932374912, 4.7568284600108841,
177 5.0396841995794928, 5.3393594166801366, 5.6568542494923806, 5.993228307506727,
178 6.3496042078727974, 6.727171322029716, 7.1271897451227151, 7.5509945014535473,
179 8, 8.4757047548743625, 8.9796963864749824, 9.5136569200217682,
180 10.079368399158986, 10.678718833360273, 11.313708498984761, 11.986456615013454,
181 12.699208415745595, 13.454342644059432, 14.25437949024543, 15.101989002907095,
182 16, 16.951409509748721, 17.959392772949972, 19.027313840043536,
183 20.158736798317967, 21.357437666720553, 22.627416997969522, 23.972913230026901,
184 25.398416831491197, 26.908685288118864, 28.508758980490853, 30.203978005814196,
185 32, 33.902819019497443, 35.918785545899944, 38.054627680087073,
186 40.317473596635935, 42.714875333441107, 45.254833995939045, 47.945826460053802,
187 50.796833662982394, 53.817370576237728, 57.017517960981706, 60.407956011628393,
188 64, 67.805638038994886, 71.837571091799887, 76.109255360174146,
189 80.63494719327187, 85.429750666882214, 90.509667991878089, 95.891652920107603,
190 101.59366732596479, 107.63474115247546, 114.03503592196341, 120.81591202325679,
191 128, 135.61127607798977, 143.67514218359977, 152.21851072034829,
192 161.26989438654374, 170.85950133376443, 181.01933598375618, 191.78330584021521,
193 203.18733465192958, 215.26948230495091, 228.07007184392683, 241.63182404651357,
194 256, 271.22255215597971, 287.35028436719938, 304.43702144069658,
195 322.53978877308765, 341.71900266752868, 362.03867196751236, 383.56661168043064,
196 406.37466930385892, 430.53896460990183, 456.14014368785394, 483.26364809302686,
197 512, 542.44510431195943, 574.70056873439876, 608.87404288139317,
198 645.0795775461753, 683.43800533505737, 724.07734393502471, 767.13322336086128,
199 812.74933860771785, 861.07792921980365, 912.28028737570787, 966.52729618605372,
200 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863,
201 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226
202 };
+0
-19
timidity/tables.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7
8 tables.h
9 */
10
11 #include <math.h>
12 #define sine(x) (sin((2*PI/1024.0) * (x)))
13
14 #define SINE_CYCLE_LENGTH 1024
15 extern const Sint32 freq_table[];
16 extern const double vol_table[];
17 extern const double bend_fine[];
18 extern const double bend_coarse[];
+0
-636
timidity/timidity.c less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7 */
8
9 #if HAVE_CONFIG_H
10 # include <config.h>
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include "SDL.h"
18
19 #include "timidity.h"
20
21 #include "options.h"
22 #include "common.h"
23 #include "instrum.h"
24 #include "playmidi.h"
25 #include "readmidi.h"
26 #include "output.h"
27
28 #include "tables.h"
29
30 ToneBank *master_tonebank[MAXBANK], *master_drumset[MAXBANK];
31
32 static char def_instr_name[256] = "";
33
34 #define MAXWORDS 10
35
36 /* Quick-and-dirty fgets() replacement. */
37
38 static char *RWgets(SDL_RWops *rw, char *s, int size)
39 {
40 int num_read = 0;
41 char *p = s;
42
43 --size;/* so that we nul terminate properly */
44
45 for (; num_read < size; ++p)
46 {
47 if (SDL_RWread(rw, p, 1, 1) != 1)
48 break;
49
50 num_read++;
51
52 /* Unlike fgets(), don't store newline. Under Windows/DOS we'll
53 * probably get an extra blank line for every line that's being
54 * read, but that should be ok.
55 */
56 if (*p == '\n' || *p == '\r')
57 {
58 *p = '\0';
59 return s;
60 }
61 }
62
63 *p = '\0';
64
65 return (num_read != 0) ? s : NULL;
66 }
67
68 static int read_config_file(const char *name)
69 {
70 SDL_RWops *rw;
71 char tmp[1024], *w[MAXWORDS], *cp;
72 ToneBank *bank=0;
73 int i, j, k, line=0, words;
74 static int rcf_count=0;
75
76 if (rcf_count>50)
77 {
78 SNDDBG(("Probable source loop in configuration files\n"));
79 return (-1);
80 }
81
82 if (!(rw=open_file(name)))
83 return -1;
84
85 while (RWgets(rw, tmp, sizeof(tmp)))
86 {
87 line++;
88 words=0;
89 w[0]=strtok(tmp, " \t\240");
90 if (!w[0]) continue;
91
92 /* Originally the TiMidity++ extensions were prefixed like this */
93 if (strcmp(w[0], "#extension") == 0)
94 {
95 w[0]=strtok(0, " \t\240");
96 if (!w[0]) continue;
97 }
98
99 if (*w[0] == '#')
100 continue;
101
102 while (w[words] && *w[words] != '#' && (words < (MAXWORDS-1)))
103 w[++words]=strtok(0," \t\240");
104
105 /*
106 * TiMidity++ adds a number of extensions to the config file format.
107 * Many of them are completely irrelevant to SDL_sound, but at least
108 * we shouldn't choke on them.
109 *
110 * Unfortunately the documentation for these extensions is often quite
111 * vague, gramatically strange or completely absent.
112 */
113 if (
114 !strcmp(w[0], "comm") /* "comm" program second */
115 || !strcmp(w[0], "HTTPproxy") /* "HTTPproxy" hostname:port */
116 || !strcmp(w[0], "FTPproxy") /* "FTPproxy" hostname:port */
117 || !strcmp(w[0], "mailaddr") /* "mailaddr" your-mail-address */
118 || !strcmp(w[0], "opt") /* "opt" timidity-options */
119 )
120 {
121 /*
122 * + "comm" sets some kind of comment -- the documentation is too
123 * vague for me to understand at this time.
124 * + "HTTPproxy", "FTPproxy" and "mailaddr" are for reading data
125 * over a network, rather than from the file system.
126 * + "opt" specifies default options for TiMidity++.
127 *
128 * These are all quite useless for our version of TiMidity, so
129 * they can safely remain no-ops.
130 */
131 } else if (!strcmp(w[0], "timeout")) /* "timeout" program second */
132 {
133 /*
134 * Specifies a timeout value of the program. A number of seconds
135 * before TiMidity kills the note. This may be useful to implement
136 * later, but I don't see any urgent need for it.
137 */
138 SNDDBG(("FIXME: Implement \"timeout\" in TiMidity config.\n"));
139 } else if (!strcmp(w[0], "copydrumset") /* "copydrumset" drumset */
140 || !strcmp(w[0], "copybank")) /* "copybank" bank */
141 {
142 /*
143 * Copies all the settings of the specified drumset or bank to
144 * the current drumset or bank. May be useful later, but not a
145 * high priority.
146 */
147 SNDDBG(("FIXME: Implement \"%s\" in TiMidity config.\n", w[0]));
148 } else if (!strcmp(w[0], "undef")) /* "undef" progno */
149 {
150 /*
151 * Undefines the tone "progno" of the current tone bank (or
152 * drum set?). Not a high priority.
153 */
154 SNDDBG(("FIXME: Implement \"undef\" in TiMidity config.\n"));
155 } else if (!strcmp(w[0], "altassign")) /* "altassign" prog1 prog2 ... */
156 {
157 /*
158 * Sets the alternate assign for drum set. Whatever that's
159 * supposed to mean.
160 */
161 SNDDBG(("FIXME: Implement \"altassign\" in TiMidity config.\n"));
162 } else if (!strcmp(w[0], "soundfont")
163 || !strcmp(w[0], "font"))
164 {
165 /*
166 * I can't find any documentation for these, but I guess they're
167 * an alternative way of loading/unloading instruments.
168 *
169 * "soundfont" sf_file "remove"
170 * "soundfont" sf_file ["order=" order] ["cutoff=" cutoff]
171 * ["reso=" reso] ["amp=" amp]
172 * "font" "exclude" bank preset keynote
173 * "font" "order" order bank preset keynote
174 */
175 SNDDBG(("FIXME: Implmement \"%s\" in TiMidity config.\n", w[0]));
176 } else if (!strcmp(w[0], "progbase"))
177 {
178 /*
179 * The documentation for this makes absolutely no sense to me, but
180 * apparently it sets some sort of base offset for tone numbers.
181 * Why anyone would want to do this is beyond me.
182 */
183 SNDDBG(("FIXME: Implement \"progbase\" in TiMidity config.\n"));
184 } else if (!strcmp(w[0], "map")) /* "map" name set1 elem1 set2 elem2 */
185 {
186 /*
187 * This extension is the one we will need to implement, as it is
188 * used by the "eawpats". Unfortunately I cannot find any
189 * documentation whatsoever for it, but it looks like it's used
190 * for remapping one instrument to another somehow.
191 */
192 SNDDBG(("FIXME: Implement \"map\" in TiMidity config.\n"));
193 }
194
195 /* Standard TiMidity config */
196
197 else if (!strcmp(w[0], "dir"))
198 {
199 if (words < 2)
200 {
201 SNDDBG(("%s: line %d: No directory given\n", name, line));
202 goto fail;
203 }
204 for (i=1; i<words; i++)
205 add_to_pathlist(w[i]);
206 }
207 else if (!strcmp(w[0], "source"))
208 {
209 if (words < 2)
210 {
211 SNDDBG(("%s: line %d: No file name given\n", name, line));
212 goto fail;
213 }
214 for (i=1; i<words; i++)
215 {
216 int status;
217 rcf_count++;
218 status = read_config_file(w[i]);
219 rcf_count--;
220 if (status != 0) {
221 SDL_RWclose(rw);
222 return status;
223 }
224 }
225 }
226 else if (!strcmp(w[0], "default"))
227 {
228 if (words != 2)
229 {
230 SNDDBG(("%s: line %d: Must specify exactly one patch name\n",
231 name, line));
232 goto fail;
233 }
234 strncpy(def_instr_name, w[1], 255);
235 def_instr_name[255]='\0';
236 }
237 else if (!strcmp(w[0], "drumset"))
238 {
239 if (words < 2)
240 {
241 SNDDBG(("%s: line %d: No drum set number given\n", name, line));
242 goto fail;
243 }
244 i=atoi(w[1]);
245 if (i<0 || i>(MAXBANK-1))
246 {
247 SNDDBG(("%s: line %d: Drum set must be between 0 and %d\n",
248 name, line, MAXBANK-1));
249 goto fail;
250 }
251 if (!master_drumset[i])
252 {
253 master_drumset[i] = safe_malloc(sizeof(ToneBank));
254 memset(master_drumset[i], 0, sizeof(ToneBank));
255 master_drumset[i]->tone = safe_malloc(128 * sizeof(ToneBankElement));
256 memset(master_drumset[i]->tone, 0, 128 * sizeof(ToneBankElement));
257 }
258 bank=master_drumset[i];
259 }
260 else if (!strcmp(w[0], "bank"))
261 {
262 if (words < 2)
263 {
264 SNDDBG(("%s: line %d: No bank number given\n", name, line));
265 goto fail;
266 }
267 i=atoi(w[1]);
268 if (i<0 || i>(MAXBANK-1))
269 {
270 SNDDBG(("%s: line %d: Tone bank must be between 0 and %d\n",
271 name, line, MAXBANK-1));
272 goto fail;
273 }
274 if (!master_tonebank[i])
275 {
276 master_tonebank[i] = safe_malloc(sizeof(ToneBank));
277 memset(master_tonebank[i], 0, sizeof(ToneBank));
278 master_tonebank[i]->tone = safe_malloc(128 * sizeof(ToneBankElement));
279 memset(master_tonebank[i]->tone, 0, 128 * sizeof(ToneBankElement));
280 }
281 bank=master_tonebank[i];
282 }
283 else
284 {
285 if ((words < 2) || (*w[0] < '0' || *w[0] > '9'))
286 {
287 SNDDBG(("%s: line %d: syntax error\n", name, line));
288 continue;
289 }
290 i=atoi(w[0]);
291 if (i<0 || i>127)
292 {
293 SNDDBG(("%s: line %d: Program must be between 0 and 127\n",
294 name, line));
295 goto fail;
296 }
297 if (!bank)
298 {
299 SNDDBG(("%s: line %d: Must specify tone bank or drum set before assignment\n",
300 name, line));
301 goto fail;
302 }
303 if (bank->tone[i].name)
304 free(bank->tone[i].name);
305 strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]);
306 bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan=
307 bank->tone[i].strip_loop=bank->tone[i].strip_envelope=
308 bank->tone[i].strip_tail=-1;
309
310 for (j=2; j<words; j++)
311 {
312 if (!(cp=strchr(w[j], '=')))
313 {
314 SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j]));
315 goto fail;
316 }
317 *cp++=0;
318 if (!strcmp(w[j], "amp"))
319 {
320 k=atoi(cp);
321 if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9'))
322 {
323 SNDDBG(("%s: line %d: amplification must be between 0 and %d\n",
324 name, line, MAX_AMPLIFICATION));
325 goto fail;
326 }
327 bank->tone[i].amp=k;
328 }
329 else if (!strcmp(w[j], "note"))
330 {
331 k=atoi(cp);
332 if ((k<0 || k>127) || (*cp < '0' || *cp > '9'))
333 {
334 SNDDBG(("%s: line %d: note must be between 0 and 127\n",
335 name, line));
336 goto fail;
337 }
338 bank->tone[i].note=k;
339 }
340 else if (!strcmp(w[j], "pan"))
341 {
342 if (!strcmp(cp, "center"))
343 k=64;
344 else if (!strcmp(cp, "left"))
345 k=0;
346 else if (!strcmp(cp, "right"))
347 k=127;
348 else
349 k=((atoi(cp)+100) * 100) / 157;
350 if ((k<0 || k>127) || (k==0 && *cp!='-' && (*cp < '0' || *cp > '9')))
351 {
352 SNDDBG(("%s: line %d: panning must be left, right, center, or between -100 and 100\n",
353 name, line));
354 goto fail;
355 }
356 bank->tone[i].pan=k;
357 }
358 else if (!strcmp(w[j], "keep"))
359 {
360 if (!strcmp(cp, "env"))
361 bank->tone[i].strip_envelope=0;
362 else if (!strcmp(cp, "loop"))
363 bank->tone[i].strip_loop=0;
364 else
365 {
366 SNDDBG(("%s: line %d: keep must be env or loop\n", name, line));
367 goto fail;
368 }
369 }
370 else if (!strcmp(w[j], "strip"))
371 {
372 if (!strcmp(cp, "env"))
373 bank->tone[i].strip_envelope=1;
374 else if (!strcmp(cp, "loop"))
375 bank->tone[i].strip_loop=1;
376 else if (!strcmp(cp, "tail"))
377 bank->tone[i].strip_tail=1;
378 else
379 {
380 SNDDBG(("%s: line %d: strip must be env, loop, or tail\n",
381 name, line));
382 goto fail;
383 }
384 }
385 else
386 {
387 SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j]));
388 goto fail;
389 }
390 }
391 }
392 }
393 SDL_RWclose(rw);
394 return 0;
395 fail:
396 SDL_RWclose(rw);
397 return -2;
398 }
399
400 int Timidity_Init_NoConfig()
401 {
402 /* Allocate memory for the standard tonebank and drumset */
403 master_tonebank[0] = safe_malloc(sizeof(ToneBank));
404 memset(master_tonebank[0], 0, sizeof(ToneBank));
405 master_tonebank[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
406 memset(master_tonebank[0]->tone, 0, 128 * sizeof(ToneBankElement));
407
408 master_drumset[0] = safe_malloc(sizeof(ToneBank));
409 memset(master_drumset[0], 0, sizeof(ToneBank));
410 master_drumset[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
411 memset(master_drumset[0]->tone, 0, 128 * sizeof(ToneBankElement));
412
413 return 0;
414 }
415
416 int Timidity_Init()
417 {
418 const char *env = SDL_getenv("TIMIDITY_CFG");
419
420 /* !!! FIXME: This may be ugly, but slightly less so than requiring the
421 * default search path to have only one element. I think.
422 *
423 * We only need to include the likely locations for the config
424 * file itself since that file should contain any other directory
425 * that needs to be added to the search path.
426 */
427 #ifdef DEFAULT_PATH
428 add_to_pathlist(DEFAULT_PATH);
429 #endif
430 #ifdef DEFAULT_PATH1
431 add_to_pathlist(DEFAULT_PATH1);
432 #endif
433 #ifdef DEFAULT_PATH2
434 add_to_pathlist(DEFAULT_PATH2);
435 #endif
436 #ifdef DEFAULT_PATH3
437 add_to_pathlist(DEFAULT_PATH3);
438 #endif
439
440 Timidity_Init_NoConfig();
441
442 if (!env || read_config_file(env)<0) {
443 if (read_config_file(CONFIG_FILE)<0) {
444 if (read_config_file(CONFIG_FILE_ETC)<0) {
445 if (read_config_file(CONFIG_FILE_ETC_TIMIDITY_FREEPATS)<0) {
446 return(-1);
447 }
448 }
449 }
450 }
451 return 0;
452 }
453
454 MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio)
455 {
456 MidiSong *song;
457 int i;
458
459 if (rw == NULL)
460 return NULL;
461
462 /* Allocate memory for the song */
463 song = (MidiSong *)safe_malloc(sizeof(*song));
464 if (song == NULL)
465 return NULL;
466 memset(song, 0, sizeof(*song));
467
468 for (i = 0; i < MAXBANK; i++)
469 {
470 if (master_tonebank[i])
471 {
472 song->tonebank[i] = safe_malloc(sizeof(ToneBank));
473 memset(song->tonebank[i], 0, sizeof(ToneBank));
474 song->tonebank[i]->tone = master_tonebank[i]->tone;
475 }
476 if (master_drumset[i])
477 {
478 song->drumset[i] = safe_malloc(sizeof(ToneBank));
479 memset(song->drumset[i], 0, sizeof(ToneBank));
480 song->drumset[i]->tone = master_drumset[i]->tone;
481 }
482 }
483
484 song->amplification = DEFAULT_AMPLIFICATION;
485 song->voices = DEFAULT_VOICES;
486 song->drumchannels = DEFAULT_DRUMCHANNELS;
487
488 song->rw = rw;
489
490 song->rate = audio->freq;
491 song->encoding = 0;
492 if ((audio->format & 0xFF) == 16)
493 song->encoding |= PE_16BIT;
494 else if ((audio->format & 0xFF) == 32)
495 song->encoding |= PE_32BIT;
496 if (audio->format & 0x8000)
497 song->encoding |= PE_SIGNED;
498 if (audio->channels == 1)
499 song->encoding |= PE_MONO;
500 else if (audio->channels > 2) {
501 SDL_SetError("Surround sound not supported");
502 free(song);
503 return NULL;
504 }
505 switch (audio->format) {
506 case AUDIO_S8:
507 song->write = s32tos8;
508 break;
509 case AUDIO_U8:
510 song->write = s32tou8;
511 break;
512 case AUDIO_S16LSB:
513 song->write = s32tos16l;
514 break;
515 case AUDIO_S16MSB:
516 song->write = s32tos16b;
517 break;
518 case AUDIO_U16LSB:
519 song->write = s32tou16l;
520 break;
521 case AUDIO_U16MSB:
522 song->write = s32tou16b;
523 break;
524 case AUDIO_S32LSB:
525 song->write = s32tos32l;
526 break;
527 case AUDIO_S32MSB:
528 song->write = s32tos32b;
529 break;
530 case AUDIO_F32SYS:
531 song->write = s32tof32;
532 break;
533 default:
534 SDL_SetError("Unsupported audio format");
535 free(song);
536 return NULL;
537 }
538
539 song->buffer_size = audio->samples;
540 song->resample_buffer = safe_malloc(audio->samples * sizeof(sample_t));
541 song->common_buffer = safe_malloc(audio->samples * 2 * sizeof(Sint32));
542
543 song->control_ratio = audio->freq / CONTROLS_PER_SECOND;
544 if (song->control_ratio < 1)
545 song->control_ratio = 1;
546 else if (song->control_ratio > MAX_CONTROL_RATIO)
547 song->control_ratio = MAX_CONTROL_RATIO;
548
549 song->lost_notes = 0;
550 song->cut_notes = 0;
551
552 song->events = read_midi_file(song, &(song->groomed_event_count),
553 &song->samples);
554
555 /* The RWops can safely be closed at this point, but let's make that the
556 * responsibility of the caller.
557 */
558
559 /* Make sure everything is okay */
560 if (!song->events) {
561 free(song);
562 return(NULL);
563 }
564
565 song->default_instrument = 0;
566 song->default_program = DEFAULT_PROGRAM;
567
568 if (*def_instr_name)
569 set_default_instrument(song, def_instr_name);
570
571 load_missing_instruments(song);
572
573 return(song);
574 }
575
576 void Timidity_FreeSong(MidiSong *song)
577 {
578 int i;
579
580 free_instruments(song);
581
582 for (i = 0; i < 128; i++)
583 {
584 if (song->tonebank[i])
585 free(song->tonebank[i]);
586 if (song->drumset[i])
587 free(song->drumset[i]);
588 }
589
590 free(song->common_buffer);
591 free(song->resample_buffer);
592 free(song->events);
593 free(song);
594 }
595
596 void Timidity_Exit(void)
597 {
598 int i, j;
599
600 for (i = 0; i < MAXBANK; i++)
601 {
602 if (master_tonebank[i])
603 {
604 ToneBankElement *e = master_tonebank[i]->tone;
605 if (e != NULL)
606 {
607 for (j = 0; j < 128; j++)
608 {
609 if (e[j].name != NULL)
610 free(e[j].name);
611 }
612 free(e);
613 }
614 free(master_tonebank[i]);
615 master_tonebank[i] = NULL;
616 }
617 if (master_drumset[i])
618 {
619 ToneBankElement *e = master_drumset[i]->tone;
620 if (e != NULL)
621 {
622 for (j = 0; j < 128; j++)
623 {
624 if (e[j].name != NULL)
625 free(e[j].name);
626 }
627 free(e);
628 }
629 free(master_drumset[i]);
630 master_drumset[i] = NULL;
631 }
632 }
633
634 free_pathlist();
635 }
+0
-163
timidity/timidity.h less more
0 /*
1
2 TiMidity -- Experimental MIDI to WAVE converter
3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the Perl Artistic License, available in COPYING.
7 */
8
9 #ifndef TIMIDITY_H
10 #define TIMIDITY_H
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 typedef Sint16 sample_t;
16 typedef Sint32 final_volume_t;
17
18 #define VIBRATO_SAMPLE_INCREMENTS 32
19
20 /* Maximum polyphony. */
21 /* #define MAX_VOICES 48 */
22 #define MAX_VOICES 256
23 #define MAXCHAN 16
24 /* #define MAXCHAN 64 */
25 #define MAXBANK 128
26
27 typedef struct {
28 Sint32
29 loop_start, loop_end, data_length,
30 sample_rate, low_freq, high_freq, root_freq;
31 Sint32
32 envelope_rate[6], envelope_offset[6];
33 float
34 volume;
35 sample_t *data;
36 Sint32
37 tremolo_sweep_increment, tremolo_phase_increment,
38 vibrato_sweep_increment, vibrato_control_ratio;
39 Uint8
40 tremolo_depth, vibrato_depth,
41 modes;
42 Sint8
43 panning, note_to_use;
44 } Sample;
45
46 typedef struct {
47 int
48 bank, program, volume, sustain, panning, pitchbend, expression,
49 mono, /* one note only on this channel -- not implemented yet */
50 pitchsens;
51 /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
52 processor near you */
53 float
54 pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
55 } Channel;
56
57 typedef struct {
58 Uint8
59 status, channel, note, velocity;
60 Sample *sample;
61 Sint32
62 orig_frequency, frequency,
63 sample_offset, sample_increment,
64 envelope_volume, envelope_target, envelope_increment,
65 tremolo_sweep, tremolo_sweep_position,
66 tremolo_phase, tremolo_phase_increment,
67 vibrato_sweep, vibrato_sweep_position;
68
69 final_volume_t left_mix, right_mix;
70
71 float
72 left_amp, right_amp, tremolo_volume;
73 Sint32
74 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
75 int
76 vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
77 envelope_stage, control_counter, panning, panned;
78
79 } Voice;
80
81 typedef struct {
82 int samples;
83 Sample *sample;
84 } Instrument;
85
86 /* Shared data */
87 typedef struct {
88 char *name;
89 int note, amp, pan, strip_loop, strip_envelope, strip_tail;
90 } ToneBankElement;
91
92 typedef struct {
93 ToneBankElement *tone;
94 Instrument *instrument[128];
95 } ToneBank;
96
97 typedef struct {
98 Sint32 time;
99 Uint8 channel, type, a, b;
100 } MidiEvent;
101
102 typedef struct {
103 MidiEvent event;
104 void *next;
105 } MidiEventList;
106
107 typedef struct {
108 int playing;
109 SDL_RWops *rw;
110 Sint32 rate;
111 Sint32 encoding;
112 float master_volume;
113 Sint32 amplification;
114 ToneBank *tonebank[MAXBANK];
115 ToneBank *drumset[MAXBANK];
116 Instrument *default_instrument;
117 int default_program;
118 void (*write)(void *dp, Sint32 *lp, Sint32 c);
119 int buffer_size;
120 sample_t *resample_buffer;
121 Sint32 *common_buffer;
122 Sint32 *buffer_pointer;
123 /* These would both fit into 32 bits, but they are often added in
124 large multiples, so it's simpler to have two roomy ints */
125 /* samples per MIDI delta-t */
126 Sint32 sample_increment;
127 Sint32 sample_correction;
128 Channel channel[MAXCHAN];
129 Voice voice[MAX_VOICES];
130 int voices;
131 Sint32 drumchannels;
132 Sint32 buffered_count;
133 Sint32 control_ratio;
134 Sint32 lost_notes;
135 Sint32 cut_notes;
136 Sint32 samples;
137 MidiEvent *events;
138 MidiEvent *current_event;
139 MidiEventList *evlist;
140 Sint32 current_sample;
141 Sint32 event_count;
142 Sint32 at;
143 Sint32 groomed_event_count;
144 } MidiSong;
145
146 /* Some of these are not defined in timidity.c but are here for convenience */
147
148 extern int Timidity_Init(void);
149 extern int Timidity_Init_NoConfig(void);
150 extern void Timidity_SetVolume(MidiSong *song, int volume);
151 extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len);
152 extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio);
153 extern void Timidity_Start(MidiSong *song);
154 extern void Timidity_Seek(MidiSong *song, Uint32 ms);
155 extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */
156 extern void Timidity_FreeSong(MidiSong *song);
157 extern void Timidity_Exit(void);
158
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif /* TIMIDITY_H */
2424 VALUE "FileDescription", "SDL_mixer\0"
2525 VALUE "FileVersion", "2, 0, 4, 0\0"
2626 VALUE "InternalName", "SDL_mixer\0"
27 VALUE "LegalCopyright", "Copyright © 2018 Sam Lantinga\0"
27 VALUE "LegalCopyright", "Copyright © 2021 Sam Lantinga\0"
2828 VALUE "OriginalFilename", "SDL_mixer.dll\0"
2929 VALUE "ProductName", "Simple DirectMedia Layer\0"
3030 VALUE "ProductVersion", "2, 0, 4, 0\0"