-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (49 loc) · 1.32 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# qrscan -- QR-Code Scanner
# Copyright (C) 2024 Zhang, Zepeng <redraiment@gmail.com>
PKG_CONFIG := $(shell which pkg-config)
ifeq ($(PKG_CONFIG),)
$(error pkg-config not installed)
endif
ifneq ($(shell $(PKG_CONFIG) --exists libpng && echo $$?),0)
$(error libpng not found)
endif
ifneq ($(shell $(PKG_CONFIG) --exists libjpeg && echo $$?),0)
$(error libjpeg not found)
endif
CC ?= gcc
PREFIX ?= /usr/local
QUIRC = quirc/lib
OBJS = \
$(QUIRC)/decode.o \
$(QUIRC)/identify.o \
$(QUIRC)/quirc.o \
$(QUIRC)/version_db.o \
src/main.o \
src/options.o \
src/qrcode.o \
src/image.o \
src/png_reader.o \
src/jpg_reader.o
TARGET = qrscan
CFLAGS += -I$(QUIRC) $(shell $(PKG_CONFIG) --cflags --static libpng libjpeg)
LDFLAGS += -lz -lm
ifeq ($(shell uname -s),Darwin)
GROUP = staff
LDFLAGS += $(shell $(PKG_CONFIG) --variable=libdir --static libpng)/libpng.a
LDFLAGS += $(shell $(PKG_CONFIG) --variable=libdir --static libjpeg)/libjpeg.a
else
GROUP = root
LDFLAGS += -static $(shell $(PKG_CONFIG) --libs --static libpng libjpeg)
endif
.PHONY: all install uninstall clean
all: $(OBJS)
$(CC) $^ $(LDFLAGS) -O2 -Wall -fPIC -o $(TARGET)
.c.o:
$(CC) $< $(CFLAGS) -c -o $@
install: all
install -o root -g $(GROUP) -m 0755 $(TARGET) $(PREFIX)/bin
uninstall:
rm -f $(PREFIX)/bin/$(TARGET)
clean:
rm -f $(OBJS)
rm -f $(TARGET)