Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 84abfd4

Browse files
committed
[enh] added windows/mingw target to makefile
1 parent e279234 commit 84abfd4

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

src/makefile

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,53 @@ INC=-Igoldilocks/src/GENERATED/include -I/usr/include/sodium
1111
LIBS=-lsodium
1212
CFLAGS=$(INC) -Wall -Os
1313
LDFLAGS=-g $(LIBS)
14+
CC=gcc
15+
SOEXT=so
1416

1517
all: bin libsphinx.so tests
16-
1718
bin: bin/challenge bin/respond bin/derive
1819

19-
tests: tests/pake tests/sphinx
20+
win: CC=x86_64-w64-mingw32-gcc
21+
win: INC=-Igoldilocks/src/GENERATED/include -Iwin/libsodium-win64/include/sodium -Iwin/libsodium-win64/include
22+
win: LIBS=-L. -Lwin/libsodium-win64/lib/ -Wl,-Bstatic -lsodium -Wl,-Bdynamic
23+
win: SOEXT=dll
24+
win: EXT=.exe
25+
win: MAKETARGET=win
26+
win: win/libsodium-win64 exe libsphinx.$(SOEXT) tests$(EXT)
27+
exe: bin/challenge$(EXT) bin/respond$(EXT) bin/derive$(EXT)
28+
29+
tests$(EXT): tests/pake$(EXT) tests/sphinx$(EXT)
2030

2131
$(objs):
22-
cd goldilocks; make
32+
cd goldilocks; OFLAGS='' ARCHFLAGS='' make $(MAKETARGET)
33+
34+
bin/challenge$(EXT): $(objs) bin/challenge.c
35+
$(CC) $(CFLAGS) -o bin/challenge$(EXT) bin/challenge.c $(LDFLAGS) $(objs)
2336

24-
bin/challenge: $(objs) bin/challenge.c
25-
gcc $(CFLAGS) -o bin/challenge bin/challenge.c $(LDFLAGS) $(objs)
37+
bin/respond$(EXT): $(objs) bin/respond.c
38+
$(CC) $(CFLAGS) -o bin/respond$(EXT) bin/respond.c $(LDFLAGS) $(objs)
2639

27-
bin/respond: $(objs) bin/respond.c
28-
gcc $(CFLAGS) -o bin/respond bin/respond.c $(LDFLAGS) $(objs)
40+
bin/derive$(EXT): $(objs) bin/derive.c
41+
$(CC) $(CFLAGS) -o bin/derive$(EXT) bin/derive.c $(LDFLAGS) $(objs)
2942

30-
bin/derive: $(objs) bin/derive.c
31-
gcc $(CFLAGS) -o bin/derive bin/derive.c $(LDFLAGS) $(objs)
43+
libsphinx.$(SOEXT): $(objs) sphinx.o pake.o
44+
$(CC) -shared -fpic $(CFLAGS) -o libsphinx.$(SOEXT) $(objs) pake.o sphinx.o $(LDFLAGS)
3245

33-
libsphinx.so: $(objs) sphinx.o pake.o
34-
$(CC) -shared -fpic $(CFLAGS) -o $@ $(objs) pake.o sphinx.o $(LDFLAGS)
46+
tests/sphinx$(EXT): tests/test.c libsphinx.$(SOEXT)
47+
$(CC) $(CFLAGS) -o tests/sphinx$(EXT) tests/test.c -lsphinx $(LDFLAGS) $(objs)
3548

36-
tests/sphinx: tests/test.c libsphinx.so
37-
gcc $(CFLAGS) -o tests/sphinx tests/test.c -lsphinx $(LDFLAGS) $(objs)
49+
tests/pake$(EXT): tests/pake-test.c libsphinx.$(SOEXT)
50+
$(CC) $(CFLAGS) -o tests/pake$(EXT) tests/pake-test.c -lsphinx $(LDFLAGS) $(objs)
3851

39-
tests/pake: tests/pake-test.c libsphinx.so
40-
gcc $(CFLAGS) -o tests/pake tests/pake-test.c -lsphinx $(LDFLAGS) $(objs)
52+
win/libsodium-win64:
53+
@echo 'win/libsodium-win64 not found.'
54+
@echo 'download and unpack latest libsodium-*-mingw.tar.gz and unpack into win/'
55+
@echo 'https://download.libsodium.org/libsodium/releases/'
56+
@false
4157

4258
clean:
43-
@rm -f bin/sphinx bin/challenge bin/respond bin/derive libsphinx.so *.o *.pyc || true
44-
@rm -f tests/sphinx tests/pake || true
45-
@rm -rf __pycache__ || true
59+
rm -f bin/sphinx bin/challenge bin/respond bin/derive libsphinx.so
60+
rm -f tests/sphinx tests/pake tests/sphinx.exe tests/pake.exe *.o
61+
rm -f bin/sphinx.exe bin/challenge.exe bin/respond.exe bin/derive.exe libsphinx.dll
4662

4763
.PHONY: bin clean

0 commit comments

Comments
 (0)