Use own minimal "getopt" function to support compiling using MSVC.
diff --git a/Makefile.in b/Makefile.in
index 002d25d..0c091be 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -202,6 +202,18 @@
 test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
 	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
 
+crypto/test/cipher_driver$(EXE): crypto/test/cipher_driver.c test/getopt_s.c
+	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
+
+crypto/test/kernel_driver$(EXE): crypto/test/kernel_driver.c test/getopt_s.c
+	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
+
+crypto/test/rand_gen$(EXE): crypto/test/rand_gen.c test/getopt_s.c
+	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
+
+crypto/test/rand_gen_soak$(EXE): crypto/test/rand_gen_soak.c test/getopt_s.c
+	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
+
 test: $(testapp)
 	@echo "Build done. Please run '$(MAKE) runtest' to run self tests."
 
diff --git a/crypto/Makefile.in b/crypto/Makefile.in
index b6d6fcf..4938437 100644
--- a/crypto/Makefile.in
+++ b/crypto/Makefile.in
@@ -9,7 +9,7 @@
 VPATH = @srcdir@
 
 CC	= @CC@
-INCDIR	= -Iinclude -I$(srcdir)/include
+INCDIR	= -Iinclude -I$(srcdir)/include -I$(top_srcdir)/include
 DEFS	= @DEFS@
 CPPFLAGS= @CPPFLAGS@
 CFLAGS	= @CFLAGS@
@@ -82,8 +82,8 @@
 %.o: %.c
 	$(COMPILE) -c $< -o $@
 
-%$(EXE): %.c  
-	$(COMPILE) $(LDFLAGS) $< -o $@ $(CRYPTOLIB) $(LIBS)
+%$(EXE): %.c ../test/getopt_s.c
+	$(COMPILE) $(LDFLAGS) $< ../test/getopt_s.c -o $@ $(CRYPTOLIB) $(LIBS)
 
 all: $(testapp)
 
diff --git a/crypto/test/cipher_driver.c b/crypto/test/cipher_driver.c
index ead784e..64db5c3 100644
--- a/crypto/test/cipher_driver.c
+++ b/crypto/test/cipher_driver.c
@@ -50,7 +50,7 @@
 #include <stdio.h>           /* for printf() */
 #include <stdlib.h>          /* for rand() */
 #include <string.h>          /* for memset() */
-#include <unistd.h>          /* for getopt() */
+#include "getopt_s.h"
 #include "cipher.h"
 #ifdef OPENSSL
 #include "aes_icm_ossl.h"
@@ -153,7 +153,7 @@
 
   /* process input arguments */
   while (1) {
-    q = getopt(argc, argv, "tva");
+    q = getopt_s(argc, argv, "tva");
     if (q == -1) 
       break;
     switch (q) {
diff --git a/crypto/test/kernel_driver.c b/crypto/test/kernel_driver.c
index c0f12c1..188637c 100644
--- a/crypto/test/kernel_driver.c
+++ b/crypto/test/kernel_driver.c
@@ -48,7 +48,7 @@
 #endif
 
 #include <stdio.h>           /* for printf() */
-#include <unistd.h>          /* for getopt() */
+#include "getopt_s.h"
 #include "crypto_kernel.h"
 
 void
@@ -59,7 +59,6 @@
 
 int
 main (int argc, char *argv[]) {
-  extern char *optarg;
   int q;
   int do_validation      = 0;
   err_status_t status;
@@ -77,7 +76,7 @@
 
   /* process input arguments */
   while (1) {
-    q = getopt(argc, argv, "vd:");
+    q = getopt_s(argc, argv, "vd:");
     if (q == -1) 
       break;
     switch (q) {
@@ -85,9 +84,9 @@
       do_validation = 1;
       break;
     case 'd':
-      status = crypto_kernel_set_debug_module(optarg, 1);
+      status = crypto_kernel_set_debug_module(optarg_s, 1);
       if (status) {
-	printf("error: set debug module (%s) failed\n", optarg);
+	printf("error: set debug module (%s) failed\n", optarg_s);
 	exit(1);
       }
       break;
diff --git a/crypto/test/rand_gen.c b/crypto/test/rand_gen.c
index 8bb8b88..b8051d5 100644
--- a/crypto/test/rand_gen.c
+++ b/crypto/test/rand_gen.c
@@ -48,7 +48,7 @@
 #endif
 
 #include <stdio.h>           /* for printf() */
-#include <unistd.h>          /* for getopt() */
+#include "getopt_s.h"
 #include "crypto_kernel.h"
 
 /*
@@ -72,7 +72,6 @@
 
 int
 main (int argc, char *argv[]) {
-  extern char *optarg;
   int q;
   int num_octets = 0;
   unsigned do_list_mods = 0;
@@ -90,14 +89,14 @@
 
   /* process input arguments */
   while (1) {
-    q = getopt(argc, argv, "ld:n:");
+    q = getopt_s(argc, argv, "ld:n:");
     if (q == -1) 
       break;
     switch (q) {
     case 'd':
-      status = crypto_kernel_set_debug_module(optarg, 1);
+      status = crypto_kernel_set_debug_module(optarg_s, 1);
       if (status) {
-	printf("error: set debug module (%s) failed\n", optarg);
+	printf("error: set debug module (%s) failed\n", optarg_s);
 	exit(1);
       }
       break;
@@ -105,7 +104,7 @@
       do_list_mods = 1;
       break;
     case 'n':
-      num_octets = atoi(optarg);
+      num_octets = atoi(optarg_s);
       if (num_octets < 0 || num_octets > BUF_LEN)
 	usage(argv[0]);
       break;
diff --git a/crypto/test/rand_gen_soak.c b/crypto/test/rand_gen_soak.c
index a39aaa0..b0e67a7 100644
--- a/crypto/test/rand_gen_soak.c
+++ b/crypto/test/rand_gen_soak.c
@@ -43,7 +43,7 @@
 #endif
 
 #include <stdio.h>           /* for printf() */
-#include <unistd.h>          /* for getopt() */
+#include "getopt_s.h"
 #include "crypto_kernel.h"
 
 #define BUF_LEN (MAX_PRINT_STRING_LEN/2)
@@ -51,7 +51,6 @@
 int main(int argc, char *argv[])
 {
     int q;
-    extern char *optarg;
     int num_octets = 0;
     err_status_t status;
     uint32_t iterations = 0;
@@ -68,7 +67,7 @@
     }
 
     while (1) {
-        q = getopt(argc, argv, "pvn:");
+        q = getopt_s(argc, argv, "pvn:");
         if (q == -1) {
             break;
         }
@@ -77,7 +76,7 @@
             print_values = 1;
             break;
         case 'n':
-            num_octets = atoi(optarg);
+            num_octets = atoi(optarg_s);
             if (num_octets < 0 || num_octets > BUF_LEN) {
                 exit(255);
             }