forked from mcdope/pam_usb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
143 lines (116 loc) · 3.86 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Set to 'yes' to include debugging information, e.g. DEBUG=yes make -e
DEBUG := no
PREFIX ?= /usr
ARCH := $(shell uname -m)
UID := $(shell id -u)
GID := $(shell id -g)
USE_FEDORA_LIBDIR := $(shell test -d /lib64/security && echo 1 || echo 0)
ifeq ($(ARCH), x86_64)
ifeq ($(USE_FEDORA_LIBDIR), 1)
LIBDIR ?= lib64
else
LIBDIR ?= lib/x86_64-linux-gnu
endif
endif
ifeq ($(ARCH), i686)
LIBDIR ?= lib
endif
# compiler/linker options
CC := gcc
CFLAGS := $(CFLAGS) -Wall -fPIC `pkg-config --cflags libxml-2.0` \
`pkg-config --cflags udisks2`
LIBS := `pkg-config --libs libxml-2.0` \
`pkg-config --libs udisks2`
# common source files
SRCS := src/conf.c \
src/mem.c \
src/log.c \
src/xpath.c \
src/pad.c \
src/volume.c \
src/process.c \
src/tmux.c \
src/local.c \
src/device.c
OBJS := $(SRCS:.c=.o)
# pam_usb
PAM_USB_SRCS := src/pam.c
PAM_USB_OBJS := $(PAM_USB_SRCS:.c=.o)
PAM_USB := pam_usb.so
PAM_USB_LDFLAGS := -shared
PAM_USB_DEST := $(DESTDIR)/$(LIBDIR)/security
# pamusb-check
PAMUSB_CHECK_SRCS := src/pamusb-check.c
PAMUSB_CHECK_OBJS := $(PAMUSB_CHECK_SRCS:.c=.o)
PAMUSB_CHECK := pamusb-check
# Tools
PAMUSB_CONF := pamusb-conf
PAMUSB_AGENT := pamusb-agent
PAMUSB_KEYRING_GNOME := pamusb-keyring-unlock-gnome
TOOLS_DEST := $(DESTDIR)$(PREFIX)/bin
TOOLS_SRC := tools
# Conf
CONFS := doc/pam_usb.conf
CONFS_DEST := $(DESTDIR)/etc/security
# Doc
DOCS := doc/CONFIGURATION doc/QUICKSTART
DOCS_DEST := $(DESTDIR)$(PREFIX)/share/doc/pam_usb
# Man
MANS := doc/pamusb-conf.1.gz doc/pamusb-agent.1.gz doc/pamusb-check.1.gz doc/pamusb-keyring-unlock-gnome.1.gz
MANS_DEST := $(DESTDIR)$(PREFIX)/share/man/man1
# PAM config
PAM_CONF := debian/pam-auth-update/usb
PAM_CONF_DEST := $(DESTDIR)$(PREFIX)/share/pam-configs
PAM_AUTH_UPDATE := pam-auth-update
# Binaries
RM := rm
INSTALL := install
MKDIR := mkdir
DEBUILD := debuild -b -uc -us --lintian-opts --profile debian
MANCOMPILE := gzip -kf
DOCKER := docker
ifeq (yes, ${DEBUG})
CFLAGS := ${CFLAGS} -ggdb
endif
all : manpages $(PAM_USB) $(PAMUSB_CHECK)
$(PAM_USB) : $(OBJS) $(PAM_USB_OBJS)
$(CC) -o $(PAM_USB) $(PAM_USB_LDFLAGS) $(LDFLAGS) $(OBJS) $(PAM_USB_OBJS) $(LIBS)
$(PAMUSB_CHECK) : $(OBJS) $(PAMUSB_CHECK_OBJS)
$(CC) -o $(PAMUSB_CHECK) $(LDFLAGS) $(OBJS) $(PAMUSB_CHECK_OBJS) $(LIBS)
%.o : %.c
${CC} -c ${CFLAGS} $< -o $@
clean :
$(RM) -f $(MANS) $(PAM_USB) $(PAMUSB_CHECK) $(OBJS) $(PAMUSB_CHECK_OBJS) $(PAM_USB_OBJS)
manpages:
$(MANCOMPILE) ./doc/*.1
install : all
$(MKDIR) -p $(CONFS_DEST) $(DOCS_DEST) $(MANS_DEST) $(TOOLS_DEST) $(PAM_USB_DEST) $(PAM_CONF_DEST)
$(INSTALL) -m755 $(PAM_USB) $(PAM_USB_DEST)
$(INSTALL) -m755 $(PAMUSB_CHECK) $(TOOLS_SRC)/$(PAMUSB_CONF) $(TOOLS_SRC)/$(PAMUSB_AGENT) $(TOOLS_SRC)/$(PAMUSB_KEYRING_GNOME) $(TOOLS_DEST)
$(INSTALL) -b -m644 $(CONFS) $(CONFS_DEST)
$(INSTALL) -m644 $(DOCS) $(DOCS_DEST)
$(INSTALL) -m644 $(MANS) $(MANS_DEST)
$(INSTALL) -m644 $(PAM_CONF) $(PAM_CONF_DEST)/libpam-usb
deinstall :
$(RM) -f $(PAM_USB_DEST)/$(PAM_USB)
$(RM) -f $(TOOLS_DEST)/$(PAMUSB_CHECK) $(TOOLS_DEST)/$(PAMUSB_CONF) $(TOOLS_DEST)/$(PAMUSB_AGENT) $(TOOLS_DEST)/$(PAMUSB_KEYRING_GNOME) $(PAM_CONF_DEST)/$(PAM_CONF)
$(RM) -rf $(DOCS_DEST)
$(RM) -f $(MANS_DEST)/pamusb-*\.1\.gz
$(RM) -f $(PAM_CONF_DEST)/$(PAM_CONF)
changelog :
git log --pretty=format:"%h %ad%x09%an%x09%s" --date=short 40b17fa..HEAD > changelog-from-v0.5.0
debchangelog :
git log --pretty=format:" * %s (%an <%ae>)" --date=short 40b17fa..HEAD > changelog-for-deb
deb : clean all
$(DEBUILD)
deb-sign : build
debsign -S -k$(APT_SIGNING_KEY) `ls -t .build/*.changes | head -1`
buildenv :
$(DOCKER) build -t mcdope/pam_usb-ubuntu-build .
build : buildenv
mkdir -p .build
$(DOCKER) run -it \
-v`pwd`/.build:/usr/local/src \
-v`pwd`:/usr/local/src/pam_usb \
--rm mcdope/pam_usb-ubuntu-build \
sh -c "make deb && chown $(UID):$(GID) ../libpam-usb*"