summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 76cb7d0374bbfbd9790366c079cc266800487abc (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Basic stuff
BACKEND_NAME ?= gutenprint52+usb
EXEC_NAME ?= dyesub_backend

# Destination directories (rely on CUPS to tell us where)
PREFIX ?=
CUPS_BACKEND_DIR ?= $(PREFIX)`cups-config --serverbin`/backend
CUPS_DATA_DIR ?= $(PREFIX)`cups-config --datadir`
BACKEND_DATA_DIR ?= $(PREFIX)/usr/local/share/gutenprint/backend_data

# Tools
CC ?= $(CROSS_COMPILE)gcc
LD ?= $(CROSS_COMPILE)gcc
CPPCHECK ?= cppcheck
MKDIR ?= mkdir
INSTALL ?= install
LN ?= ln
RM ?= rm

# Flags
CFLAGS += -Wall -Wextra -g -Os -D_GNU_SOURCE -std=c99 # -Wconversion
LDFLAGS += `pkg-config --libs libusb-1.0` 
CPPFLAGS += `pkg-config --cflags libusb-1.0`
# CPPFLAGS += -DLIBUSB_PRE_1_0_10
CPPFLAGS += -DURI_PREFIX=\"$(BACKEND_NAME)\"

# If you want to use LTO..
#CFLAGS += -flto
# If not...
CFLAGS += -funit-at-a-time

# List of backends
BACKENDS = sonyupdr150 kodak6800 kodak1400 shinkos2145 shinkos1245 canonselphy mitsu70x kodak605 dnpds40 citizencw01 mitsu9550 shinkos6245 shinkos6145 canonselphyneo mitsup95d

# For the s6145 and mitsu70x backends
CPPFLAGS += -DUSE_DLOPEN
LDFLAGS += -ldl
#CPPFLAGS += -DUSE_LTDL
#LDFLAGS += -lltdl

# Build stuff
DEPS += backend_common.h
SOURCES = backend_common.c $(addsuffix .c,$(addprefix backend_,$(BACKENDS)))

# Backend-specific joy:
backend_mitsu70x.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\" -include lib70x/libMitsuD70ImageReProcess.h

# And now the rules!
.PHONY: clean all install cppcheck

all: $(EXEC_NAME) $(BACKENDS)

%.o: %.c $(DEPS)
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

$(EXEC_NAME): $(SOURCES:.c=.o) $(DEPS)
	$(CC) -o $@ $(SOURCES:.c=.o) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

$(BACKENDS): $(EXEC_NAME)
	$(LN) -sf $(EXEC_NAME) $@

cppcheck:
	$(CPPCHECK) -q -v --std=c99 --enable=all -I/usr/include $(CPPFLAGS) $(SOURCES)

install:
	$(MKDIR) -p $(CUPS_BACKEND_DIR)
	$(INSTALL) -o root -m 700 $(EXEC_NAME) $(CUPS_BACKEND_DIR)/$(BACKEND_NAME)
	$(MKDIR) -p $(CUPS_DATA_DIR)/usb
	$(INSTALL) -o root -m 644 blacklist $(CUPS_DATA_DIR)/usb/net.sf.gimp-print.usb-quirks

clean:
	$(RM) -f $(EXEC_NAME) $(BACKENDS) $(SOURCES:.c=.o)

release:
	$(RM) -Rf selphy_print-rel
	$(MKDIR) -p selphy_print-rel
	cp -a *.c *.h Makefile blacklist COPYING README lib6145 D70 selphy_print-rel
	tar -czvf selphy_print-rel.tar.gz selphy_print-rel
	$(RM) -Rf selphy_print-rel