Debian Codegraph @

imagequant-sys/Makefile

raw
1 # You can configure these
2 PREFIX ?= /usr/local
3 LIBDIR ?= $(PREFIX)/lib
4 INCLUDEDIR ?= $(PREFIX)/include
5 PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
6 DESTDIR ?= ""
7
8 VERSION=$(shell grep '^version = "4' Cargo.toml | grep -Eo "4\.[0-9.]+")
9 STATICLIB=libimagequant.a
10
11 JNILIB=libimagequant.jnilib
12
13 JAVACLASSES = org/pngquant/LiqObject.class org/pngquant/PngQuant.class org/pngquant/Image.class org/pngquant/Result.class
14 JAVAHEADERS = $(JAVACLASSES:.class=.h)
15 JAVAINCLUDE = -I'$(JAVA_HOME)/include' -I'$(JAVA_HOME)/include/linux' -I'$(JAVA_HOME)/include/win32' -I'$(JAVA_HOME)/include/darwin'
16
17 PKGCONFIG = imagequant.pc
18
19 all: static
20
21 static: $(STATICLIB)
22
23 java: $(JNILIB)
24
25 $(STATICLIB): Cargo.toml
26 cargo build --release
27 cp ../target/release/libimagequant_sys.a $(STATICLIB)
28
29 $(JNILIB): $(JAVAHEADERS) $(STATICLIB) org/pngquant/PngQuant.c
30 # You may need to set LDFLAGS env var. See: cargo rustc -- --print native-static-libs
31 $(CC) -g $(CFLAGS) $(LDFLAGS) $(JAVAINCLUDE) -shared -o $@ org/pngquant/PngQuant.c $(STATICLIB)
32
33 $(JAVACLASSES): %.class: %.java
34 javac $<
35
36 $(JAVAHEADERS): %.h: %.class
37 javah -o $@ $(subst /,., $(patsubst %.class,%,$<)) && touch $@
38
39 example: example.c lodepng.h lodepng.c $(STATICLIB)
40 # remove -lpthread on Windows
41 # add -ldl on Linux
42 # You may need to set LDFLAGS env var. See: cargo rustc -- --print native-static-libs
43 $(CC) -g $(CFLAGS) -Wall example.c $(STATICLIB) -lm -lpthread $(LDFLAGS) -o example
44
45 lodepng.h:
46 curl -o lodepng.h -L https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.h
47
48 lodepng.c:
49 curl -o lodepng.c -L https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.cpp
50
51 clean:
52 rm -f $(SHAREDLIBVER) $(SHAREDLIB) $(STATICLIB)
53 rm -f $(JAVAHEADERS) $(JAVACLASSES) $(JNILIB) example
54 rm -rf ../target
55
56 distclean: clean
57 rm -f imagequant.pc
58
59 install: all $(PKGCONFIG)
60 install -d $(DESTDIR)$(LIBDIR)
61 install -d $(DESTDIR)$(PKGCONFIGDIR)
62 install -d $(DESTDIR)$(INCLUDEDIR)
63 install -m 644 $(STATICLIB) $(DESTDIR)$(LIBDIR)/$(STATICLIB)
64 install -m 644 $(PKGCONFIG) $(DESTDIR)$(PKGCONFIGDIR)/$(PKGCONFIG)
65 install -m 644 libimagequant.h $(DESTDIR)$(INCLUDEDIR)/libimagequant.h
66 $(FIX_INSTALL_NAME)
67
68 uninstall:
69 rm -f $(DESTDIR)$(LIBDIR)/$(STATICLIB)
70 rm -f $(DESTDIR)$(PKGCONFIGDIR)/$(PKGCONFIG)
71 rm -f $(DESTDIR)$(INCLUDEDIR)/libimagequant.h
72
73 $(PKGCONFIG): Cargo.toml
74 sed 's|@PREFIX@|$(PREFIX)|;s|@VERSION@|$(VERSION)|' < imagequant.pc.in > $(PKGCONFIG)
75
76 .PHONY: all static clean distclean java
77 .DELETE_ON_ERROR: