Skip to content

Commit e40cfc6

Browse files
committed
Improve makefile
1 parent d0d0a8b commit e40cfc6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@ MAKE := make
66
CFLAGS += -Wall -Wextra -fpic -O2 -fno-strict-aliasing -Wno-unused-parameter
77

88
SYS := $(shell gcc -dumpmachine)
9-
LIBFFI_PATH := ./libs/libffi/$(SYS)
10-
INCLUDES := -I$(LIBFFI_PATH)/include
9+
LIBFFI_PATH := ./libs/libffi
10+
11+
ifeq ($(SYS), x86_64-w64-mingw32)
12+
BUILDSYS := $(SYS)
13+
else
14+
BUILDSYS := $(shell bash $(LIBFFI_PATH)/config.guess)
15+
endif
16+
17+
LIBFFI_PATH := $(LIBFFI_PATH)/$(BUILDSYS)
18+
INCLUDES :=-I$(LIBFFI_PATH)/include
1119
LIBS := -L$(LIBFFI_PATH)/.libs -lffi
1220

1321
ifneq (, $(findstring linux, $(SYS)))
1422
SUFFIX := so
1523
LDFLAGS := -shared
1624
LIBS += -ldl
1725
else ifneq (, $(findstring mingw, $(SYS)))
18-
SUFFIX = dll
19-
LDFLAGS = -mdll
20-
CFLAGS += -I./libs/$(PLATFORM)/include/
26+
SUFFIX := dll
27+
LDFLAGS := -mdll
2128
else
2229
$(error Unsupported build platform)
2330
endif
@@ -32,12 +39,12 @@ INCLUDES += -I${GLOBALS_HOME}/dev/cpp/include
3239
CFLAGS += $(INCLUDES)
3340
TESTSDIR := tests
3441

35-
.PHONY: all clean libffi libffi_clean
42+
.PHONY: all clean libffi libffi-clean
3643

3744
all: libcna.$(SUFFIX) $(TESTSDIR)/libtest.$(SUFFIX)
3845

3946
libffi:
40-
cd libs/libffi && ./configure --build=$(SYS) --enable-shared=no && $(MAKE)
47+
cd libs/libffi && ./configure --build=$(BUILDSYS) --enable-shared=no && $(MAKE)
4148

4249
cna.o: cna.c storage.h
4350

libs/libffi/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Makefile
22
config.log
3+
confdefs.h
34
*~
45
x86_64-w64-mingw32

0 commit comments

Comments
 (0)