From befd8247fcf28f722c3bc4b8b154db631d1654c9 Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 19 Jun 2024 12:25:25 +0000 Subject: [PATCH] add vbcc git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@365 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Grammar/Makefile | 2 +- Grammar/dw.l | 15 +++++++++++++++ Library/Makefile | 2 +- Library/dataworks.c | 12 ++++++++++++ Library/util.c | 6 ++++++ Makefiles/Platforms/amigaos.mk | 11 +++++++++++ Makefiles/Platforms/vbcc.mk | 21 +++++++++++++++++++++ Makefiles/Platforms/watcom.mk | 2 ++ Makefiles/common-decl.mk | 8 +++++--- 9 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 Makefiles/Platforms/amigaos.mk create mode 100644 Makefiles/Platforms/vbcc.mk diff --git a/Grammar/Makefile b/Grammar/Makefile index 99a26b5..d9edc35 100644 --- a/Grammar/Makefile +++ b/Grammar/Makefile @@ -6,7 +6,7 @@ all: dw.tab.o dw.yy.o .c.o: - $(CC) $(CFLAGS) -fPIC -c -o $@ $< + $(CC) $(CFLAGS) $(PIC) -c -o $@ $< dw.tab.c: dw.y $(YACC) $(YFLAGS) -o $@ dw.y diff --git a/Grammar/dw.l b/Grammar/dw.l index 0e08627..6d4af1d 100644 --- a/Grammar/dw.l +++ b/Grammar/dw.l @@ -37,6 +37,21 @@ extern YYSTYPE yylval; double __dw_atof(const char* str); char* __dw_strcat(const char* a, const char* b); +char* __dw_strdup(const char* a); + +#ifdef NO_STRDUP +#define strdup __dw_strdup +#endif + +#ifdef __VBCC__ +int isatty(int fd){ + return 0; +} +int fileno(FILE* fp){ + return 0; +} +#endif + char* str = NULL; void proc_esc(void){ diff --git a/Library/Makefile b/Library/Makefile index c0b4bd0..0c674e7 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -15,7 +15,7 @@ $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX): $(OBJS) $(RANLIB) $@ .c.o: - $(CC) $(CFLAGS) -DPLATFORM_M=\"$(PLATFORM_M)\" -DPLATFORM_P=\"$(PLATFORM_P)\" -fPIC -c -o $@ $< + $(CC) $(CFLAGS) -DPLATFORM_M=\"$(PLATFORM_M)\" -DPLATFORM_P=\"$(PLATFORM_P)\" $(PIC) -c -o $@ $< clean: rm -f *.o *.so *.dll *.a *.lib diff --git a/Library/dataworks.c b/Library/dataworks.c index a32078c..deb6ed4 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -54,11 +54,23 @@ const char* dataworks_platform = "Linux/" const char* dataworks_platform = "WatcomC/" #elif defined(__APPLE__) const char* dataworks_platform = "MacOSX/" +#elif defined(__VBCC__) +#undef SUPPORTED +const char* dataworks_platform = "VBCC/" #else #undef SUPPORTED const char* dataworks_platform = "Unknown/" #endif +#ifdef __VBCC__ +#ifdef AMIGA + "amiga (amiga)"; +#else + "unknown (unknown)"; +#endif +; +#else PLATFORM_M " (" PLATFORM_P ")"; +#endif extern const char* yaccver; extern const char* lexver; diff --git a/Library/util.c b/Library/util.c index 9fa4abf..fd9b813 100644 --- a/Library/util.c +++ b/Library/util.c @@ -38,8 +38,10 @@ #ifdef __MINGW32__ #include #else +#ifndef NO_UNISTD #include #endif +#endif char* __dw_strdup(const char* a) { char* str = malloc(strlen(a) + 1); @@ -73,6 +75,8 @@ bool __dw_lockfile(struct dataworks_db* db) { fseek(db->fp, 0, SEEK_SET); #if defined(__WATCOMC__) +#elif defined(__VBCC__) + #elif defined(__MINGW32__) OVERLAPPED overlap = {0}; LockFileEx(db->fp, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlap); @@ -93,6 +97,8 @@ bool __dw_unlockfile(struct dataworks_db* db) { fflush(db->fp); #if defined(__WATCOMC__) +#elif defined(__VBCC__) + #elif defined(__MINGW32__) OVERLAPPED overlap = {0}; UnlockFileEx(db->fp, 0, MAXDWORD, MAXDWORD, &overlap); diff --git a/Makefiles/Platforms/amigaos.mk b/Makefiles/Platforms/amigaos.mk new file mode 100644 index 0000000..50718de --- /dev/null +++ b/Makefiles/Platforms/amigaos.mk @@ -0,0 +1,11 @@ +# $Id$ + +VBCC_PLATFORM=kick13 +include Makefiles/Platforms/vbcc.mk +LIBS = -lmsoft +EXEC_SUFFIX= +RCLI= +SERVER= +SERVER_MODULE = hayes.o +RCLI_MODULE = hayes.o +CFLAGS += -DAMIGA diff --git a/Makefiles/Platforms/vbcc.mk b/Makefiles/Platforms/vbcc.mk new file mode 100644 index 0000000..d9ca77f --- /dev/null +++ b/Makefiles/Platforms/vbcc.mk @@ -0,0 +1,21 @@ +# $Id$ + +# THIS IS A TEMPLATE + +CC = vc +SHCC = true +AR = vlink +AR_ARGS = -r -o \$$@ +RANLIB = true +STDC99 = -c99 +PIC = +LIB_PREFIX = +LIB_SUFFIX = .dll +EXEC_SUFFIX = .$(VBCC_PLATFORM) +STATICLIB_PREFIX = +STATICLIB_SUFFIX = .a +PLATFORM_M = $(VBCC_PLATFORM) +PLATFORM_P = $(VBCC_PLATFORM) +CFLAGS += +$(VBCC_PLATFORM) -DNO_STRDUP -DNO_UNISTD -Doff_t=int64_t +DFLAGS += +$(VBCC_PLATFORM) -DNO_STRDUP -DNO_UNISTD -Doff_t=int64_t +LDFLAGS += +$(VBCC_PLATFORM) diff --git a/Makefiles/Platforms/watcom.mk b/Makefiles/Platforms/watcom.mk index e686616..68ec992 100644 --- a/Makefiles/Platforms/watcom.mk +++ b/Makefiles/Platforms/watcom.mk @@ -1,5 +1,7 @@ # $Id$ +# THIS IS A TEMPLATE + CC = owcc SHCC = true AR = wlib diff --git a/Makefiles/common-decl.mk b/Makefiles/common-decl.mk index ffa4569..d3f737c 100644 --- a/Makefiles/common-decl.mk +++ b/Makefiles/common-decl.mk @@ -8,11 +8,13 @@ LEX = lex AR_ARGS = rcs \$$@ RANLIB = ranlib WINDRES = windres -CFLAGS = -g -std=c99 -D_DEFAULT_SOURCE $(DEBUGFLAGS) +STDC99 = -std=c99 +CFLAGS = -g $(STDC99) -D_DEFAULT_SOURCE $(DEBUGFLAGS) LDFLAGS = -L`pwd`/Library $(MORE_LDFLAGS) YFLAGS = -d -t -y -LFLAGS = +LFLAGS = --nounistd LIBS = +PIC = -fPIC LIB_PREFIX = lib LIB_SUFFIX = .so STATICLIB_PREFIX = lib @@ -32,4 +34,4 @@ RCLI_MODULE = tcpip.o MD5SUM = md5sum VERSION = `cat Library/dataworks.c | grep " dataworks_version " | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?'` -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_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)" YACC="$(YACC)" LEX="$(LEX)" LFLAGS="$(LFLAGS)" YFLAGS="$(YFLAGS)" SERVER_MODULE="$(SERVER_MODULE)" SERVLINK_LIB="$(SERVLINK_LIB)" RCLI_MODULE="$(RCLI_MODULE)" RCLILINK_LIB="$(RCLILINK_LIB)" INDEP="$(INDEP)" INDEP_TO="$(INDEP_TO)" +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_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)" YACC="$(YACC)" LEX="$(LEX)" LFLAGS="$(LFLAGS)" YFLAGS="$(YFLAGS)" SERVER_MODULE="$(SERVER_MODULE)" SERVLINK_LIB="$(SERVLINK_LIB)" RCLI_MODULE="$(RCLI_MODULE)" RCLILINK_LIB="$(RCLILINK_LIB)" INDEP="$(INDEP)" INDEP_TO="$(INDEP_TO)" PIC="$(PIC)" -- 2.43.0