]> Pileus Git - ~andy/rsl/commitdiff
Build fixes for win32
authorAndy Spencer <andy753421@gmail.com>
Sun, 28 Aug 2011 21:58:30 +0000 (21:58 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 28 Aug 2011 21:58:30 +0000 (21:58 +0000)
Currently unsupported features:
  - fork, used by gzip decompression
  - rpc, used by lassen radar format

13 files changed:
configure.ac
examples/killer_sweep.c
src/Makefile.am
src/dorade.c
src/gzip.c
src/lassen.c
src/rainbow.c
src/rapic_parse.y
src/rapic_routines.c
src/rapic_scan.l
src/rsl.h
src/win32compat.h [new file with mode: 0644]
src/wsr88d.h

index 2b59634bc41bb6c6f5606535bd38bd123923cbed..3405552614fc46d39e90023dfbf4af7f54b75126 100644 (file)
@@ -59,6 +59,16 @@ if test "$YYWRAP" = ""; then
        LIBS="$LIBS $LEXLIB"
 fi
 
+# Test for Windows vs. Unix
+case "${host}" in
+       *mingw32*) WIN32="yes" ;;
+       *)         WIN32="no"  ;;
+esac
+if test "$WIN32" = yes; then
+       ac_default_prefix="/"
+fi
+AM_CONDITIONAL([WIN32], test "$WIN32" = "yes")
+
 AC_MSG_RESULT(LIBS = $LIBS)
 AC_CONFIG_FILES([Makefile doc/Makefile data/Makefile examples/Makefile src/Makefile])
 AC_OUTPUT
index d70766c84a347c1b4b0f96901e284fc310b87c7f..4ad518b90d434aea5ae85c84b4b3e8d1f6294777 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "rsl.h"
 #include <stdlib.h>
+#include <limits.h>
 void print_link_list(Azimuth_hash *list)
 {
   if (list == NULL) {
@@ -84,9 +85,7 @@ void poke_about_sweep(Sweep *s)
 
 float random_azim(void)
 {
-  double drand;
-  drand = drand48()*1;
-  return (float)drand;
+  return (float)rand() / INT_MAX;
 }
 
 Sweep *permute_sweep(Sweep *sweep)
index dbc3fd391b6c684210e2d2ac81690dcd1b994a33..7bcf3813ad11c2c67fd7e01ebe631aed471fe563 100644 (file)
@@ -12,7 +12,7 @@ headers = africa.h dorade.h lassen.h \
          $(include_HEADERS)
 
 librsl_la_LDFLAGS  = -version-info 1:42
-librsl_la_CPPFLAGS = -DDATADIR="\"$(datadir)/rsl\"" 
+librsl_la_CPPFLAGS = -DDATADIRRSL="\"$(dots)$(datadir)/rsl\"" 
 librsl_la_SOURCES  = \
        rapic_parse.y rapic_scan.l rapic_to_radar.c rapic_routines.c \
        radtec.c radtec_to_radar.c \
@@ -29,6 +29,12 @@ librsl_la_SOURCES  = \
        radar_to_hdf_2.c hdf_to_radar.c toolkit_memory_mgt.c \
        radar_to_hdf_1.c rainbow.c rainbow_to_radar.c $(headers)
 
+if WIN32
+librsl_la_LDFLAGS += -mwindows -no-undefined
+librsl_la_LIBADD   = -lws2_32
+dots               = ..
+endif
+
 # This should be speciifc to rapic,
 # but I'm not sure how to do that with autofoo
 AM_LFLAGS  = -P rapic
index 7cd137f5cabfb66b75ffff9db25b32e6e2495fcf..6dac83128f2a266e733953e6931f4cca2f9dfc88 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <netinet/in.h>
 #include <string.h>
 #include "dorade.h"
+#ifndef WIN32
+#include <netinet/in.h>
+#else
+#include "win32compat.h"
+#endif
 
 int dorade_verbose = 0;
 
index b2c76371d0a98834696db7643841f637771c16a7..9c2ef315a16aaf97adebf701b321f00cfcca7c13 100644 (file)
@@ -26,9 +26,8 @@
 #include <string.h>
 #define _USE_BSD
 #include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
 #include <signal.h>
+#include "win32compat.h"
 
 /* Prototype definitions within this file. */
 int no_command (char *cmd);
index dc8cd161dd1b44b1ff54cd4143e71610a462b6ab..b850b5dcfe244228be77e8aaf68ff8625bfb0793 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "lassen.h"
+#ifndef WIN32
 #include <rpc/rpc.h>
 #include <netinet/in.h>
-#include "lassen.h"
+#else
+#include "win32compat.h"
+#endif
 
 /* xdr_destroy is broken on HPUX, SGI, and SUN; Linux, the only working one? */
 /* This broken behavior could be from old xdr versions, too. */
index 7d5862c00f525cfc2fe1eba141c3b9d9046421ba..72892f503d230e8073807aaaf80d2db3699ed873 100644 (file)
@@ -27,6 +27,8 @@
 #include "rsl.h"
 #include "rainbow.h"
 
+#include "win32compat.h"
+
 static int get_param_int(char *buf)
 {
     /* Returns an integer parameter from a header line. */
index b10475702322bc9e593b5c22a8b27fa64ab25413..eede522b7b1674dc603124238a2986ce401b92b6 100644 (file)
@@ -616,9 +616,3 @@ int rapicerror(char *s)
   fprintf(stderr, ">\n");
   return 1;
 }
-
-int rapicwrap(char *s)
-{
-  yywrap(s);
-  return 1;
-}
index 2ae3faf238b87d0104257c12960c9ac2c26ef077..ff92f0921345089d59660981debf370ecde60e79 100644 (file)
@@ -1,8 +1,12 @@
 #include <stdio.h>
 #include "rapic_routines.h"
 #include <string.h>
-
+#ifndef WIN32
 #include <netinet/in.h>
+#else
+#include "win32compat.h"
+#endif
+
 void rapic_decode(unsigned char *inbuf, int inbytes, unsigned char *outbuf, int *outbytes,
                                  float *azim, float *elev, int *delta_time)
 {
index 002aacd6874b614340b55e977b73757dc27f7a3e..6291c6358cba1acb051555deb8c896dbe26b4454 100644 (file)
@@ -44,6 +44,7 @@
 
 %option nounput
 %option noinput
+%option noyywrap
 %x ATMODE
 
 %%
index 597069c83933392f6e499d594b7fd4f1bbba3d35..b3ea1f490220a28fa7df62b0c1bc145737a9c98f 100644 (file)
--- a/src/rsl.h
+++ b/src/rsl.h
@@ -44,7 +44,7 @@
 /*            so you shouldn't have to modify anything here.          */
 /**********************************************************************/
 #ifndef COLORDIR
-#define COLORDIR DATADIR "/colors"
+#define COLORDIR DATADIRRSL "/colors"
 #endif
 
 /* These are the color table indexes. See RSL_set/get_color_table. */
diff --git a/src/win32compat.h b/src/win32compat.h
new file mode 100644 (file)
index 0000000..897d8a1
--- /dev/null
@@ -0,0 +1,39 @@
+#ifdef WIN32
+#include <windows.h>
+#include <winsock2.h>
+
+typedef int            bool_t;
+typedef unsigned char  uchar_t;
+typedef unsigned short ushort_t;
+typedef unsigned int   uint_t;
+
+typedef struct {} XDR;
+
+enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 };
+
+static inline bool_t unimp(char *what)
+{
+       printf("%s not supported in win32\n", what);
+       exit(-1);
+       return FALSE;
+}
+
+static inline void   xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op)    {        unimp("xdr"); }
+static inline void   xdr_destroy(XDR *xdrs)                                    {        unimp("xdr"); }
+static inline bool_t xdr_u_char (XDR *xdrs, uchar_t  *ucp)                     { return unimp("xdr"); }
+static inline bool_t xdr_bytes  (XDR *xdrs, char    **sp, uint_t *s, uint_t m) { return unimp("xdr"); }
+static inline bool_t xdr_int    (XDR *xdrs, int      *ip)                      { return unimp("xdr"); }
+static inline bool_t xdr_string (XDR *xdrs, char    **sp, uint_t maxsize)      { return unimp("xdr"); }
+static inline bool_t xdr_u_short(XDR *xdrs, ushort_t *usp)                     { return unimp("xdr"); }
+static inline bool_t xdr_short  (XDR *xdrs, short    *sp)                      { return unimp("xdr"); }
+static inline bool_t xdr_u_int  (XDR *xdrs, uint_t   *up)                      { return unimp("xdr"); }
+
+static inline pid_t fork(void) { return unimp("fork"); }
+
+static inline char *index(const char *s, int c)
+{
+    while (*s != c && *s != '\0')
+       s++;
+    return *s == '\0' ? NULL : (char*)s;
+}
+#endif
index 7d22427a15cbbd8dcfefe5e0d6dd822410887665..ba56391994341c697212f1bc936375e5066af6f7 100644 (file)
@@ -7,7 +7,7 @@
  * The directory should be the same as the LIBDIR in the makefile.
  */
 #ifndef WSR88D_SITE_INFO_FILE
-#define WSR88D_SITE_INFO_FILE DATADIR "/wsr88d_locations.dat"
+#define WSR88D_SITE_INFO_FILE DATADIRRSL "/wsr88d_locations.dat"
 #endif
 /*===============================================================*/
 typedef struct {