From: nishi Date: Tue, 21 May 2024 02:41:24 +0000 (+0000) Subject: add watcom support X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3aaf07e1f16d5c130abb3c6d361e3b0f8b7a3976;p=dataworks.git add watcom support git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@47 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/Makefile b/Client/Makefile index d0b21c1..d6ed4de 100644 --- a/Client/Makefile +++ b/Client/Makefile @@ -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 diff --git a/Library/Makefile b/Library/Makefile index 461eb25..42fd89a 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -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) diff --git a/Library/database.c b/Library/database.c index 8a1f1ab..9fc9c75 100644 --- a/Library/database.c +++ b/Library/database.c @@ -38,12 +38,21 @@ 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; diff --git a/Library/dataworks.c b/Library/dataworks.c index 2399f12..b46d438 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -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 diff --git a/Library/util.c b/Library/util.c index 2ac0124..dd53f41 100644 --- a/Library/util.c +++ b/Library/util.c @@ -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 index 0000000..b7a4c58 --- /dev/null +++ b/Platforms/watcom.mk @@ -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"` diff --git a/Platforms/win32.mk b/Platforms/win32.mk index 0c6bf5c..8142e2b 100644 --- a/Platforms/win32.mk +++ b/Platforms/win32.mk @@ -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 = diff --git a/Platforms/win64.mk b/Platforms/win64.mk index ff52002..e34eea7 100644 --- a/Platforms/win64.mk +++ b/Platforms/win64.mk @@ -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 = diff --git a/common-decl.mk b/common-decl.mk index 14e7d06..e6dce64 100644 --- a/common-decl.mk +++ b/common-decl.mk @@ -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) diff --git a/common.mk b/common.mk index 9cb3001..743655e 100644 --- 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