build: Clean up the makefile a bit. Use c99 to build.

This commit is contained in:
Solomon Peachy 2015-07-24 23:37:12 -04:00
parent 5ffc5f3f8e
commit 79279ee4ea
1 changed files with 31 additions and 20 deletions

View File

@ -1,40 +1,51 @@
BACKEND_NAME = gutenprint52+usb
EXEC_NAME = dyesub_backend
# Basic stuff
BACKEND_NAME ?= gutenprint52+usb
EXEC_NAME ?= dyesub_backend
# CC ?= gcc
# DESTDIR ?=
# Destination directories
DESTDIR ?=
CUPS_BACKEND_DIR ?= $(DESTDIR)/usr/lib/cups/backend
CUPS_DATA_DIR ?= $(DESTDIR)/usr/share/cups
CFLAGS = -Wall -Wextra -g -Os
# Tools
CC ?= gcc
CPPCHECK = cppcheck
MKDIR = mkdir
INSTALL = install
LN = ln
RM = rm
# Flags
CFLAGS = -Wall -Wextra -g -Os -D_GNU_SOURCE -std=c99
LDFLAGS = `pkg-config --libs libusb-1.0`
CPPFLAGS = `pkg-config --cflags libusb-1.0`
CUPS_BACKEND_DIR = $(DESTDIR)/usr/lib/cups/backend
CUPS_DATA_DIR = $(DESTDIR)/usr/share/cups
CPPFLAGS += `pkg-config --cflags libusb-1.0`
# CPPFLAGS += -DLIBUSB_PRE_1_0_10
CPPFLAGS += -DURI_PREFIX=\"$(BACKEND_NAME)\"
# List of backends
BACKENDS = sonyupdr150 kodak6800 kodak1400 shinkos2145 shinkos1245 canonselphy mitsu70x kodak605 dnpds40 citizencw01 mitsu9550 shinkos6245
# Build stuff
DEPS = backend_common.h
SOURCES = backend_common.c $(addsuffix .c,$(addprefix backend_,$(BACKENDS)))
# CFLAGS += -DLIBUSB_PRE_1_0_10
# And now the rules!
all: $(EXEC_NAME) $(BACKENDS)
$(EXEC_NAME): $(SOURCES) $(DEPS)
$(CC) -o $@ $(SOURCES) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -DURI_PREFIX=\"$(BACKEND_NAME)\"
$(CC) -o $@ $(SOURCES) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
$(BACKENDS): $(EXEC_NAME)
ln -sf $(EXEC_NAME) $@
$(LN) -sf $(EXEC_NAME) $@
cppcheck:
cppcheck -q -v --std=c99 --enable=all -I/usr/include $(CPPFLAGS) -DURI_PREFIX=\"$(BACKEND_NAME)\" $(SOURCES)
$(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
$(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)
$(RM) -f $(EXEC_NAME) $(BACKENDS)