diff options
| author | peter <peter@pmikkelsen.com> | 2026-10-08 19:22:16 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-10-08 19:22:16 +0000 |
| commit | 58afb03f7082b355f2c317c9acb60e48a86d6eec (patch) | |
| tree | 6ddc5c2e5c1e126bd89650bbe47856dc3ae9fe73 /src | |
| parent | 0a81016dabf9e463d4d21853115c81b9dba8059d (diff) | |
Start working on support for compiling on windows using msys2.
FossilOrigin-Name: d0b8a592f04b7c438aff01694ef262cef67b71da7625bf7415c1e61ff22d8a63
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 1 | ||||
| -rw-r--r-- | src/bin/Makefile.am | 2 | ||||
| -rw-r--r-- | src/bin/aplwc_repl.h | 3 | ||||
| -rw-r--r-- | src/bin/main.c | 2 | ||||
| -rw-r--r-- | src/include/Makefile.am | 8 | ||||
| -rw-r--r-- | src/include/os.h | 54 | ||||
| -rw-r--r-- | src/include/os/windows.h | 25 | ||||
| -rw-r--r-- | src/include/os/windows_main.h | 20 | ||||
| -rw-r--r-- | src/include/os_main.h | 31 | ||||
| -rw-r--r-- | src/lib/Makefile.am | 2 | ||||
| -rw-r--r-- | src/os/Makefile.am | 11 | ||||
| -rw-r--r-- | src/os/os.c | 24 | ||||
| -rw-r--r-- | src/os/os_main.c | 24 | ||||
| -rw-r--r-- | src/os/windows.c | 25 | ||||
| -rw-r--r-- | src/os/windows_main.c | 26 | ||||
| -rw-r--r-- | src/tools/Makefile.am | 8 | ||||
| -rw-r--r-- | src/tools/genboot.c | 5 | ||||
| -rw-r--r-- | src/tools/genunicode.c | 8 |
18 files changed, 263 insertions, 16 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b4cd291..92b080f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ include src/bin/Makefile.am include src/include/Makefile.am include src/lib/Makefile.am +include src/os/Makefile.am include src/tools/Makefile.am include src/unicode/Makefile.am diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index e4d2204..4ae24a6 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -5,4 +5,4 @@ aplwc_SOURCES = \ src/bin/main.c \ src/bin/util.c -aplwc_LDADD = libaplwc.la +aplwc_LDADD = libaplwc.la libos.la libosmain.la diff --git a/src/bin/aplwc_repl.h b/src/bin/aplwc_repl.h index 6fb4415..6d01de1 100644 --- a/src/bin/aplwc_repl.h +++ b/src/bin/aplwc_repl.h @@ -20,6 +20,9 @@ #ifndef APLWC_REPL_H #define APLWC_REPL_H +#include <os.h> +#include <os_main.h> + #include <assert.h> #include <limits.h> #include <stdint.h> diff --git a/src/bin/main.c b/src/bin/main.c index 5242cd5..04bb13a 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -79,7 +79,7 @@ my_setup_failsim(enum aplwc_failsim_parameter p, unsigned long def) } int -main(int argc, char *argv[]) +portable_main(int argc, char *argv[]) { struct aplwc_fns fns; struct aplwc *aplwc; diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 3f082fb..99326ea 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -1,2 +1,8 @@ +OS_HS = \ + src/include/os/windows.h + include_HEADERS += src/include/aplwc.h -noinst_HEADERS += src/include/aplwc_macros.h +noinst_HEADERS += src/include/aplwc_macros.h src/include/os.h $(OS_HS) + +src/include/os.h: $(OS_HS) + diff --git a/src/include/os.h b/src/include/os.h new file mode 100644 index 0000000..a56b79d --- /dev/null +++ b/src/include/os.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef OS_H +#define OS_H + +#include <config.h> + +enum OS { + OS_Windows, + OS_Unknown +}; + +#if BUILD_TARGET + +#ifdef BUILD_OS_WINDOWS +#define OS OS_Windows +#else +#error "Unexpected build os" +#endif + +#else + +#ifdef HOST_OS_WINDOWS +#define OS OS_Windows +#else +#error "Unexpected host os" +#endif + +#endif + +#if OS == OS_Windows +#include <os/windows.h> +#endif + +int getline(char **, size_t *, void *); + +#endif /* OS_H */ diff --git a/src/include/os/windows.h b/src/include/os/windows.h new file mode 100644 index 0000000..7d12e12 --- /dev/null +++ b/src/include/os/windows.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <stddef.h> +#include <stdio.h> +#include <assert.h> +#include <setjmp.h> +#include <stdlib.h> +#include <string.h> diff --git a/src/include/os/windows_main.h b/src/include/os/windows_main.h new file mode 100644 index 0000000..fad4151 --- /dev/null +++ b/src/include/os/windows_main.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +int main(int, char **); diff --git a/src/include/os_main.h b/src/include/os_main.h new file mode 100644 index 0000000..1aa3d55 --- /dev/null +++ b/src/include/os_main.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef OS_MAIN_H +#define OS_MAIN_H + +#if OS == OS_Windows +#include <os/windows_main.h> +#else +#error "Did you include <os.h> before including <os_main.h>?" /* There may also be a missing case */ +#endif + +int portable_main(int, char **); + +#endif /* OS_MAIN_H */ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index b0f60f8..6a526e3 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES += libaplwc.la libaplwc_la_SOURCES = \ + src/os/os.c \ src/lib/aplwc_internal.h \ src/lib/eval.c \ src/lib/main.c \ @@ -11,6 +12,7 @@ libaplwc_la_SOURCES = \ src/lib/syntax.c \ src/lib/unicode.c +libaplwc_la_LIBADD = libos.la libaplwc_la_LDFLAGS = -version-info 0:0:0 EXTRA_DIST += src/lib/boot.aplwc diff --git a/src/os/Makefile.am b/src/os/Makefile.am new file mode 100644 index 0000000..46d9edf --- /dev/null +++ b/src/os/Makefile.am @@ -0,0 +1,11 @@ +noinst_LTLIBRARIES = libos.la libosmain.la + +libos_la_SOURCES = src/os/os.c +libos_la_LDFLAGS = -static + +libosmain_la_SOURCES = src/os/os_main.c +libosmain_la_LDFLAGS = -static + +src/os/os.c: src/os/windows.c + +src/os/os_main.c: src/os/windows_main.c diff --git a/src/os/os.c b/src/os/os.c new file mode 100644 index 0000000..2c4fcc6 --- /dev/null +++ b/src/os/os.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <os.h> + +#if OS == OS_Windows +#include "windows.c" +#endif diff --git a/src/os/os_main.c b/src/os/os_main.c new file mode 100644 index 0000000..1d35a78 --- /dev/null +++ b/src/os/os_main.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <os_main.h> + +#if OS == OS_Windows +#include "windows_main.c" +#endif diff --git a/src/os/windows.c b/src/os/windows.c new file mode 100644 index 0000000..88d8b27 --- /dev/null +++ b/src/os/windows.c @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <os.h> + +int getline(char **, size_t *, void *) +{ + return -1; +} diff --git a/src/os/windows_main.c b/src/os/windows_main.c new file mode 100644 index 0000000..dc30750 --- /dev/null +++ b/src/os/windows_main.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com> + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <os.h> + +int +main(int argc, char **argv) +{ + return portable_main(argc, argv); +} diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index 9f1d00a..8e995db 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -1,10 +1,10 @@ -genboot$(EXEEXT): src/tools/genboot.c +genboot$(EXEEXT): src/tools/genboot.c src/os/os.c src/os/os_main.c src/include/os.h src/include/os_main.h $(AM_V_CC) - $(AM_V_at)$(CC_FOR_BUILD) -o $@ $(top_srcdir)/src/tools/genboot.c + $(AM_V_at)$(CC_FOR_BUILD) -DBUILD_TARGET -I$(top_srcdir)/src/include/ -I. -o $@ $(top_srcdir)/src/tools/genboot.c $(top_srcdir)/src/os/os.c $(top_srcdir)/src/os/os_main.c -genunicode$(EXEEXT): src/tools/genunicode.c +genunicode$(EXEEXT): src/tools/genunicode.c src/os/os.c src/os/os_main.c src/include/os.h src/include/os_main.h $(AM_V_CC) - $(AM_V_at)$(CC_FOR_BUILD) -o $@ $(top_srcdir)/src/tools/genunicode.c + $(AM_V_at)$(CC_FOR_BUILD) -DBUILD_TARGET -I$(top_srcdir)/src/include/ -I. -o $@ $(top_srcdir)/src/tools/genunicode.c $(top_srcdir)/src/os/os.c $(top_srcdir)/src/os/os_main.c EXTRA_DIST += src/tools/genboot.c src/tools/genunicode.c CLEANFILES += genboot$(EXEEXT) genunicode$(EXEEXT) diff --git a/src/tools/genboot.c b/src/tools/genboot.c index 9d0a7e4..6433bf7 100644 --- a/src/tools/genboot.c +++ b/src/tools/genboot.c @@ -17,11 +17,10 @@ * along with aplwc. If not, see <https://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <assert.h> +#include <os.h> int -main(int argc, char *argv[]) +portable_main(int argc, char *argv[]) { FILE *f; int c, s; diff --git a/src/tools/genunicode.c b/src/tools/genunicode.c index 76f2c60..209984f 100644 --- a/src/tools/genunicode.c +++ b/src/tools/genunicode.c @@ -17,11 +17,7 @@ * along with aplwc. If not, see <https://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> -#include <setjmp.h> +#include <os.h> static char *files[] = { "DerivedCoreProperties.txt", @@ -51,7 +47,7 @@ static void parse_sep(FILE *); static jmp_buf env; int -main(int argc, char *argv[]) +portable_main(int argc, char *argv[]) { FILE *f; char *dir, *buf; |