Commit 208a337e1de2183b849e6c93ada766c001f1a4db
Committed by
Stéphane Raimbault
1 parent
60adc050
Add a windows scripting host configure file.
Simply run cscript configure.js from the win32 directory to generate the files needed to create the modbus DLL.
Showing
4 changed files
with
366 additions
and
9 deletions
src/win32/README.win32
| 1 | 1 | Intro |
| 2 | 2 | ----- |
| 3 | 3 | |
| 4 | -This directory contains the project file for Visual Studio 2008 to build a | |
| 5 | -modbus.dll. | |
| 4 | + | |
| 5 | +This directory contains the project file for Visual Studio 2008 to build | |
| 6 | +modbus.dll and the import library modbus.lib. | |
| 7 | + | |
| 6 | 8 | |
| 7 | 9 | The project file searches for D:/include/msvc_std to find stdint.h. |
| 8 | 10 | See ../../README.md |
| 9 | 11 | |
| 10 | -config.h and modbus-version.h were generated using a Windows native experimental | |
| 11 | -port of zsh and Microsoft cl. | |
| 12 | - | |
| 13 | 12 | |
| 14 | -TODO | |
| 15 | ----- | |
| 13 | +config.h and ../modbus-version.h are generated using configure.js. | |
| 14 | +Run | |
| 15 | + cscript configurs.js | |
| 16 | +to generate these files. | |
| 16 | 17 | |
| 17 | -Fix the ugly need to have config.h and modbus-version.h in this directory. | ... | ... |
src/win32/config.h.win32
0 → 100644
| 1 | +/* config.h. Generated from config.h.in by configure. */ | |
| 2 | +/* config.h.in. Generated from configure.ac by autoheader. */ | |
| 3 | + | |
| 4 | +/* Define to 1 if you have the <arpa/inet.h> header file. */ | |
| 5 | +/* #undef HAVE_ARPA_INET_H */ | |
| 6 | + | |
| 7 | +/* Define to 1 if you have the declaration of `TIOCSRS485', and to 0 if you | |
| 8 | + don't. */ | |
| 9 | +/* #undef HAVE_DECL_TIOCSRS485 */ | |
| 10 | + | |
| 11 | +/* Define to 1 if you have the declaration of `__CYGWIN__', and to 0 if you | |
| 12 | + don't. */ | |
| 13 | +/* #undef HAVE_DECL___CYGWIN__ */ | |
| 14 | + | |
| 15 | +/* Define to 1 if you have the <dlfcn.h> header file. */ | |
| 16 | +/* #undef HAVE_DLFCN_H */ | |
| 17 | + | |
| 18 | +/* Define to 1 if you have the <errno.h> header file. */ | |
| 19 | +#define HAVE_ERRNO_H 1 | |
| 20 | + | |
| 21 | +/* Define to 1 if you have the <fcntl.h> header file. */ | |
| 22 | +#define HAVE_FCNTL_H 1 | |
| 23 | + | |
| 24 | +/* Define to 1 if you have the `fork' function. */ | |
| 25 | +/* #undef HAVE_FORK */ | |
| 26 | + | |
| 27 | +/* Define to 1 if you have the `getaddrinfo' function. */ | |
| 28 | +/* #undef HAVE_GETADDRINFO */ | |
| 29 | + | |
| 30 | +/* Define to 1 if you have the `gettimeofday' function. */ | |
| 31 | +/* #undef HAVE_GETTIMEOFDAY */ | |
| 32 | + | |
| 33 | +/* Define to 1 if you have the `inet_ntoa' function. */ | |
| 34 | +/* #undef HAVE_INET_NTOA */ | |
| 35 | + | |
| 36 | +/* Define to 1 if you have the <inttypes.h> header file. */ | |
| 37 | +#define HAVE_INTTYPES_H 1 | |
| 38 | + | |
| 39 | +/* Define to 1 if you have the <limits.h> header file. */ | |
| 40 | +#define HAVE_LIMITS_H 1 | |
| 41 | + | |
| 42 | +/* Define to 1 if you have the <linux/serial.h> header file. */ | |
| 43 | +/* #undef HAVE_LINUX_SERIAL_H */ | |
| 44 | + | |
| 45 | +/* Define to 1 if you have the <memory.h> header file. */ | |
| 46 | +#define HAVE_MEMORY_H 1 | |
| 47 | + | |
| 48 | +/* Define to 1 if you have the `memset' function. */ | |
| 49 | +#define HAVE_MEMSET 1 | |
| 50 | + | |
| 51 | +/* Define to 1 if you have the <netdb.h> header file. */ | |
| 52 | +/* #undef HAVE_NETDB_H */ | |
| 53 | + | |
| 54 | +/* Define to 1 if you have the <netinet/in.h> header file. */ | |
| 55 | +/* #undef HAVE_NETINET_IN_H */ | |
| 56 | + | |
| 57 | +/* Define to 1 if you have the <netinet/tcp.h> header file. */ | |
| 58 | +/* #undef HAVE_NETINET_TCP_H */ | |
| 59 | + | |
| 60 | +/* Define to 1 if you have the `select' function. */ | |
| 61 | +/* #undef HAVE_SELECT */ | |
| 62 | + | |
| 63 | +/* Define to 1 if you have the `socket' function. */ | |
| 64 | +/* #undef HAVE_SOCKET */ | |
| 65 | + | |
| 66 | +/* Define to 1 if you have the <stdint.h> header file. */ | |
| 67 | +#define HAVE_STDINT_H 1 | |
| 68 | + | |
| 69 | +/* Define to 1 if you have the <stdlib.h> header file. */ | |
| 70 | +#define HAVE_STDLIB_H 1 | |
| 71 | + | |
| 72 | +/* Define to 1 if you have the `strerror' function. */ | |
| 73 | +#define HAVE_STRERROR 1 | |
| 74 | + | |
| 75 | +/* Define to 1 if you have the <strings.h> header file. */ | |
| 76 | +/* #undef HAVE_STRINGS_H */ | |
| 77 | + | |
| 78 | +/* Define to 1 if you have the <string.h> header file. */ | |
| 79 | +#define HAVE_STRING_H 1 | |
| 80 | + | |
| 81 | +/* Define to 1 if you have the `strlcpy' function. */ | |
| 82 | +/* #undef HAVE_STRLCPY */ | |
| 83 | + | |
| 84 | +/* Define to 1 if you have the <sys/ioctl.h> header file. */ | |
| 85 | +/* #undef HAVE_SYS_IOCTL_H */ | |
| 86 | + | |
| 87 | +/* Define to 1 if you have the <sys/socket.h> header file. */ | |
| 88 | +/* #undef HAVE_SYS_SOCKET_H */ | |
| 89 | + | |
| 90 | +/* Define to 1 if you have the <sys/stat.h> header file. */ | |
| 91 | +#define HAVE_SYS_STAT_H 1 | |
| 92 | + | |
| 93 | +/* Define to 1 if you have the <sys/time.h> header file. */ | |
| 94 | +/* #undef HAVE_SYS_TIME_H */ | |
| 95 | + | |
| 96 | +/* Define to 1 if you have the <sys/types.h> header file. */ | |
| 97 | +#define HAVE_SYS_TYPES_H 1 | |
| 98 | + | |
| 99 | +/* Define to 1 if you have the <termios.h> header file. */ | |
| 100 | +/* #undef HAVE_TERMIOS_H */ | |
| 101 | + | |
| 102 | +/* Define to 1 if you have the <time.h> header file. */ | |
| 103 | +#define HAVE_TIME_H 1 | |
| 104 | + | |
| 105 | +/* Define to 1 if you have the <unistd.h> header file. */ | |
| 106 | +/* #undef HAVE_UNISTD_H */ | |
| 107 | + | |
| 108 | +/* Define to 1 if you have the `vfork' function. */ | |
| 109 | +/* #undef HAVE_VFORK */ | |
| 110 | + | |
| 111 | +/* Define to 1 if you have the <vfork.h> header file. */ | |
| 112 | +/* #undef HAVE_VFORK_H */ | |
| 113 | + | |
| 114 | +/* Define to 1 if you have the <winsock2.h> header file. */ | |
| 115 | +#define HAVE_WINSOCK2_H 1 | |
| 116 | + | |
| 117 | +/* Define to 1 if `fork' works. */ | |
| 118 | +/* #undef HAVE_WORKING_FORK */ | |
| 119 | + | |
| 120 | +/* Define to 1 if `vfork' works. */ | |
| 121 | +/* #undef HAVE_WORKING_VFORK */ | |
| 122 | + | |
| 123 | +/* Define to the sub-directory in which libtool stores uninstalled libraries. | |
| 124 | + */ | |
| 125 | +/* #undef LT_OBJDIR */ | |
| 126 | + | |
| 127 | +/* Name of package */ | |
| 128 | +#define PACKAGE "libmodbus" | |
| 129 | + | |
| 130 | +/* Define to the address where bug reports for this package should be sent. */ | |
| 131 | +#define PACKAGE_BUGREPORT "https://github.com/stephane/libmodbus/issues" | |
| 132 | + | |
| 133 | +/* Define to the full name of this package. */ | |
| 134 | +#define PACKAGE_NAME "libmodbus" | |
| 135 | + | |
| 136 | +/* Define to the full name and version of this package. */ | |
| 137 | +#define PACKAGE_STRING "libmodbus @LIBMODBUS_VERSION@" | |
| 138 | + | |
| 139 | +/* Define to the one symbol short name of this package. */ | |
| 140 | +#define PACKAGE_TARNAME "libmodbus" | |
| 141 | + | |
| 142 | +/* Define to the home page for this package. */ | |
| 143 | +#define PACKAGE_URL "" | |
| 144 | + | |
| 145 | +/* Define to the version of this package. */ | |
| 146 | +#define PACKAGE_VERSION "@LIBMODBUS_VERSION@" | |
| 147 | + | |
| 148 | +/* Define to 1 if you have the ANSI C header files. */ | |
| 149 | +#define STDC_HEADERS 1 | |
| 150 | + | |
| 151 | +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ | |
| 152 | +/* #undef TIME_WITH_SYS_TIME */ | |
| 153 | + | |
| 154 | +/* Version number of package */ | |
| 155 | +#define VERSION "@LIBMODBUS_VERSION@" | |
| 156 | + | |
| 157 | +/* Define to empty if `const' does not conform to ANSI C. */ | |
| 158 | +/* #undef const */ | |
| 159 | + | |
| 160 | +/* Define to `int' if <sys/types.h> does not define. */ | |
| 161 | +/* #undef pid_t */ | |
| 162 | + | |
| 163 | +/* Define to `unsigned int' if <sys/types.h> does not define. */ | |
| 164 | +/* #undef size_t */ | |
| 165 | + | |
| 166 | +/* Define as `fork' if `vfork' does not work. */ | |
| 167 | +#define vfork fork | ... | ... |
src/win32/configure.js
0 → 100644
| 1 | +/* Configure script for modbus.dll, specific for Windows with Scripting Host. | |
| 2 | + * | |
| 3 | + * Inspired by configure.js from libxml2 | |
| 4 | + * | |
| 5 | + * oldfaber < oldfaber _at_ gmail _dot_ com > | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + | |
| 9 | +/* The source directory, relative to the one where this file resides. */ | |
| 10 | +var srcDir = ".."; | |
| 11 | +/* Base name of what we are building. */ | |
| 12 | +var baseName = "modbus"; | |
| 13 | +/* Configure file template and output file */ | |
| 14 | +var configFile = srcDir + "\\..\\configure.ac"; | |
| 15 | +/* Input and output files for the modbus-version.h include */ | |
| 16 | +var newfile; | |
| 17 | +/* Version strings for the binary distribution. Will be filled later in the code. */ | |
| 18 | +var verMajor; | |
| 19 | +var verMinor; | |
| 20 | +var verMicro; | |
| 21 | +/* modbus features. */ | |
| 22 | +var testRun = false; | |
| 23 | +/* Win32 build options. NOT used yet */ | |
| 24 | +var compiler = "msvc"; | |
| 25 | +/* Local stuff */ | |
| 26 | +var error = 0; | |
| 27 | + | |
| 28 | +/* Helper function, transforms the option variable into the 'Enabled' | |
| 29 | + or 'Disabled' string. */ | |
| 30 | +function boolToStr(opt) | |
| 31 | +{ | |
| 32 | + if (opt == false) | |
| 33 | + return "no"; | |
| 34 | + else if (opt == true) | |
| 35 | + return "yes"; | |
| 36 | + error = 1; | |
| 37 | + return "*** undefined ***"; | |
| 38 | +} | |
| 39 | + | |
| 40 | +/* Helper function, transforms the argument string into a boolean | |
| 41 | + value. */ | |
| 42 | +function strToBool(opt) | |
| 43 | +{ | |
| 44 | + if (opt == 0 || opt == "no") | |
| 45 | + return false; | |
| 46 | + else if (opt == 1 || opt == "yes") | |
| 47 | + return true; | |
| 48 | + error = 1; | |
| 49 | + return false; | |
| 50 | +} | |
| 51 | + | |
| 52 | +/* Displays the details about how to use this script. */ | |
| 53 | +function usage() | |
| 54 | +{ | |
| 55 | + var txt; | |
| 56 | + txt = "Usage:\n"; | |
| 57 | + txt += " cscript " + WScript.ScriptName + " <options>\n"; | |
| 58 | + txt += " cscript " + WScript.ScriptName + " help\n\n"; | |
| 59 | + txt += "Options can be specified in the form <option>=<value>, where the value is\n"; | |
| 60 | + txt += "either 'yes' or 'no', if not stated otherwise.\n\n"; | |
| 61 | + txt += "\nModbus library configure options, default value given in parentheses:\n\n"; | |
| 62 | + txt += " test-run: Run configure without creating files (" + (testRun? "yes" : "no") + ")\n"; | |
| 63 | + txt += "\nWin32 build options, default value given in parentheses:\n\n"; | |
| 64 | + txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n"; | |
| 65 | + WScript.Echo(txt); | |
| 66 | +} | |
| 67 | + | |
| 68 | +/* read the version from the configuration file */ | |
| 69 | +function readVersion() | |
| 70 | +{ | |
| 71 | + var fso, cf, ln, s; | |
| 72 | + fso = new ActiveXObject("Scripting.FileSystemObject"); | |
| 73 | + cf = fso.OpenTextFile(configFile, 1); | |
| 74 | + while (cf.AtEndOfStream != true) { | |
| 75 | + ln = cf.ReadLine(); | |
| 76 | + s = new String(ln); | |
| 77 | + if (s.search(/^m4_define\(\[libmodbus_version_major/) != -1) { | |
| 78 | + verMajor = s.substr(s.indexOf(",") + 3, 1) | |
| 79 | + } else if(s.search(/^m4_define\(\[libmodbus_version_minor/) != -1) { | |
| 80 | + verMinor = s.substr(s.indexOf(",") + 3, 1) | |
| 81 | + } else if(s.search(/^m4_define\(\[libmodbus_version_micro/) != -1) { | |
| 82 | + verMicro = s.substr(s.indexOf(",") + 3, 1) | |
| 83 | + } | |
| 84 | + } | |
| 85 | + cf.Close(); | |
| 86 | +} | |
| 87 | + | |
| 88 | +/* create the versioned file */ | |
| 89 | +function createVersionedFile(newfile, unversioned) | |
| 90 | +{ | |
| 91 | + var fso, ofi, of, ln, s; | |
| 92 | + fso = new ActiveXObject("Scripting.FileSystemObject"); | |
| 93 | + ofi = fso.OpenTextFile(unversioned, 1); | |
| 94 | + if (!testRun) { | |
| 95 | + of = fso.CreateTextFile(newfile, true); | |
| 96 | + } | |
| 97 | + while (ofi.AtEndOfStream != true) { | |
| 98 | + ln = ofi.ReadLine(); | |
| 99 | + s = new String(ln); | |
| 100 | + if (!testRun && s.search(/\@LIBMODBUS_VERSION_MAJOR\@/) != -1) { | |
| 101 | + of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MAJOR\@/, verMajor)); | |
| 102 | + } else if (!testRun && s.search(/\@LIBMODBUS_VERSION_MINOR\@/) != -1) { | |
| 103 | + of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MINOR\@/, verMinor)); | |
| 104 | + } else if (!testRun && s.search(/\@LIBMODBUS_VERSION_MICRO\@/) != -1) { | |
| 105 | + of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MICRO\@/, verMicro)); | |
| 106 | + } else if (!testRun && s.search(/\@LIBMODBUS_VERSION\@/) != -1) { | |
| 107 | + of.WriteLine(s.replace(/\@LIBMODBUS_VERSION\@/, verMajor+"."+verMinor+"."+verMicro)); | |
| 108 | + } else { | |
| 109 | + if (!testRun) | |
| 110 | + of.WriteLine(ln); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + ofi.Close(); | |
| 114 | + if (!testRun) | |
| 115 | + of.Close(); | |
| 116 | +} | |
| 117 | + | |
| 118 | + | |
| 119 | +/* | |
| 120 | + * main(), | |
| 121 | + * Execution begins here. | |
| 122 | + */ | |
| 123 | + | |
| 124 | +// Parse the command-line arguments. | |
| 125 | +for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { | |
| 126 | + var arg, opt; | |
| 127 | + arg = WScript.Arguments(i); | |
| 128 | + opt = arg.substring(0, arg.indexOf("=")); | |
| 129 | + if (opt.length == 0) | |
| 130 | + opt = arg.substring(0, arg.indexOf(":")); | |
| 131 | + if (opt.length > 0) { | |
| 132 | + if (opt == "dry-run") | |
| 133 | + testRun = strToBool(arg.substring(opt.length + 1, arg.length)); | |
| 134 | + else if (opt == "compiler") | |
| 135 | + compiler = arg.substring(opt.length + 1, arg.length); | |
| 136 | + else | |
| 137 | + error = 1; | |
| 138 | + } else if (i == 0) { | |
| 139 | + if (arg == "help") { | |
| 140 | + usage(); | |
| 141 | + WScript.Quit(0); | |
| 142 | + } | |
| 143 | + } else { | |
| 144 | + error = 1; | |
| 145 | + } | |
| 146 | +} | |
| 147 | + | |
| 148 | + | |
| 149 | +// If we fail here, it is because the user supplied an unrecognised argument. | |
| 150 | +if (error != 0) { | |
| 151 | + usage(); | |
| 152 | + WScript.Quit(error); | |
| 153 | +} | |
| 154 | + | |
| 155 | +// Read the the version. | |
| 156 | +readVersion(); | |
| 157 | +if (error != 0) { | |
| 158 | + WScript.Echo("Version discovery failed, aborting."); | |
| 159 | + WScript.Quit(error); | |
| 160 | +} | |
| 161 | + | |
| 162 | +var outVerString = baseName + " version: " + verMajor + "." + verMinor + "." + verMicro; | |
| 163 | +// WScript.Echo(outVerString); | |
| 164 | + | |
| 165 | +newfile = srcDir + "\\modbus-version.h" | |
| 166 | +createVersionedFile(newfile, srcDir + "\\modbus-version.h.in"); | |
| 167 | +if (error != 0) { | |
| 168 | + WScript.Echo("Creation of " + newfile + " failed, aborting."); | |
| 169 | + WScript.Quit(error); | |
| 170 | +} | |
| 171 | + | |
| 172 | +newfile = "modbus.dll.manifest" | |
| 173 | +createVersionedFile(newfile, "modbus.dll.manifest.in"); | |
| 174 | +if (error != 0) { | |
| 175 | + WScript.Echo("Creation of " + newfile + " failed, aborting."); | |
| 176 | + WScript.Quit(error); | |
| 177 | +} | |
| 178 | + | |
| 179 | +newfile = "config.h" | |
| 180 | +createVersionedFile(newfile, "config.h.win32"); | |
| 181 | +if (error != 0) { | |
| 182 | + WScript.Echo("Creation of " + newfile + " failed, aborting."); | |
| 183 | + WScript.Quit(error); | |
| 184 | +} | |
| 185 | + | |
| 186 | +// Display the final configuration. | |
| 187 | +var txtOut = "\nLIBMODBUS configuration completed\n"; | |
| 188 | +WScript.Echo(txtOut); | |
| 189 | + | |
| 190 | + | ... | ... |