]> Nishi Git Mirror - dataworks.git/commitdiff
add watcom support
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Tue, 21 May 2024 02:41:24 +0000 (02:41 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Tue, 21 May 2024 02:41:24 +0000 (02:41 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@47 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/Makefile
Library/Makefile
Library/database.c
Library/dataworks.c
Library/util.c
Platforms/watcom.mk [new file with mode: 0644]
Platforms/win32.mk
Platforms/win64.mk
common-decl.mk
common.mk

index d0b21c10fb2053ac233ffd3760b4754bfc742690..d6ed4de7e3eaf21cd797b2367d80e3cd0e63bb58 100644 (file)
@@ -7,11 +7,11 @@ OBJS = main.o
 
 all: dataworks$(EXEC_SUFFIX)
 
-dataworks$(EXEC_SUFFIX): $(OBJS)
-       $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
+dataworks$(EXEC_SUFFIX): $(OBJS) ../Library/*.o
+       $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)  ../Library/*.o
 
 .c.o:
        $(CC) -I../Library $(CFLAGS) -c -o $@ $<
 
 clean:
-       rm -f *.o dataworks *.exe
+       rm -f *.o dataworks *.exe *.dos *.dos4g
index 461eb25fa3884b3fb4e2db1cde84ab66db321528..42fd89aa859486ead8c2e46ca38de395c3ce4968 100644 (file)
@@ -8,7 +8,7 @@ OBJS = parser.o database.o util.o dataworks.o
 all: $(LIB_PREFIX)dataworks$(LIB_SUFFIX) $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
 
 $(LIB_PREFIX)dataworks$(LIB_SUFFIX): $(OBJS)
-       $(CC) -shared $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+       $(SHCC) -shared $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
 
 $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX): $(OBJS)
        $(AR) rcs $@ $(OBJS)
index 8a1f1ab0941b8d51b261e7f61e04fc8051c08563..9fc9c75671bd236a39431fad17a71da08ef7fa1a 100644 (file)
 
 const char sig[3] = {0x7f, 'D', 'W'};
 
+#ifdef M_I86
+#define BUFSIZE 128
+#else
+#endif
+
 int dataworks_database_create(const char* fname) {
        FILE* f = fopen(fname, "wb");
        if(f == NULL) {
                return 1;
        }
+#ifdef BUFSIZE
+       uint8_t nul[BUFSIZE];
+#else
        uint8_t nul[4096];
+#endif
        int i;
        fwrite(sig, 1, 3, f);
        nul[0] = 0;
@@ -51,13 +60,23 @@ int dataworks_database_create(const char* fname) {
        fwrite(nul, 1, 2, f);
        uint64_t t = time(NULL);
        __dw_big_endian(t, uint64_t, fwrite(__converted_ptr, 1, 8, f));
-       for(i = 0; i < 4096; i++) nul[i] = 0;
+       for(i = 0; i < 16; i++) nul[i] = 0;
        for(i = 0; i < 256; i++) {
                fwrite(nul, 1, 1, f);
                fwrite(nul, 1, 8, f);
                fwrite(nul, 1, 1, f);
+               int j;
+#ifdef BUFSIZE
+               for(j = 0; j < 256 / BUFSIZE; j++){
+                       fwrite(nul, 1, BUFSIZE, f);
+               }
+               for(j = 0; j < 4096 / BUFSIZE; j++){
+                       fwrite(nul, 1, BUFSIZE, f);
+               }
+#else
                fwrite(nul, 1, 256, f);
                fwrite(nul, 1, 4096, f);
+#endif
        }
        fclose(f);
        return 0;
index 2399f12131c247f20458ebcf56b86b5b18f7fa7f..b46d43830bafd52bcdc308586ccaef0e7f0e3f52 100644 (file)
@@ -37,6 +37,8 @@ const char* dataworks_platform = "Windows/"
 const char* dataworks_platform = "NetBSD/"
 #elif defined(__linux__)
 const char* dataworks_platform = "Linux/"
+#elif defined(__WATCOMC__)
+const char* dataworks_platform = "WatcomC/"
 #else
 const char* dataworks_platform = "Unknown/"
 #endif
index 2ac0124219f97ffc28f5b16330f65599db06c391..dd53f41bbc173580d5a4b8604a093b4510d2de5c 100644 (file)
@@ -49,7 +49,9 @@ bool __dw_strcaseequ(const char* a, const char* b) {
 bool __dw_lockfile(FILE* fp) {
        off_t off = ftell(fp);
        fseek(fp, 0, SEEK_SET);
-#ifdef __MINGW32__
+#if defined(DOS)
+
+#elif defined(__MINGW32__)
        OVERLAPPED overlap = {0};
        LockFileEx(fp, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlap);
 #else
@@ -62,7 +64,9 @@ bool __dw_lockfile(FILE* fp) {
 bool __dw_unlockfile(FILE* fp) {
        off_t off = ftell(fp);
        fseek(fp, 0, SEEK_SET);
-#ifdef __MINGW32__
+#if defined(DOS)
+
+#elif defined(__MINGW32__)
        OVERLAPPED overlap = {0};
        UnlockFileEx(fp, 0, MAXDWORD, MAXDWORD, &overlap);
 #else
diff --git a/Platforms/watcom.mk b/Platforms/watcom.mk
new file mode 100644 (file)
index 0000000..b7a4c58
--- /dev/null
@@ -0,0 +1,14 @@
+CC = WATCOM=$$WATCOM INCLUDE=$$WATCOM/h PATH=$$PATH:$$WATCOM/binl64 owcc
+SHCC = /bin/true
+AR = /bin/true
+RANLIB = /bin/true
+LIB_PREFIX =
+LIB_SUFFIX = .dll
+EXEC_SUFFIX = .$(WATCOM_PLATFORM)
+STATICLIB_PREFIX =
+STATICLIB_SUFFIX = .a
+PLATFORM_M = $(WATCOM_PLATFORM)
+PLATFORM_P = $(WATCOM_PLATFORM)
+CFLAGS += -DDOS -b $(WATCOM_PLATFORM)
+LDFLAGS += -b $(WATCOM_PLATFORM)
+LINK_LIB = `find Library -name "*.o"`
index 0c6bf5c0d7ab333d0d0e4fac0f5460b836afcc4b..8142e2b0fc3c89dfdcd0a10c2f090486fef9189c 100644 (file)
@@ -1,4 +1,5 @@
 CC = i686-w64-mingw32-gcc
+SHCC = i686-w64-mingw32-gcc
 AR = i686-w64-mingw32-ar
 RANLIB = i686-w64-mingw32-ranlib
 LIB_PREFIX =
index ff52002c05ab25dbbda95e6912d11e4d064e1fdb..e34eea71068e6a2332630386c937c5991c4ed853 100644 (file)
@@ -1,4 +1,5 @@
 CC = x86_64-w64-mingw32-gcc
+SHCC = x86_64-w64-mingw32-gcc
 AR = x86_64-w64-mingw32-ar
 RANLIB = x86_64-w64-mingw32-ranlib
 LIB_PREFIX =
index 14e7d06b8ebaed6272aa97f52bffb48380285eb6..e6dce6489417949ca9a0ce9e84c7dab314434716 100644 (file)
@@ -1,6 +1,7 @@
 # $Id$
 
 CC = cc
+SHCC = cc
 AR = ar
 RANLIB = ranlib
 CFLAGS = -std=c99 -D_DEFAULT_SOURCE
@@ -12,4 +13,5 @@ STATICLIB_PREFIX = lib
 STATICLIB_SUFFIX = .a
 EXEC_SUFFIX =
 PLATFORM_M = `uname -m`
-PLATFORM_P = `uname -p`
+PLATFORM_P = `uname -p | sed -E "s/[ \\(\\)]/-/g"`
+LINK_LIB = ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
index 9cb30015b5c7708a0e391b080a1c5f1abc2abf78..743655e7c3a71f57cd657385a33b5fc30501015b 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -1,6 +1,6 @@
 # $Id$
 
-COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)"
+COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)" SHCC="$(SHCC)" LINK_LIN="$(LINK_LIB)"
 
 .PHONY: all no-doc replace format clean ./Library ./Client ./Document archive archive-prepare archive-cleanup archive-targz archive-zip