Skip to content

Commit

Permalink
Add Windows cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoNex committed Jun 12, 2024
1 parent a6f56b7 commit bd2a1bd
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ all: libffi tau

tau:
cd cmd/tau && \
CC=$(CC) CGO_CFLAGS="$(CFLAGS)" CGO_LDFLAGS="$(LDFLAGS)" go build -o $(DIR)/tau
CC=$(CC) \
CGO_CFLAGS="$(CFLAGS)" \
CGO_LDFLAGS="$(LDFLAGS)" \
go build -o $(DIR)/tau

libffi:
if [ ! -d libffi ] || [ $$(ls -1q libffi | wc -l) -eq 0 ]; then \
Expand All @@ -45,6 +48,30 @@ libffi:
./configure --prefix=$(DIR)/internal/obj/libffi --disable-shared --enable-static --disable-multi-os-directory && \
make install CC=$(CC)

libffi-windows:
if [ ! -d libffi ] || [ $$(ls -1q libffi | wc -l) -eq 0 ]; then \
git submodule init; \
git submodule update --recursive; \
fi

CC=$(CC) cd libffi && \
ACLOCAL_PATH=$(ACLOCAL_PATH) autoreconf -i && \
./configure --host=x86_64-w64-mingw32 --prefix=$(DIR)/internal/obj/libffi --disable-shared --enable-static --disable-multi-os-directory && \
make install CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib

tau-windows:
cd cmd/tau && \
CC=x86_64-w64-mingw32-gcc \
CGO_ENABLED=1 \
RANLIB=x86_64-w64-mingw32-ranlib \
CGO_CFLAGS="$(CFLAGS)" \
CGO_LDFLAGS="$(LDFLAGS)" \
GOOS=windows \
GOARCH=amd64 \
go build -o $(DIR)/tau.exe

windows: libffi-windows tau-windows

debug:
cd cmd/tau && \
CC=$(CC) CGO_CFLAGS="$(CFLAGS) -DDEBUG" CGO_LDFLAGS="$(LDFLAGS)" go build -o $(DIR)/tau
Expand Down

0 comments on commit bd2a1bd

Please sign in to comment.