shithub: opus-tools

Download patch

ref: d2ca877ff7dc38401b3c477208d322f25c18eb8d
parent: ed79787d16ee8bb5afe5bd4bf829e51894e5eace
author: Ralph Giles <giles@mozilla.com>
date: Mon Nov 5 07:47:51 EST 2012

Update Makefile.unix to work with mingw.

If $(CC) contains the substring 'mingw' then add some
options required to target windows. This fixes

  make -f Makefile.unix CC=i686-w64-mingw32-gcc

on my Fedora 17 system.

This uses a few more GNU make features, and makes the
Makefile itself less portable. However, we've had some
gnu-isms like := for a couple of releases so far without
complaint.

--- a/Makefile.unix
+++ b/Makefile.unix
@@ -2,26 +2,35 @@
 #Run ./configure to run autotools/autoconf.
 #This makefile exists as a fallback where autotools isn't working.
 #CC=gcc
-CFLAGS:=-DPACKAGE='"opus-tools"' -DVERSION='"0.1.5git"' -DOPUSTOOLS -O2 -g -c -Wall -Wextra -DHAVE_GETOPT_H -DSPX_RESAMPLE_EXPORT= -DRANDOM_PREFIX=opustools -DOUTSIDE_SPEEX -DFLOATING_POINT $(CFLAGS)
-INCLUDES=-I../opus/include
+CFLAGS := -DPACKAGE='"opus-tools"' -DVERSION='"0.1.5git"' -DOPUSTOOLS -O2 -g -c -Wall -Wextra -DHAVE_GETOPT_H -DSPX_RESAMPLE_EXPORT= -DRANDOM_PREFIX=opustools -DOUTSIDE_SPEEX -DFLOATING_POINT $(CFLAGS)
+INCLUDES := -I../opus/include
 
+ifneq (,$(findstring mingw,$(CC)))
+  INCLUDES += -Iwin32
+  COMMON_OBJS += win32/unicode_support.o
+  CFLAGS += -DHAVE_WINMM
+  LIBS += -lwinmm
+endif
+
 PROGS := opusenc opusdec opusinfo
 all: $(PROGS)
 
+clean:
+	rm -f src/*.o win32/*.o $(PROGS) opusrtp
+
+.PHONEY: all clean
+
 .c.o:
 	$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
 
-opusenc: src/opus_header.o src/opusenc.o src/resample.o src/audio-in.o src/diag_range.o src/lpc.o
-	$(CC) $(LDFLAGS) src/opus_header.o src/audio-in.o src/diag_range.o src/opusenc.o src/resample.o src/lpc.o -o opusenc ../opus/.libs/libopus.a -lm -logg
+opusenc: src/opus_header.o src/opusenc.o src/resample.o src/audio-in.o src/diag_range.o src/lpc.o $(COMMON_OBJS)
+	$(CC) $(LDFLAGS) $^ -o $@ ../opus/.libs/libopus.a -lm -logg $(LIBS)
 
-opusdec: src/opus_header.o src/wav_io.o src/wave_out.o src/opusdec.o src/resample.o src/diag_range.o
-	$(CC) $(LDFLAGS) src/wave_out.o src/opus_header.o src/wav_io.o src/diag_range.o src/opusdec.o src/resample.o -o opusdec ../opus/.libs/libopus.a -lm -logg
+opusdec: src/opus_header.o src/wav_io.o src/wave_out.o src/opusdec.o src/resample.o src/diag_range.o $(COMMON_OBJS)
+	$(CC) $(LDFLAGS) $^ -o $@ ../opus/.libs/libopus.a -lm -logg $(LIBS)
 
-opusinfo: src/opus_header.o src/opusinfo.o src/info_opus.o
-	$(CC) $(LDFLAGS) src/opus_header.o src/opusinfo.o src/info_opus.o -o opusinfo -logg
+opusinfo: src/opus_header.o src/opusinfo.o src/info_opus.o $(COMMON_OBJS)
+	$(CC) $(LDFLAGS) $^ -o $@ -logg $(LIBS)
 
 opusrtp: src/opusrtp.o
-	$(CC) $(LDFLAGS) src/opusrtp.o -o opusrtp ../opus/.libs/libopus.a -logg
-
-clean:
-	rm -f src/*.o $(PROGS) opusrtp
+	$(CC) $(LDFLAGS) $^ -o $@ ../opus/.libs/libopus.a -logg