From 34d5a95e7d8a8708ba51f57dc094802c10e892ef Mon Sep 17 00:00:00 2001 From: Nishi Date: Tue, 19 Nov 2024 07:54:58 +0000 Subject: [PATCH] compiles for windows ce git-svn-id: file:///raid/svn-personal/tewi/trunk@416 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Platform/wince-arm.mk | 16 ++++++++++ Server/config.c | 2 ++ Server/main.c | 6 ++-- Server/module.c | 8 ++++- Server/tewi.rc | 2 +- vc4arm.sh | 70 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 Platform/wince-arm.mk create mode 100644 vc4arm.sh diff --git a/Platform/wince-arm.mk b/Platform/wince-arm.mk new file mode 100644 index 0000000..bf0dca0 --- /dev/null +++ b/Platform/wince-arm.mk @@ -0,0 +1,16 @@ +# $Id$ + +PREFIX = C:/Tewi + +PLATFORM_IDENT = WINDOWS +CC = ../vc4arm.sh +AR = lib +AR_FLAGS = /nologo /out: +CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC +LDFLAGS = +LIBS = +EXEC = .exe +STATIC = lib +LIBSUF = .dll +OBJ = obj +PREOBJS = vc6.res diff --git a/Server/config.c b/Server/config.c index 8fc335b..0b0641c 100644 --- a/Server/config.c +++ b/Server/config.c @@ -392,7 +392,9 @@ int tw_config_read(const char* path) { cm_log("Config", "Missing path at line %d", ln); stop = 1; } else { +#ifndef WINCE chdir(r[1]); +#endif free(config.server_root); config.server_root = cm_strdup(r[1]); } diff --git a/Server/main.c b/Server/main.c index 9d22d6d..8dd4f0e 100644 --- a/Server/main.c +++ b/Server/main.c @@ -100,7 +100,7 @@ char tw_server[2048]; int startup(int argc, char** argv); -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || (defined(_MSC_VER) && !defined(WINCE)) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) char* get_registry(const char* main, const char* sub) { DWORD bufsize = 512; HKEY handle; @@ -761,7 +761,7 @@ void thread_stuff(void* pargs) { int startup(int argc, char** argv) { int i; char* r; -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || (defined(_MSC_VER) && !defined(WINCE)) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__) char* confpath = cm_strdup(PREFIX "/etc/tewi.conf"); char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir"); if(regpath != NULL) { @@ -848,7 +848,7 @@ int startup(int argc, char** argv) { #if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); -#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__) +#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__) && !defined(WINCE) SetConsoleTitle(tw_server); #endif return -1; diff --git a/Server/module.c b/Server/module.c index a3e60e5..bb9eb9a 100644 --- a/Server/module.c +++ b/Server/module.c @@ -51,7 +51,9 @@ void* tw_module_load(const char* path) { #elif defined(__NETWARE__) unsigned int* hnd = malloc(sizeof(*hnd)); #endif +#ifndef WINCE chdir(config.server_root); +#endif #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #ifdef __OS2__ if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) { @@ -66,7 +68,7 @@ void* tw_module_load(const char* path) { } lib = (void*)hnd; #else - lib = LoadLibraryA(path); + lib = LoadLibrary(path); #endif #else lib = dlopen(path, RTLD_LAZY); @@ -74,7 +76,9 @@ void* tw_module_load(const char* path) { if(lib == NULL) { cm_log("Module", "Could not load %s", path); } +#ifndef WINCE chdir(p); +#endif free(p); return lib; } @@ -91,6 +95,8 @@ void* tw_module_symbol(void* mod, const char* sym) { return ret; #elif defined(__NETWARE__) return ImportSymbol(*(unsigned int*)mod, sym); +#elif defined(WINCE) + return GetProcAddressW(mod, sym); #else return GetProcAddress(mod, sym); #endif diff --git a/Server/tewi.rc b/Server/tewi.rc index 7766e8a..c0c28fa 100644 --- a/Server/tewi.rc +++ b/Server/tewi.rc @@ -1,4 +1,4 @@ -#include +#include #include "tw_version.h" #include "../config.h" diff --git a/vc4arm.sh b/vc4arm.sh new file mode 100644 index 0000000..7a3e0a3 --- /dev/null +++ b/vc4arm.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# $Id$ +# Wrapper for CL. VC6 sucks. + +outfile="a.out" +dowhat="" +options="/I../WCECompat /I../VC6Compat /D_NTSDK /Ddouble=long /DNEED_DIRECT /DARM /D_ARM_ /D_M_ARM /DARMV4I /D_ARMV4I_ /DWINCE /DUNICODE" +obj=0 +win=0 +source="" +libraries="" +link="" + +for i in "$@"; do + if [ "$i" = "-o" ]; then + dowhat="output" + elif [ "$i" = "-I" ]; then + dowhat="include" + elif [ "$i" = "-c" ]; then + options="$options /c" + obj=1 + elif [ "$i" = "-fPIC" ]; then + : + elif [ "$i" = "-g" ]; then + : + elif [ "$i" = "-std=c99" ]; then + : + elif [ "$i" = "-shared" ]; then + options="$options /LD" + elif [ "$i" = "-mwindows" ]; then + win=1 + elif [ "`echo "$i" | grep -Eo "^-D"`" = "-D" ]; then + options="$options /`echo "$i" | sed "s/^-//g"`" + elif [ "`echo "$i" | grep -Eo "^-l"`" = "-l" ]; then + if [ "$i" = "-luser32" ]; then + libraries="$libraries gdi32.lib" + fi + if [ "$i" = "-lws2_32" ]; then + libraries="$libraries ws2.lib" + else + libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib" + fi + elif [ "$dowhat" = "output" ]; then + dowhat="" + outfile="$i" + elif [ "$dowhat" = "include" ]; then + dowhat="" + options="$options /I$i" + elif [ ! "`echo "$i" | grep -Eo "^."`" = "-" ]; then + source="$source $i" + fi +done +if [ "$obj" = "1" ]; then + options="$options /Fo$outfile" +else + options="$options /Fe$outfile" +fi +if [ ! "$libraries" = "" ]; then + link="/link /subsystem:windowsce $libraries /libpath:../WCECompat wcecompat.lib" +else + link="/link /subsystem:windowsce" +fi +if [ "$obj" = "0" ]; then + if [ "$win" = "1" ]; then + link="$link /SUBSYSTEM:windowsce" + fi +fi +construct="clarm /nologo $options $source $link" +echo "Run: $construct" +$construct -- 2.43.0