Skip to content

Commit c91868d

Browse files
committed
Generate and install pkg-config module file
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
1 parent e169732 commit c91868d

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ stb_image.h
33
stb_image_write.h
44
qoibench
55
qoiconv
6+
qoi.pc

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TARGET_CONV ?= qoiconv
1010
PREFIX ?= /usr/local
1111
BINDIR ?= $(PREFIX)/bin
1212
INCLUDEDIR ?= $(PREFIX)/include
13+
LIBDIR ?= $(PREFIX)/lib
1314

1415
all: $(TARGET_BENCH) $(TARGET_CONV)
1516

@@ -21,6 +22,9 @@ conv: $(TARGET_CONV)
2122
$(TARGET_CONV):$(TARGET_CONV).c qoi.h
2223
$(CC) $(CFLAGS_CONV) $(CFLAGS) $(TARGET_CONV).c -o $(TARGET_CONV) $(LFLAGS_CONV)
2324

25+
qoi.pc: pc_gen.sh
26+
./pc_gen.sh "$(PREFIX)" "$(INCLUDEDIR)" > qoi.pc
27+
2428
.PHONY: install
2529
install: install-tools install-header
2630

@@ -32,6 +36,7 @@ install-tools: all
3236
.PHONY: install-header
3337
install-header: qoi.h qoi.pc
3438
install -Dm 644 qoi.h $(DESTDIR)$(INCLUDEDIR)/qoi.h
39+
install -Dm 644 qoi.pc $(DESTDIR)$(LIBDIR)/pkgconfig/qoi.pc
3540

3641
.PHONY: clean
3742
clean:

pc_gen.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
prefix=$1
2+
includedir=$2
3+
4+
if [[ $includedir == $prefix* ]]
5+
then
6+
includedir='${prefix}'${includedir#"$prefix"}
7+
fi
8+
9+
cat << EOF
10+
prefix=$prefix
11+
includedir=$includedir
12+
13+
Name: qoi
14+
Description: The "Quite OK Image Format" for fast, lossless image compression
15+
Version: 0
16+
URL: https://qoiformat.org/
17+
License: MIT
18+
Cflags: -I\${includedir}
19+
EOF

0 commit comments

Comments
 (0)