Skip to content

Commit 62e9058

Browse files
committed
Makefile now works on Linux too
1 parent 87eda5a commit 62e9058

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

c/Makefile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ MAKE := make
55

66
CFLAGS += -Wall -Wextra -fpic -O2 -fno-strict-aliasing -Wno-unused-parameter
77

8-
98
SYS := $(shell gcc -dumpmachine)
109

1110
ifeq ($(SYS), x86_64-w64-mingw32)
@@ -16,33 +15,35 @@ endif
1615

1716
ifneq (, $(findstring linux, $(SYS)))
1817
SUFFIX := so
19-
LDFLAGS := -shared
20-
LIBS += -ldl
18+
19+
ifndef PYTHONVER
20+
$(error Couldn't find PYTHONVER)
21+
endif
22+
23+
INCLUDES += $(shell python${PYTHONVER}-config --includes)
24+
LDFLAGS := -shared $(shell python${PYTHONVER}-config --ldflags)
25+
LIBS += $(shell python${PYTHONVER}-config --libs)
2126
else ifneq (, $(findstring mingw, $(SYS)))
2227
SUFFIX := dll
23-
LDFLAGS := -shared
28+
29+
ifndef PYTHONHOME
30+
$(error Couldn't find PYTHONHOME)
31+
endif
32+
33+
PYTHONVER := $(shell ${PYTHONHOME}python -c "import sys; print(str(sys.version_info[0])+str(sys.version_info[1]))")
34+
35+
INCLUDES += -I${PYTHONHOME}/include
36+
LDFLAGS += -L${PYTHONHOME}/Libs
37+
LIBS = -lpython${PYTHONVER}
2438
else
2539
$(error Unsupported build platform)
2640
endif
2741

28-
29-
30-
3142
ifndef GLOBALS_HOME
32-
$(error Couldn't find GLOBALS_HOME)
43+
$(error Couldn't find GLOBALS_HOME)
3344
endif
3445

35-
ifndef PYTHONHOME
36-
$(error Couldn't find PYTHONHOME)
37-
endif
38-
39-
PYTHONVER := $(shell ${PYTHONHOME}python -c "import sys; print(sys.version_info[0],sys.version_info[1],sep='')")
40-
LIBS = -lpython${PYTHONVER}
41-
42-
LDFLAGS += -L${PYTHONHOME}/Libs
43-
4446
INCLUDES += -I${GLOBALS_HOME}/dev/cpp/include
45-
INCLUDES += -I${PYTHONHOME}/include
4647
CFLAGS += $(INCLUDES)
4748

4849
.PHONY: all clean

c/iscpython.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ int main(int argc, char **argv) {
131131
char* result = malloc(sizeof(char) * 1024);
132132

133133
Initialize();
134-
SimpleString("x=2", "y", result);
134+
SimpleString("x=2", "x", result);
135135
Finalize();
136136

137-
printf(result);
137+
printf("%s", result);
138138
return EXIT_SUCCESS;
139139
}
140140

0 commit comments

Comments
 (0)