This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change license, flat file hier, do not use gpp, join .py and .pyx, si…
…mpler makefile Signed-off-by: Mattias Andrée <[email protected]>
- Loading branch information
Showing
12 changed files
with
1,283 additions
and
2,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
bin/ | ||
obj/ | ||
\#*\# | ||
*\#* | ||
*~ | ||
__pycache__/ | ||
*.bak | ||
*.sw[op] | ||
*.o | ||
*.out | ||
*.su | ||
*.so | ||
*.gch | ||
*.py[co] | ||
src/*_native_*.c | ||
*.pyc | ||
*.pyo | ||
*.c | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,9 @@ BUILD DEPENDENCIES: | |
cython | ||
coreutils | ||
pkg-config | ||
gpp | ||
|
||
|
||
INSTALL DEPENDENCIES: | ||
|
||
make | ||
coreutils | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,34 @@ | ||
PREFIX = /usr | ||
LIBDIR = $(PREFIX)/lib | ||
DATADIR = $(PREFIX)/share | ||
LICENSEDIR = $(DATADIR)/licenses | ||
.POSIX: | ||
|
||
PKGNAME = pylibcoopgamma | ||
CONFIGFILE = config.mk | ||
include $(CONFIGFILE) | ||
|
||
GPP = gpp | ||
CYTHON = cython | ||
PKGCONFIG = pkg-config | ||
PYTHON = python3 | ||
all: libcoopgamma.so | ||
libcoopgamma.o: libcoopgamma.c include-libcoopgamma.h | ||
|
||
PY_MAJOR = $(shell $(PYTHON) --version | cut -d ' ' -f 2 | cut -d . -f 1) | ||
PY_MINOR = $(shell $(PYTHON) --version | cut -d ' ' -f 2 | cut -d . -f 2) | ||
PY_VER = $(PY_MAJOR)$(PY_MINOR) | ||
PY_VERSION = $(PY_MAJOR).$(PY_MINOR) | ||
.pyx.c: | ||
if ! $(CYTHON) -3 -v $<; then rm -f -- $@; false; fi | ||
|
||
PYTHONDIR = $(LIBDIR)/python$(PY_VERSION) | ||
.c.o: | ||
$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) | ||
|
||
OPTIMISE = -O2 | ||
LIBS = python$(PY_MAJOR) | ||
.o.so: | ||
$(CC) -shared -o $@ $< $(LDFLAGS) | ||
|
||
CC_FLAGS = $$($(PKGCONFIG) --cflags $(LIBS)) -std=c99 $(OPTIMISE) -fPIC $(CFLAGS) $(CPPFLAGS) | ||
LD_FLAGS = $$($(PKGCONFIG) --libs $(LIBS)) -lcoopgamma -std=c99 $(OPTIMISE) -shared $(LDFLAGS) | ||
check: libcoopgamma.so | ||
./test | ||
|
||
ifeq ($(shell test $(PY_VER) -ge 35 ; echo $$?),0) | ||
PY_OPT2_EXT = opt-2.pyc | ||
else | ||
PY_OPT2_EXT = pyo | ||
endif | ||
|
||
|
||
|
||
.PHONY: all | ||
all: base | ||
|
||
.PHONY: base | ||
base: lib | ||
|
||
.PHONY: lib | ||
lib: compiled optimised native | ||
|
||
.PHONY: compiled | ||
compiled: src/__pycache__/libcoopgamma.cpython-$(PY_VER).pyc | ||
|
||
.PHONY: optimised | ||
optimised: src/__pycache__/libcoopgamma.cpython-$(PY_VER).$(PY_OPT2_EXT) | ||
|
||
.PHONY: so-files | ||
native: bin/libcoopgamma_native.so | ||
|
||
obj/libcoopgamma_native.pyx: src/libcoopgamma_native.pyx.gpp | ||
@mkdir -p obj | ||
$(GPP) -s '$$$$' -i src/libcoopgamma_native.pyx.gpp -o $@ | ||
|
||
obj/%.c: obj/%.pyx | ||
if ! $(CYTHON) -3 -v $< ; then rm $@ ; false ; fi | ||
|
||
obj/%.o: obj/%.c src/*.h | ||
$(CC) $(CC_FLAGS) -iquote"src" -c -o $@ $< | ||
|
||
bin/%.so: obj/%.o | ||
@mkdir -p bin | ||
$(CC) $(LD_FLAGS) -o $@ $^ | ||
|
||
src/__pycache__/%.cpython-$(PY_VER).pyc: src/%.py | ||
$(PYTHON) -m compileall $< | ||
|
||
src/__pycache__/%.cpython-$(PY_VER).$(PY_OPT2_EXT): src/%.py | ||
$(PYTHON) -OO -m compileall $< | ||
|
||
|
||
|
||
.PHONY: install | ||
install: install-base | ||
|
||
.PHONY: install-all | ||
install-all: install-base | ||
|
||
.PHONY: install-base | ||
install-base: install-lib install-copyright | ||
|
||
.PHONY: install-lib | ||
install-lib: install-source install-compiled install-optimised install-native | ||
|
||
.PHONY: install-source | ||
install-source: src/libcoopgamma.py | ||
mkdir -p -- "$(DESTDIR)$(PYTHONDIR)" | ||
cp $^ -- "$(DESTDIR)$(PYTHONDIR)" | ||
|
||
.PHONY: install-compiled | ||
install-compiled: src/__pycache__/libcoopgamma.cpython-$(PY_VER).pyc | ||
mkdir -p -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" | ||
cp $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" | ||
|
||
.PHONY: install-optimised | ||
install-optimised: src/__pycache__/libcoopgamma.cpython-$(PY_VER).$(PY_OPT2_EXT) | ||
mkdir -p -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" | ||
cp $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" | ||
|
||
.PHONY: install-native | ||
install-native: bin/libcoopgamma_native.so | ||
install: libcoopgamma.so | ||
mkdir -p -- "$(DESTDIR)$(PYTHONDIR)" | ||
cp $^ -- "$(DESTDIR)$(PYTHONDIR)" | ||
cp -- libcoopgamma.so "$(DESTDIR)$(PYTHONDIR)" | ||
|
||
.PHONY: install-copyright | ||
install-copyright: install-copying install-license | ||
|
||
.PHONY: install-copying | ||
install-copying: COPYING | ||
mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" | ||
cp $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" | ||
|
||
.PHONY: install-license | ||
install-license: LICENSE | ||
mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" | ||
cp $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" | ||
|
||
|
||
|
||
.PHONY: uninstall | ||
uninstall: | ||
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" | ||
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" | ||
-rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" | ||
-rm -- "$(DESTDIR)$(PYTHONDIR)/__pycache__/libcoopgamma.cpython-$(PY_VER).$(PY_OPT2_EXT)" | ||
-rm -- "$(DESTDIR)$(PYTHONDIR)/__pycache__/libcoopgamma.cpython-$(PY_VER).pyc" | ||
-rm -- "$(DESTDIR)$(PYTHONDIR)/libcoopgamma.py" | ||
-rm -- "$(DESTDIR)$(PYTHONDIR)/libcoopgamma_native.so" | ||
|
||
-rm -- "$(DESTDIR)$(PYTHONDIR)/libcoopgamma.so" | ||
|
||
|
||
.PHONY: clean | ||
clean: | ||
-rm -r obj bin src/__pycache__ | ||
-rm -rf -- __pycache__/ *.pyc *.pyo *.c *.o *.su *.so | ||
|
||
.SUFFIXES: | ||
.SUFFIXES: .so .o .c .pyx | ||
|
||
.PHONY: all check install uninstall clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ SEE ALSO | |
libcoopgamma(7) | ||
|
||
Full documentation available locally via the command help in python(1). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
PREFIX = /usr | ||
|
||
PY_MAJOR = $$($(PYTHON) --version 2>&1 | cut -d ' ' -f 2 | cut -d . -f 1) | ||
PY_MINOR = $$($(PYTHON) --version 2>&1 | cut -d ' ' -f 2 | cut -d . -f 2) | ||
PY_VER = $(PY_MAJOR)$(PY_MINOR) | ||
PY_VERSION = $(PY_MAJOR).$(PY_MINOR) | ||
|
||
PYTHONDIR = $(PREFIX)/lib/python$(PY_VERSION) | ||
|
||
CYTHON = cython | ||
PKGCONFIG = pkg-config | ||
PYTHON = python3 | ||
|
||
CPPFLAGS = | ||
CFLAGS = -std=c99 -Wall $$($(PKGCONFIG) --cflags python$(PY_MAJOR)) -O2 | ||
LDFLAGS = $$($(PKGCONFIG) --libs python$(PY_MAJOR)) -lcoopgamma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* See LICENSE file for copyright and license details. */ | ||
#include <libcoopgamma.h> | ||
|
||
#define fclass class | ||
#define u_red_size u8.red_size | ||
#define u_green_size u8.green_size | ||
#define u_blue_size u8.blue_size | ||
#define u_red u8.red | ||
#define u_green u8.green | ||
#define u_blue u8.blue |
Oops, something went wrong.