From fd0bc0fb650df8f7c67a96c966037038879dd494 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 19 Oct 2021 13:12:18 +0100 Subject: [PATCH] Add OpenWatcom 2 --- CMake-OpenWatcom2/.clang-format | 66 +++++++++++ CMake-OpenWatcom2/.idea/.gitignore | 9 ++ CMake-OpenWatcom2/.idea/.name | 1 + CMake-OpenWatcom2/.idea/CMake-OpenWatcom2.iml | 2 + CMake-OpenWatcom2/.idea/custom-compiler.xml | 7 ++ CMake-OpenWatcom2/.idea/misc.xml | 4 + CMake-OpenWatcom2/.idea/modules.xml | 8 ++ CMake-OpenWatcom2/CMakeLists.txt | 6 + CMake-OpenWatcom2/README.md | 66 +++++++++++ CMake-OpenWatcom2/main.c | 6 + CMake-OpenWatcom2/openwatcom2.yaml | 105 ++++++++++++++++++ README.md | 8 +- configs/OpenWatcom 2/README.md | 66 +++++++++++ configs/OpenWatcom 2/openwatcom2.yaml | 105 ++++++++++++++++++ 14 files changed, 458 insertions(+), 1 deletion(-) create mode 100755 CMake-OpenWatcom2/.clang-format create mode 100755 CMake-OpenWatcom2/.idea/.gitignore create mode 100644 CMake-OpenWatcom2/.idea/.name create mode 100755 CMake-OpenWatcom2/.idea/CMake-OpenWatcom2.iml create mode 100755 CMake-OpenWatcom2/.idea/custom-compiler.xml create mode 100755 CMake-OpenWatcom2/.idea/misc.xml create mode 100755 CMake-OpenWatcom2/.idea/modules.xml create mode 100755 CMake-OpenWatcom2/CMakeLists.txt create mode 100644 CMake-OpenWatcom2/README.md create mode 100755 CMake-OpenWatcom2/main.c create mode 100755 CMake-OpenWatcom2/openwatcom2.yaml create mode 100644 configs/OpenWatcom 2/README.md create mode 100755 configs/OpenWatcom 2/openwatcom2.yaml diff --git a/CMake-OpenWatcom2/.clang-format b/CMake-OpenWatcom2/.clang-format new file mode 100755 index 0000000..f0fb4b4 --- /dev/null +++ b/CMake-OpenWatcom2/.clang-format @@ -0,0 +1,66 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +AlignOperands: DontAlign +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 4 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PointerAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 0 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never diff --git a/CMake-OpenWatcom2/.idea/.gitignore b/CMake-OpenWatcom2/.idea/.gitignore new file mode 100755 index 0000000..8ed479c --- /dev/null +++ b/CMake-OpenWatcom2/.idea/.gitignore @@ -0,0 +1,9 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +/deployment.xml diff --git a/CMake-OpenWatcom2/.idea/.name b/CMake-OpenWatcom2/.idea/.name new file mode 100644 index 0000000..f0fef4c --- /dev/null +++ b/CMake-OpenWatcom2/.idea/.name @@ -0,0 +1 @@ +CMake-OpenWatcom2 diff --git a/CMake-OpenWatcom2/.idea/CMake-OpenWatcom2.iml b/CMake-OpenWatcom2/.idea/CMake-OpenWatcom2.iml new file mode 100755 index 0000000..f08604b --- /dev/null +++ b/CMake-OpenWatcom2/.idea/CMake-OpenWatcom2.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/CMake-OpenWatcom2/.idea/custom-compiler.xml b/CMake-OpenWatcom2/.idea/custom-compiler.xml new file mode 100755 index 0000000..80acd1b --- /dev/null +++ b/CMake-OpenWatcom2/.idea/custom-compiler.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/CMake-OpenWatcom2/.idea/misc.xml b/CMake-OpenWatcom2/.idea/misc.xml new file mode 100755 index 0000000..79b3c94 --- /dev/null +++ b/CMake-OpenWatcom2/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/CMake-OpenWatcom2/.idea/modules.xml b/CMake-OpenWatcom2/.idea/modules.xml new file mode 100755 index 0000000..6e7bf54 --- /dev/null +++ b/CMake-OpenWatcom2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CMake-OpenWatcom2/CMakeLists.txt b/CMake-OpenWatcom2/CMakeLists.txt new file mode 100755 index 0000000..bcb0271 --- /dev/null +++ b/CMake-OpenWatcom2/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.21) +project(CMake-OpenWatcom2 C) + +set(CMAKE_C_STANDARD 90) + +add_executable(CMake-OpenWatcom2 main.c) diff --git a/CMake-OpenWatcom2/README.md b/CMake-OpenWatcom2/README.md new file mode 100644 index 0000000..727fa7a --- /dev/null +++ b/CMake-OpenWatcom2/README.md @@ -0,0 +1,66 @@ +## Custom compiler definitions for CLion and OpenWatcom 2 + +This compiler definition allows you to use OpenWatcom 2 from Linux or Windows. + +## Supported platforms + +- Windows NT (x86) +- 16-bit OS/2 +- 32-bit OS/2 +- DOS +- 32-bit DOS (using DOS/4GW) +- Linux (x86) + +## Unsupported platforms + +- 16-bit Windows: don't know how to make it work, patches welcome +- Windows for MIPS, PowerPC or Alpha: the compilers are there, but the libraries are not made, contribute to [Open Watcom 2](https://github.com/open-watcom/open-watcom-v2) to make it possible +- QNX: headers and libraries are copyright of BlackBerry Limited, ping them for opensourcing them (as they were for QNX 2 and QNX 4 probably not of much interest to them anymore?) +- NetWare: libraries are there but headers need to be installed separately, ping Micro Focus International for opensourcing them (as they abandoned NetWare long ago) +- Others: Watcom supported many targets over the ages and I don't know which others may just need some care to make them work + +## Instructions + +The most important step is to ensure that Watcom binaries are in the path. This depends on your exact installation but usually on Windows it is `C:\WATCOM\BINNT64` and on Linux it is `/opt/watcom/binl64`. Until JetBrains allow to specify APPENDING path members for a specific toolchain (tried with Environment Variables, no go) this is a must. + +After this is done you need to add the compilers in `Settings -> Build, Execution, Deployment -> Toolchains` and set up at least the C compiler and C++ compiler (they're the same) and at least in Windows (as there's no system `make` to make CLion happy) also select `wmake` (`wmake.exe`). + +Compiler for 16-bit targets: `wcl` or `wcl.exe` +Compiler for 32-bit targets: `wcl386` or `wcl386.exe` +Compiler for Alpha targets: `wclaxp` or `wclaxp.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* +Compiler for MIPS targets: `wclmps` or `wclmps.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* +Compiler for PowerPC targets: `wclppc` or `wclppc.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* + +Then, for the project, you need to go `Settings -> Build, Execution, Deployment -> CMake` and create the appropriate targets. + +In each target set the following environment for Windows (change paths appropriately if installed in another location): + +- `WATCOM=C:\WATCOM` +- `INCLUDE=C:\WATCOM\H\;C:\WATCOM\H\NT\;C:\WATCOM\H\NT\DIRECTX\;C:\WATCOM\H\NT\DDK\;%INCLUDE%` + +or in Linux (change paths appropriately if installed in another location): + +- `WATCOM=/opt/watcom` +- `INCLUDE=/opt/watcom/lh` + +then in CMake options you need to set: `-DCMAKE_SYSTEM_NAME= -DCMAKE_SYSTEM_PROCESSOR= -G "Watcom WMake"` + +where `` is: + +- `DOS` for DOS +- `OS2` for OS/2 +- `Windows` for Windows and Windows NT +- `Linux` for Linux + +and `` is: + +- `I86` for 16-bit +- `I386` for 32-bit +- none for 32-bit or the others *(untested)* + +## Final notes + +The preprocessor macros have been a bestguess and may be severely incomplete, patches welcome! + +2021 - [Natalia Portillo](https://github.com/claunia) +Many thanks to [Jiří Malák](https://github.com/jmalak) for keeping OpenWatcom alive! diff --git a/CMake-OpenWatcom2/main.c b/CMake-OpenWatcom2/main.c new file mode 100755 index 0000000..0923337 --- /dev/null +++ b/CMake-OpenWatcom2/main.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, World!\n"); + return 0; +} diff --git a/CMake-OpenWatcom2/openwatcom2.yaml b/CMake-OpenWatcom2/openwatcom2.yaml new file mode 100755 index 0000000..4b8a251 --- /dev/null +++ b/CMake-OpenWatcom2/openwatcom2.yaml @@ -0,0 +1,105 @@ + +compilers: + + - description: OpenWatcom 32-bit OS/2 target + match-args: "-bt=os2" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os2" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __OS2__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit DOS target + match-args: "-bt=dos" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os2" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define _DOS 1 +#define MSDOS 1 +#define __DOS__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit Windows target + match-args: "-bt=nt" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/nt" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __NT__ 1 +#define __WINDOWS_386__ 1 +#define _WIN32 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 16-bit OS/2 target + match-args: "-bt=os2" + match-compiler-exe: "(.*/)?wcl(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os21x" + defines-text: " +#define __X86__ 1 +#define __I86__ 1 +#define M_I86 1 +#define _M_I86 1 +#define _M_IX86 0 +#define __OS2__ 1 +#define __LARGE__ 1 +#define M_I86LM 1 +#define _M_I86LM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom DOS target + match-args: "-bt=dos" + match-compiler-exe: "(.*/)?wcl(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h" + defines-text: " +#define __X86__ 1 +#define __I86__ 1 +#define M_I86 1 +#define _M_I86 1 +#define _M_IX86 0 +#define __DOS__ 1 +#define _DOS 1 +#define MSDOS 1 +#define __LARGE__ 1 +#define M_I86LM 1 +#define _M_I86LM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit Linux target + match-args: "-bt=linux" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/nt" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __LINUX__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" diff --git a/README.md b/README.md index 132bab7..036a891 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,10 @@ This repository contains: * Compiler definition file: [custom-compiler-sdcc-stm8.yaml](CCMake-SDCC/custom-compiler-sdcc-stm8.yaml) * Host Platforms: Windows, Linux, Mac * Target Platform: STM8 MCU - \ No newline at end of file +* [CMake-OpenWatcom2](CMake-OpenWatcom2) + * Build System: [CMake](https://cmake.org/) + * Compiler: [Open Watcom 2](https://github.com/open-watcom/open-watcom-v2) + * Compiler definition file: [openwatcom2.yaml](CMake-OpenWatcom2/openwatcom2.yaml) + * Host Platforms: Windows, Linux + * Target Platform: Windows NT, DOS, 32-bit DOS (DOS/4GW), 16-bit OS/2, 32-bit OS/2, Linux/x86 + * Contributed by: [Natalia Portillo](https://github.com/claunia) diff --git a/configs/OpenWatcom 2/README.md b/configs/OpenWatcom 2/README.md new file mode 100644 index 0000000..727fa7a --- /dev/null +++ b/configs/OpenWatcom 2/README.md @@ -0,0 +1,66 @@ +## Custom compiler definitions for CLion and OpenWatcom 2 + +This compiler definition allows you to use OpenWatcom 2 from Linux or Windows. + +## Supported platforms + +- Windows NT (x86) +- 16-bit OS/2 +- 32-bit OS/2 +- DOS +- 32-bit DOS (using DOS/4GW) +- Linux (x86) + +## Unsupported platforms + +- 16-bit Windows: don't know how to make it work, patches welcome +- Windows for MIPS, PowerPC or Alpha: the compilers are there, but the libraries are not made, contribute to [Open Watcom 2](https://github.com/open-watcom/open-watcom-v2) to make it possible +- QNX: headers and libraries are copyright of BlackBerry Limited, ping them for opensourcing them (as they were for QNX 2 and QNX 4 probably not of much interest to them anymore?) +- NetWare: libraries are there but headers need to be installed separately, ping Micro Focus International for opensourcing them (as they abandoned NetWare long ago) +- Others: Watcom supported many targets over the ages and I don't know which others may just need some care to make them work + +## Instructions + +The most important step is to ensure that Watcom binaries are in the path. This depends on your exact installation but usually on Windows it is `C:\WATCOM\BINNT64` and on Linux it is `/opt/watcom/binl64`. Until JetBrains allow to specify APPENDING path members for a specific toolchain (tried with Environment Variables, no go) this is a must. + +After this is done you need to add the compilers in `Settings -> Build, Execution, Deployment -> Toolchains` and set up at least the C compiler and C++ compiler (they're the same) and at least in Windows (as there's no system `make` to make CLion happy) also select `wmake` (`wmake.exe`). + +Compiler for 16-bit targets: `wcl` or `wcl.exe` +Compiler for 32-bit targets: `wcl386` or `wcl386.exe` +Compiler for Alpha targets: `wclaxp` or `wclaxp.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* +Compiler for MIPS targets: `wclmps` or `wclmps.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* +Compiler for PowerPC targets: `wclppc` or `wclppc.exe` *DOESN'T INCLUDE C OR C++ LIBRARIES* + +Then, for the project, you need to go `Settings -> Build, Execution, Deployment -> CMake` and create the appropriate targets. + +In each target set the following environment for Windows (change paths appropriately if installed in another location): + +- `WATCOM=C:\WATCOM` +- `INCLUDE=C:\WATCOM\H\;C:\WATCOM\H\NT\;C:\WATCOM\H\NT\DIRECTX\;C:\WATCOM\H\NT\DDK\;%INCLUDE%` + +or in Linux (change paths appropriately if installed in another location): + +- `WATCOM=/opt/watcom` +- `INCLUDE=/opt/watcom/lh` + +then in CMake options you need to set: `-DCMAKE_SYSTEM_NAME= -DCMAKE_SYSTEM_PROCESSOR= -G "Watcom WMake"` + +where `` is: + +- `DOS` for DOS +- `OS2` for OS/2 +- `Windows` for Windows and Windows NT +- `Linux` for Linux + +and `` is: + +- `I86` for 16-bit +- `I386` for 32-bit +- none for 32-bit or the others *(untested)* + +## Final notes + +The preprocessor macros have been a bestguess and may be severely incomplete, patches welcome! + +2021 - [Natalia Portillo](https://github.com/claunia) +Many thanks to [Jiří Malák](https://github.com/jmalak) for keeping OpenWatcom alive! diff --git a/configs/OpenWatcom 2/openwatcom2.yaml b/configs/OpenWatcom 2/openwatcom2.yaml new file mode 100755 index 0000000..4b8a251 --- /dev/null +++ b/configs/OpenWatcom 2/openwatcom2.yaml @@ -0,0 +1,105 @@ + +compilers: + + - description: OpenWatcom 32-bit OS/2 target + match-args: "-bt=os2" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os2" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __OS2__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit DOS target + match-args: "-bt=dos" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os2" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define _DOS 1 +#define MSDOS 1 +#define __DOS__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit Windows target + match-args: "-bt=nt" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/nt" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __NT__ 1 +#define __WINDOWS_386__ 1 +#define _WIN32 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 16-bit OS/2 target + match-args: "-bt=os2" + match-compiler-exe: "(.*/)?wcl(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/os21x" + defines-text: " +#define __X86__ 1 +#define __I86__ 1 +#define M_I86 1 +#define _M_I86 1 +#define _M_IX86 0 +#define __OS2__ 1 +#define __LARGE__ 1 +#define M_I86LM 1 +#define _M_I86LM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom DOS target + match-args: "-bt=dos" + match-compiler-exe: "(.*/)?wcl(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h" + defines-text: " +#define __X86__ 1 +#define __I86__ 1 +#define M_I86 1 +#define _M_I86 1 +#define _M_IX86 0 +#define __DOS__ 1 +#define _DOS 1 +#define MSDOS 1 +#define __LARGE__ 1 +#define M_I86LM 1 +#define _M_I86LM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64" + - description: OpenWatcom 32-bit Linux target + match-args: "-bt=linux" + match-compiler-exe: "(.*/)?wcl386(\\.exe)?" + include-dirs: "${compiler-exe-dir}/../h ${compiler-exe-dir}/../h/nt" + defines-text: " +#define __X86__ 1 +#define __386__ 1 +#define M_I386 1 +#define _M_I386 1 +#define _M_IX86 500 +#define __LINUX__ 1 +#define __FLAT__ 1 +#define M_386FM 1 +#define _M_386FM 1 +#define __WATCOMC__ 1280 +#define _INTEGRAL_MAX_BITS 64"