Attached are some fixes for making mainline Faust work on Windows again. I
tested these with both mingw 4.4 and 4.8 (the latest) and they work fine
for me.
Most of the changes are rather straightforward and unobtrusive, but I also
had to remove some existing Windows-specific code which didn't work, so
someone in the know should maybe review the patch.
Ok to commit?
Albert
--
Dr. Albert Gr"af
Computer Music Research Group, JGU Mainz, Germany
Email: aggr...@gmail.com
WWW: https://plus.google.com/+AlbertGraef
diff --git a/compiler/Makefile.unix b/compiler/Makefile.unix
index b7ca7b2..f6dab52 100755
--- a/compiler/Makefile.unix
+++ b/compiler/Makefile.unix
@@ -15,6 +15,11 @@ else
ARCHFLAGS :=
endif
+## On Windows (mingw32) we must link against the socket library.
+ifneq ($(findstring MINGW32, $(system)),)
+LIBS = -lwsock32
+endif
+
CXXFLAGS ?= -O1 -g -Wall -Wuninitialized
##CXXFLAGS ?= -O3 -Wall -Wuninitialized $(ARCHFLAGS)
CXXFLAGS += -Wno-parentheses $(addprefix -I, $(subprojects))
-DINSTALL_PREFIX='"$(prefix)"'
@@ -22,7 +27,7 @@ CXXFLAGS += -Wno-parentheses $(addprefix -I, $(subprojects))
-DINSTALL_PREFIX='"
all : faust
faust : $(objects)
- $(CXX) $(CXXFLAGS) $(objects) -o faust
+ $(CXX) $(CXXFLAGS) $(objects) -o faust $(LIBS)
.PHONY: clean depend ctags parser
diff --git a/compiler/main.cpp b/compiler/main.cpp
index 0a0ef12..c58db85 100644
--- a/compiler/main.cpp
+++ b/compiler/main.cpp
@@ -194,6 +194,10 @@ static string makeDrawPathNoExt()
}
}
+#ifdef WIN32
+#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
+#endif
+
bool process_cmdline(int argc, char* argv[])
{
int i=1; int err=0;
diff --git a/compiler/parser/enrobage.cpp b/compiler/parser/enrobage.cpp
index abc922a..4d94dfd 100644
--- a/compiler/parser/enrobage.cpp
+++ b/compiler/parser/enrobage.cpp
@@ -446,34 +446,6 @@ static void buildFullPathname(string& fullpath, const
char* filename)
* place its full pathname in the string <fullpath>
*/
-#ifdef WIN32
-FILE* fopensearch(const char* filename, string& fullpath)
-{
- FILE* f;
- char* envpath;
-
- if ((f = fopen(filename, "r"))) {
- buildFullPathname(fullpath, filename);
- return f;
- }
- if ((f = fopenat(fullpath, gMasterDirectory, filename))) {
- return f;
- }
- if ((envpath = getenv("FAUST_LIB_PATH")) && (f = fopenat(fullpath,
envpath, filename))) {
- return f;
- }
- if ((f = fopenat(fullpath, gFaustDirectory, "architecture", filename))) {
- return f;
- }
- if ((f = fopenat(fullpath, gFaustSuperDirectory, "architecture",
filename))) {
- return f;
- }
- if ((f = fopenat(fullpath, gFaustSuperSuperDirectory, "architecture",
filename))) {
- return f;
- }
- return 0;
-}
-#else
FILE* fopensearch(const char* filename, string& fullpath)
{
FILE* f;
@@ -527,7 +499,6 @@ FILE* fopensearch(const char* filename, string& fullpath)
}
return 0;
}
-#endif
/**
diff --git a/compiler/parser/faustlexer.l b/compiler/parser/faustlexer.l
index d515020..f055334 100644
--- a/compiler/parser/faustlexer.l
+++ b/compiler/parser/faustlexer.l
@@ -5,7 +5,6 @@
%{
#include "tree.hh"
#include "faustparser.hpp"
-#include "compatibility.hh"
%}
DIGIT [0-9]
diff --git a/compiler/tlib/compatibility.cpp b/compiler/tlib/compatibility.cpp
index bc868ba..bf300da 100644
--- a/compiler/tlib/compatibility.cpp
+++ b/compiler/tlib/compatibility.cpp
@@ -76,7 +76,7 @@
}
#if defined(_MBCS) || __MINGW32__
- bool chdir(const char* path)
+ int chdir(const char* path)
{
return !SetCurrentDirectory(path);
}
@@ -86,7 +86,7 @@
return CreateDirectory(path,NULL);
}
- char* getcwd(char* str, unsigned int size)
+ char* getcwd(char* str, int size)
{
GetCurrentDirectory(size, str);
return str;
diff --git a/compiler/tlib/compatibility.hh b/compiler/tlib/compatibility.hh
index fefbeb4..717797d 100644
--- a/compiler/tlib/compatibility.hh
+++ b/compiler/tlib/compatibility.hh
@@ -25,18 +25,14 @@
#ifdef WIN32
-#if !defined(INT) & !defined(FLOAT)
#include <windows.h>
-#else
-#include <io.h>
-#endif
#include <time.h>
#include <assert.h>
#undef min
#undef max
-#define int64_t __int64
+//#define int64_t __int64
#define YY_NO_UNISTD_H 1
struct timezone
@@ -47,15 +43,14 @@ struct timezone
#define alarm(x)
#define strdup _strdup
-#define isatty _isatty
-#define fileno _fileno
#define snprintf _snprintf
-double rint(double nr);
+extern "C" {
int gettimeofday(struct timeval *tv, struct timezone *tz);
-bool chdir(const char* path);
+int chdir(const char *path);
int mkdir(const char* path, unsigned int attribute);
-char* getcwd(char* str, unsigned int size);
+char* getcwd(char* str, int size);
int isatty(int file);
+}
void getFaustPathname(char* str, unsigned int size);
void getFaustPathname(char* str, unsigned int size);
diff --git a/compiler/tlib/node.hh b/compiler/tlib/node.hh
index 1d056f4..39a7015 100644
--- a/compiler/tlib/node.hh
+++ b/compiler/tlib/node.hh
@@ -53,10 +53,6 @@
#ifndef __NODE__
#define __NODE__
-#ifdef WIN32
-#define int64_t __int64
-#endif
-
#include <iostream>
#include "symbol.hh"
#include <sys/types.h>
diff --git a/compiler/utils/files.cpp b/compiler/utils/files.cpp
index 83d038d..222644f 100644
--- a/compiler/utils/files.cpp
+++ b/compiler/utils/files.cpp
@@ -26,7 +26,9 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
+#ifndef WIN32
#include <unistd.h>
+#endif
#include <errno.h>
using namespace std;
diff --git a/tools/sound2faust/Makefile b/tools/sound2faust/Makefile
index d0faa7e..985551f 100644
--- a/tools/sound2faust/Makefile
+++ b/tools/sound2faust/Makefile
@@ -4,9 +4,16 @@ PREFIX ?= /usr/local
prefix := $(DESTDIR)$(PREFIX)
+system ?= $(shell uname -s)
+
+## On Windows (mingw32) we must link against the socket library.
+ifneq ($(findstring MINGW32, $(system)),)
+LIBS = -lwsock32
+endif
+
sound2faust : sound2faust.cpp
- g++ -O3 sound2faust.cpp -I../../architecture `pkg-config --cflags
--static --libs sndfile` -o sound2faust
+ g++ -O3 sound2faust.cpp -I../../architecture `pkg-config --cflags
--static --libs sndfile` -o sound2faust $(LIBS)
static:
diff --git a/tools/sound2faust/sound2faust.cpp
b/tools/sound2faust/sound2faust.cpp
index e6b6f6a..42ed701 100644
--- a/tools/sound2faust/sound2faust.cpp
+++ b/tools/sound2faust/sound2faust.cpp
@@ -54,20 +54,7 @@ int main(int argc, char *argv[])
}
snd_info.format = 0;
-#ifndef _WIN32
soundfile = sf_open(argv[1], SFM_READ, &snd_info);
-#else
- printf("ARGV 1 = %s\n", argv[1]);
- char *dir = new char[_MAX_DIR];
- char* ext = new char[_MAX_EXT];
- _splitpath(argv[1], NULL, dir, base_name, ext);
- string fullPath(dir);
- fullPath += "\\";
- fullPath += base_name;
- fullPath += ext;
- printf("FullPath = %s\n", fullPath.c_str());
- soundfile = sf_open(fullPath.c_str(), SFM_READ, &snd_info);
-#endif
if (soundfile == NULL) {
printf("soundfile '%s' cannot be opened\n", base_name);
------------------------------------------------------------------------------
Slashdot TV. Video for Nerds. Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel