From 3f76eddbcec596be8f08d2981d9a20f76e5c1d89 Mon Sep 17 00:00:00 2001 From: surkeh Date: Sat, 21 Apr 2018 15:44:09 -0700 Subject: [PATCH] Makefile creates .so (internall a .dll on windows?) --- .gitignore | 3 ++- Makefile | 23 ++++++++++++++++------- bindings/py3devil1.py | 15 ++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) mode change 100644 => 100755 bindings/py3devil1.py diff --git a/.gitignore b/.gitignore index 35a3473..e76c721 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ # Files from compilation and tests *.o +*.so +*.gch *.exe *.stackdump *.log -devil1test demo-extractpld demo-extracttexture demo-extractmesh diff --git a/Makefile b/Makefile index 7cc9e14..9b199fb 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,30 @@ +CC=gcc +CFLAGS=-I"include" -Wall -fPIC #-g +LDFLAGS=-shared +TARGET=lib3ddevil1.so PEX=demo-extractpld TEX=demo-extracttexture MEX=demo-extractmesh +OBJ=devil1pld.o devil1tex.o devil1geo.o -CC=gcc -CFLAGS= -I"include" -Wall +all: $(TARGET) demos + +$(TARGET): $(OBJ) + $(LINK.cc) $(LDFLAGS) $^ -o $@ -all: pld texture mesh -pld: devil1pld.o devil1tex.o devil1geo.o +demos: pld texture mesh + +pld: $(OBJ) $(CC) $^ demo/extractpld.c $(CFLAGS) -o $(PEX) -texture: devil1pld.o devil1tex.o devil1geo.o +texture: $(OBJ) $(CC) $^ demo/extracttexture.c $(CFLAGS) -o $(TEX) -mesh: devil1pld.o devil1tex.o devil1geo.o +mesh: $(OBJ) $(CC) $^ demo/extractmesh.c $(CFLAGS) -o $(MEX) + devil1pld.o: src/devil1pld.c $(CC) -c $^ $(CFLAGS) @@ -26,4 +35,4 @@ devil1geo.o: src/devil1geo.c $(CC) -c $^ $(CFLAGS) clean: - rm *.o $(EX) $(PEX) $(TEX) $(MEX) + rm *.o $(TARGET) $(PEX) $(TEX) $(MEX) diff --git a/bindings/py3devil1.py b/bindings/py3devil1.py old mode 100644 new mode 100755 index b520e39..61e75b3 --- a/bindings/py3devil1.py +++ b/bindings/py3devil1.py @@ -1,3 +1,4 @@ +#!/usr/bin/python3 import ctypes class PldHeader(ctypes.Structure): @@ -14,8 +15,12 @@ class Devil1FN_PLD(ctypes.Structure): ] def main(): - libc = cdll.LoadLibrary('./libdevil1pld.so') - if (lib): - print("OK") - with open("pl01.pld", "rb") as f: - data = f.read() + sharedlib='./lib3ddevil1.so' + libc = cdll.LoadLibrary(sharedlib) + if (not lib): + print("Couldn't load %s" % sharedlib) + return 1 + + print("OK") + with open("pl01.pld", "rb") as f: + data = f.read()