Skip to content

Commit 9123db2

Browse files
author
mokrates
committed
windows (cygwin/mingw32) branch
1 parent 9437e46 commit 9123db2

37 files changed

+311
-74
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,20 @@ limo: $(OBJ) libs info
3535
limo-almost-static: $(OBJ) libs info
3636
$(CC) $(OBJ) $(PROFILING) `./inline-cfg.sh` -lm -l:libgc.a -lpthread -l:libgmp.a -ldl -l:libreadline.a -l:libtermcap.a -rdynamic -o limo
3737

38+
limo-cygwin-exe: $(OBJ)
39+
$(CC) $(BASEOBJ) $(PROFILING) -shared `./inline-cfg.sh` -lm -lgc -lpthread -lgmp -ldl -lreadline -rdynamic -o limodll.dll
40+
$(CC) main.o $(PROFILING) limodll.dll -lm -lgc -lpthread -lgmp -ldl -lreadline -rdynamic -o limo.exe
41+
42+
limo-cygwin: limo-cygwin-exe libs-cygwin info
43+
3844
limo-wsl: limo-almost-static info
3945

4046
libs:
4147
make -C libs
4248

49+
libs-cygwin:
50+
make -C libs lib-cygwin
51+
4352
TAGS:
4453
etags.emacs --regex='{c}/BUILTIN\(FUN\)?(\([^)]+\)/\2/' *.c *.h libs/*/*.c libs/*/*.h
4554

@@ -62,7 +71,7 @@ realclean: clean
6271
install:
6372
mkdir -p $(LIMO_PREFIX)
6473
cp -f *.limo $(LIMO_PREFIX)
65-
cp -f libs/*/*.so $(LIMO_PREFIX)
74+
# cp -f libs/*/*.so $(LIMO_PREFIX)
6675
cp -f libs/*/*.ttf $(LIMO_PREFIX)
6776
cp -rf limo-code/* $(LIMO_PREFIX)
6877
cp -f docs/limo-info.info $(LIMO_PREFIX)

Makefile.mingw

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# -*- makefile -*-
2+
3+
CC=i686-w64-mingw32-gcc
4+
DLLSOURCEDIR=/usr/i686-w64-mingw32/sys-root/mingw/bin
5+
export CC
6+
AR=$(CC)-ar
7+
export AR
8+
9+
INSTALL_PREFIX=c:/limo/
10+
LIMO_PREFIX=$(INSTALL_PREFIX)
11+
12+
DEBUG=-g -Wall #-DNDEBUG
13+
PROFILING= # -pg -no-pie
14+
OPTIMIZE=-O3
15+
OPTIONS=-DLIMO_PREFIX=\"$(LIMO_PREFIX)\"
16+
17+
BASEOBJ=writer.o reader.o error.o makers.o vars.o eval.o \
18+
helpers.o builtinenv.o builtins.o numbers_gmp.o annotations.o \
19+
dict.o special.o block.o limpy.o misc.o inlined_mods.o dynamicvars.o \
20+
limo.o
21+
OBJ=main.o $(BASEOBJ)
22+
EXEOBJ=exelimo.o $(BASEOBJ)
23+
HEADERS=limo.h config.h
24+
25+
CFLAGS += $(OPTIMIZE) $(DEBUG) $(PROFILING) $(OPTIONS)
26+
export CFLAGS
27+
28+
.PHONY: all libs clean realclean install uninstall
29+
30+
all: TAGS libs limo
31+
32+
exelimo: $(EXEOBJ)
33+
$(AR) rcs liblimo.a $(EXEOBJ)
34+
exelimo.o: $(HEADERS) limo.c
35+
$(CC) $(DEBUG) -c -DLIMO_MAKE_EXECUTABLE limo.c -o exelimo.o
36+
37+
inlined_mods.c: inlined.mods
38+
./make-inlined_mods-c.sh
39+
40+
limo-mingw: $(OBJ) libs info
41+
$(CC) $(OBJ) $(PROFILING) `./inline-cfg.sh` -lm -lgc -lpthread -lgmp -ldl -lreadline -o limo
42+
43+
44+
limo-wsl: limo-almost-static info
45+
46+
libs:
47+
$(MAKE) -C libs
48+
49+
TAGS:
50+
etags.emacs --regex='{c}/BUILTIN\(FUN\)?(\([^)]+\)/\2/' *.c *.h libs/*/*.c libs/*/*.h
51+
52+
$(OBJ): $(HEADERS) Makefile
53+
54+
info:
55+
$(MAKE) -C docs docs
56+
57+
clean:
58+
rm -f *.o *~
59+
rm -f inlined_mods.c
60+
$(MAKE) -C libs clean
61+
$(MAKE) -C docs clean
62+
63+
realclean: clean
64+
$(MAKE) -C libs realclean
65+
make -C docs realclean
66+
rm -f limo
67+
68+
install:
69+
mkdir -p $(LIMO_PREFIX)
70+
cp -f *.limo $(LIMO_PREFIX)
71+
# cp -f libs/*/*.so $(LIMO_PREFIX)
72+
cp -f libs/*/*.ttf $(LIMO_PREFIX)
73+
cp -rf limo-code/* $(LIMO_PREFIX)
74+
# cp -f docs/limo-info.info $(LIMO_PREFIX)
75+
mkdir -p $(INSTALL_PREFIX)/bin
76+
cp -f limo $(INSTALL_PREFIX)/bin
77+
78+
install-mingw:
79+
mkdir -p $(LIMO_PREFIX)
80+
cp -f *.limo $(LIMO_PREFIX)
81+
# cp -f libs/*/*.so $(LIMO_PREFIX)
82+
cp -f libs/*/*.ttf $(LIMO_PREFIX)
83+
cp -rf limo-code/* $(LIMO_PREFIX)
84+
# cp -f docs/limo-info.info $(LIMO_PREFIX)
85+
mkdir -p $(INSTALL_PREFIX)
86+
cp -f limo.exe $(INSTALL_PREFIX)
87+
88+
uninstall:
89+
rm -rf $(LIMO_PREFIX)
90+
rm -f $(INSTALL_PREFIX)/bin/limo

build-cygwin.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if [ "$1" == "bin" ]; then
2+
make INSTALL_PREFIX=~/.local/ realclean
3+
make INSTALL_PREFIX=~/.local/ TAGS
4+
make INSTALL_PREFIX=~/.local/ limo-cygwin
5+
make INSTALL_PREFIX=~/.local/ install
6+
else
7+
make INSTALL_PREFIX=~/.local/ install
8+
fi
9+

build-mingw.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
DLLSOURCEDIR=/usr/i686-w64-mingw32/sys-root/mingw/bin
2+
INSTALL_PREFIX=c:/limo/
3+
4+
if [ "$1" == "bin" ]; then
5+
make -f Makefile.mingw realclean
6+
#make TAGS
7+
make -f Makefile.mingw limo-mingw
8+
make -f Makefile.mingw install-win
9+
10+
11+
# TODO this here should be beefed up like this: https://blog.rubenwardy.com/2018/05/07/mingw-copy-dlls/
12+
for dll in $(i686-w64-mingw32-objdump.exe -p limo.exe | grep lib.*dll | awk '{print $3}'); do
13+
cp ${DLLSOURCEDIR}/$dll ${INSTALL_PREFIX}
14+
done
15+
cp ${DLLSOURCEDIR}/libgcc_s_sjlj-1.dll ${INSTALL_PREFIX}
16+
17+
else
18+
make -f Makefile.mingw install-mingw
19+
fi
20+

builtins.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
#ifdef __MINGW32__
2+
#include <malloc.h>
3+
#endif
14
#include "limo.h"
25
#include <unistd.h>
36
#include <assert.h>
7+
#ifndef __MINGW32__
48
#include <alloca.h>
9+
#endif
510

611
BUILTIN(builtin_quote)
712
{

config.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,21 @@
2323
#define NO_EXECINFO
2424
#undef LIMO_THREADING
2525
#endif
26+
27+
28+
////// mingw / cygwin (windows)
29+
#if defined(__MINGW32__) || defined(__CYGWIN__)
30+
#define NO_EXECINFO
31+
#undef LIMO_THREADING
32+
#endif
33+
34+
#ifdef __MINGW32__
35+
/// strerror_r
36+
void strerror_r(int err_no, char *buf, int buflen);
37+
38+
/// setjmp
39+
#define sigsetjmp(env, sigs) setjmp(env)
40+
#define siglongjmp longjmp
41+
#define sigjmp_buf jmp_buf
42+
43+
#endif // !mingw

error.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ void segfault()
9494
{
9595
*((int *)NULL) = 123;
9696
}
97+
98+
#ifdef __MINGW32__
99+
void strerror_r(int err_no, char *buf, int buflen)
100+
{
101+
strncpy(buf, strerror(err_no), buflen);
102+
}
103+
#endif

eval.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
#ifdef __MINGW32__
2+
#include <malloc.h>
3+
#endif
14
#include <gc.h>
5+
6+
#ifndef __MINGW32__
27
#include <alloca.h>
8+
#endif
9+
310
#include "limo.h"
411
#include <assert.h>
512

inlined.mods

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
file
2-
string_builtins
3-
ncurses
1+
#file
2+
#string_builtins
3+
#ncurses
4+
5+
###########
6+
# windows
7+
###########
8+
#fd
9+
#date
10+
#regex
11+
#rlcompleter
12+
#vector
13+
#limogtk

libs/Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
LIBS=file string_builtins simplesdl threading regex sdl ncurses ncmenu\
2-
fd popen socket ssl rlcompleter date vector
2+
fd rlcompleter date vector # limogtk
33

44
.PHONY: all clean realclean $(LIBS)
55

6+
export CC
7+
export AR
8+
69
all: $(LIBS)
710

811
$(LIBS):
912
make -C $@ $@.so
1013
make -C $@ $@.a
1114

15+
$(LIBS:%=%.dll):
16+
make -C $(@:.dll=) $(@:.dll=.a)
17+
make -C $(@:.dll=) $@
18+
19+
libs-cygwin: $(LIBS:%=%.dll)
20+
1221
clean:
1322
$(foreach X,$(LIBS), make -C $X clean ; )
1423

1524
realclean:
1625
$(foreach X,$(LIBS), make -C $X realclean ; )
26+
27+

0 commit comments

Comments
 (0)