Skip to content

Commit e169732

Browse files
committed
Add installation support to Makefile
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
1 parent d749efc commit e169732

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ LFLAGS_CONV ?= $(LDFLAGS)
77
TARGET_BENCH ?= qoibench
88
TARGET_CONV ?= qoiconv
99

10+
PREFIX ?= /usr/local
11+
BINDIR ?= $(PREFIX)/bin
12+
INCLUDEDIR ?= $(PREFIX)/include
13+
1014
all: $(TARGET_BENCH) $(TARGET_CONV)
1115

1216
bench: $(TARGET_BENCH)
@@ -17,6 +21,18 @@ conv: $(TARGET_CONV)
1721
$(TARGET_CONV):$(TARGET_CONV).c qoi.h
1822
$(CC) $(CFLAGS_CONV) $(CFLAGS) $(TARGET_CONV).c -o $(TARGET_CONV) $(LFLAGS_CONV)
1923

24+
.PHONY: install
25+
install: install-tools install-header
26+
27+
.PHONY: install-tools
28+
install-tools: all
29+
install -Dm 755 $(TARGET_CONV) $(DESTDIR)$(BINDIR)/$(TARGET_CONV)
30+
install -Dm 755 $(TARGET_BENCH) $(DESTDIR)$(BINDIR)/$(TARGET_BENCH)
31+
32+
.PHONY: install-header
33+
install-header: qoi.h qoi.pc
34+
install -Dm 644 qoi.h $(DESTDIR)$(INCLUDEDIR)/qoi.h
35+
2036
.PHONY: clean
2137
clean:
2238
$(RM) $(TARGET_BENCH) $(TARGET_CONV)

0 commit comments

Comments
 (0)