########################################
#
# Audacity Makefile
#
# Dominic Mazzoni
#
# Run configure to generate Makefile
# from Makefile.in
#

CC = @CC@
CCC = @CXX@

# Files that must exist in order to compile a C/C++ files
CDEPEND = @CDEPEND@

# For precompiled header support
PRECOMP_CFLAGS = @PRECOMP_CFLAGS@

LOCAL_LIBS = @LOCAL_LIBS@
EXTRAOBJS = @EXTRAOBJS@
EXTRATARGETS = @EXTRATARGETS@
LIBS = @LIBS@
DIRS=blockfile commands effects effects/ladspa effects/nyquist export import prefs widgets xml

srcdir=@srcdir@
top_srcdir=@top_srcdir@
top_builddir=@top_builddir@

# CFLAGS are specific to C.
override CFLAGS += @CFLAGS@

# CXXFLAGS are specific to C++.
override CXXFLAGS += @CXXFLAGS@

# CPPFLAGS are for both C and C++.
override CPPFLAGS += -Wall -I$(srcdir)/include -I. @CPPFLAGS@ 


########################################
# ALL OBJECT FILES

OBJS = \
	AColor.o \
	AboutDialog.o \
	AudacityApp.o \
	AudioIO.o \
	BatchCommandDialog.o \
	BatchCommands.o \
	BatchProcessDialog.o \
	Benchmark.o \
	ControlToolBar.o \
	Envelope.o \
	EditToolBar.o \
	FFT.o \
	FreqWindow.o \
	Help.o \
	HistoryWindow.o \
	ImageManipulation.o \
	LabelTrack.o \
	Languages.o \
	LangChoice.o \
	Legacy.o \
	Menus.o \
	MeterToolBar.o \
	Mix.o \
	MixerToolBar.o \
	NoteTrack.o \
	PitchName.o \
	PlatformCompatibility.o \
	Printing.o \
	Project.o \
	Resample.o \
	RingBuffer.o \
	SelectionBar.o \
	Shuttle.o \
	Spectrum.o \
	Tags.o \
	TimeTrack.o \
	Track.o \
	TrackArtist.o \
	TrackPanel.o \
	TranscriptionToolBar.o \
	ToolBar.o \
	UndoManager.o \
	UploadDialog.o \
	VoiceKey.o \
	WaveClip.o \
	WaveTrack.o \
	commands/CommandManager.o \
	commands/Keyboard.o \
	effects/Effect.o \
	effects/SimpleMono.o \
	effects/SimplePairedTwoTrack.o \
	effects/SoundTouchEffect.o \
	effects/LoadEffects.o \
	effects/Amplify.o \
	effects/BassBoost.o \
	effects/ChangeLength.o \
	effects/ChangePitch.o \
	effects/ChangeSpeed.o \
	effects/ChangeTempo.o \
	effects/ClickRemoval.o \
	effects/Compressor.o \
	effects/Echo.o \
	effects/Equalization.o \
	effects/Fade.o \
	effects/Filter.o \
	effects/Invert.o \
	effects/Leveller.o \
	effects/Noise.o \
	effects/NoiseRemoval.o \
	effects/Normalize.o \
	effects/Phaser.o \
	effects/Repeat.o \
	effects/Reverse.o \
	effects/Silence.o \
	effects/SpikeCleaner.o \
	effects/StereoToMono.o \
	effects/ToneGen.o \
	effects/TruncSilence.o \
	effects/TwoPassSimpleMono.o \
	effects/Wahwah.o \
	export/Export.o \
	export/ExportMultiple.o \
	export/ExportMP3.o \
	export/ExportOGG.o \
	export/ExportPCM.o \
	export/ExportCL.o \
	import/Import.o \
	import/ImportFLAC.o \
	import/ImportLOF.o \
	import/ImportMIDI.o \
	import/ImportMP3.o \
	import/ImportOGG.o \
	import/ImportPCM.o \
	import/ImportRaw.o \
	import/RawAudioGuess.o \
	prefs/AudioIOPrefs.o \
	prefs/BatchPrefs.o \
	prefs/DirectoriesPrefs.o \
	prefs/FileFormatPrefs.o \
	prefs/GUIPrefs.o \
	prefs/KeyConfigPrefs.o \
	prefs/MousePrefs.o \
	prefs/PrefsDialog.o \
	prefs/QualityPrefs.o \
	prefs/SpectrumPrefs.o \
	widgets/AButton.o \
	widgets/ASlider.o \
	widgets/Meter.o \
	widgets/MultiDialog.o \
	widgets/Ruler.o \
	widgets/TimeTextCtrl.o \
	widgets/Warning.o \
	xml/XMLFileReader.o \
	@OPTOBJS@

TEMPORARILY_DISABLED_IMPORTER_OBJS = \
	import/ImportMIDI.o \
	import/ImportPCM.o \
	import/ImportRaw.o \

LIBAUDACITY_OBJS = \
	BlockFile.o \
	Dither.o \
	DirManager.o \
	FileFormats.o \
	Prefs.o \
	SampleFormat.o \
	Sequence.o \
	Internat.o \
	blockfile/LegacyBlockFile.o \
	blockfile/LegacyAliasBlockFile.o \
	blockfile/SilentBlockFile.o \
	blockfile/SimpleBlockFile.o \
	blockfile/PCMAliasBlockFile.o \
	xml/XMLTagHandler.o \


########################################
# DEPENDENCIES

SOURCES = $(OBJS:%.o=%.cpp)
LIBAUDACITY_SOURCES = $(LIBAUDACITY_OBJS:%.o=%.cpp)

########################################

all: $(DIRS) libaudacity.a ../audacity $(EXTRATARGETS)

libaudacity.a: $(LIBAUDACITY_OBJS)
	ar rcs libaudacity.a $(LIBAUDACITY_OBJS)

../audacity: $(OBJS) $(LOCAL_LIBS:%=$(top_builddir)/lib-src/%) $(EXTRAOBJS) libaudacity.a Makefile
	$(CCC) -o ../audacity $(OBJS) $(LOCAL_LIBS:%=$(top_builddir)/lib-src/%) $(EXTRAOBJS) libaudacity.a $(LIBS)
	@AFTERBUILD@

$(DIRS):
	mkdir -p $(DIRS)

#
# Mac OS X application
#

../Audacity.app: ../audacity
	mkdir -p ../Audacity.app/Contents/MacOS
	mkdir -p ../Audacity.app/Contents/Resources
	cp -f ../audacity ../Audacity.app/Contents/MacOS
	cp -f ../mac/Info.plist ../Audacity.app/Contents
	test -f "../Audacity.app/Contents/PkgInfo" || \
	     echo "APPLauDy" > ../Audacity.app/Contents/PkgInfo
	cp -f ../mac/Resources/*.icns ../Audacity.app/Contents/Resources
	cp -f ../mac/Resources2/Audacity.rsrc \
		../Audacity.app/Contents/Resources/Audacity.rsrc

#
# You can optionally "make dep" to make dependencies.
# The sed script turns "Foo.o: bar/Foo.cpp" into "bar/Foo.o: bar/Foo.cpp".
#

dep:
	$(CCC) -MM $(CXXFLAGS) $(CPPFLAGS) $(SOURCES) $(LIBAUDACITY_SOURCES) | \
		sed -e 's/^.*\.o: \([^ ]*\)\.cpp/\1.o: \1.cpp/' \
		> .depend
	$(CCC) -MM $(CXXFLAGS) $(CPPFLAGS) AudacityHeaders.h | \
		sed -e 's/^.*: \([^ ]*\)\.cpp/$(OBJDIR)\/\1.o: /' | \
		sed 's/AudacityHeaders.o/AudacityHeaders.h.gch/' \
		> .gchdepend

clean:
	rm -rf $(OBJS) $(LIBAUDACITY_OBJS)
	rm -f libaudacity.a

#
# Rule for compiling C++ files
#

$(OBJS) $(LIBAUDACITY_OBJS): %.o: $(srcdir)/%.cpp configunix.h $(CDEPEND)
	$(CCC) -c $(CXXFLAGS) $(CPPFLAGS) $(PRECOMP_CFLAGS) $< -o $@

#
# Precompiled headers:
#

AudacityHeaders.h.gch:
	echo "Rebuilding Precompiled Headers"
	$(CCC) -c $(CXXFLAGS) $(CPPFLAGS) AudacityHeaders.h -o AudacityHeaders.h.gch

#
# Include ".depend" if it exists (run "make dep" to generate it)
#

ifeq (.depend,$(wildcard .depend))
include .depend
endif

