File: Makefile

package info (click to toggle)
google-compute-image-packages 20190124-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,344 kB
  • sloc: python: 6,338; sh: 1,748; cpp: 1,535; ansic: 404; makefile: 160
file content (154 lines) | stat: -rw-r--r-- 5,778 bytes parent folder | download | duplicates (2)
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
144
145
146
147
148
149
150
151
152
153
154
SHELL = /bin/sh

BASENAME = oslogin
NAME = google-compute-engine-$(BASENAME)
MAJOR = 1
MINOR = 4
REVISION = 3

LIBNSS_CACHE_OSLOGIN = libnss_cache_$(BASENAME)
LIBNSS_CACHE_OSLOGIN_NAME = libnss_cache_$(NAME)-$(MAJOR).$(MINOR).$(REVISION).so
LIBNSS_CACHE_OSLOGIN_SONAME = $(LIBNSS_CACHE_OSLOGIN).so.2
NSS_LIBRARY_NAME = libnss_$(NAME)-$(MAJOR).$(MINOR).$(REVISION).so
NSS_LIBRARY_SONAME = libnss_$(BASENAME).so.2
NSS_INSTALL_PATH = /lib
PAM_INSTALL_PATH = /lib/security
AUTHKEYS_INSTALL_PATH = /usr/bin

JSON_INCLUDE_PATH = /usr/include/json-c
INCLUDE_FLAGS = -I$(JSON_INCLUDE_PATH)

CXX ?= g++
CXXFLAGS += -fPIC# -Wall
CC ?= gcc
PAMFLAGS = $(LDFLAGS) $(INCLUDE_FLAGS) -shared
NSSFLAGS = $(LDFLAGS) $(INCLUDE_FLAGS) -shared -Wl,-soname,$(NSS_LIBRARY_SONAME)
LIBNSSFLAGS = $(LDFLAGS) -Wall -Wstrict-prototypes -fPIC -g
LIBNSS_SO_FLAGS = $(LIBNSSFLAGS) -shared -Wl,-soname,$(LIBNSS_CACHE_OSLOGIN_SONAME)

# UTILS
UTILS_DIR = utils
UTILS_SRC = $(UTILS_DIR)/$(BASENAME)_utils.cc
UTILS = $(UTILS_DIR)/$(BASENAME)_utils.o

# AUTHORIZED KEYS
AUTHKEYS_DIR = authorized_keys
AUTHKEYS_SRC = $(AUTHKEYS_DIR)/authorized_keys.cc
AUTHKEYS_BIN = google_authorized_keys

# NSS
NSS = nss_$(BASENAME)
NSS_DIR = nss_module
NSS_SRC = $(NSS_DIR)/$(NSS).cc

# NSS CACHE
NSS_CACHE = nss_cache
NSS_CACHE_DIR = nss_cache
NSS_CACHE_BIN = google_$(BASENAME)_nss_cache
NSS_CACHE_SRC = $(NSS_CACHE_DIR)/$(NSS_CACHE).cc

# LIBNSS OSLOGIN CACHE
LIBNSS_CACHE_OSLOGIN_DIR = $(LIBNSS_CACHE_OSLOGIN)
LIBNSS_CACHE = nss_cache_$(BASENAME)
LIBNSS_CACHE_SRC = $(LIBNSS_CACHE_OSLOGIN_DIR)/$(LIBNSS_CACHE).c
LIBNSS_CACHE_OBJ = $(LIBNSS_CACHE_OSLOGIN_DIR)/$(LIBNSS_CACHE).o
LIBNSS_COMPAT = compat/getpwent_r
LIBNSS_COMPAT_SRC = $(LIBNSS_CACHE_OSLOGIN_DIR)/$(LIBNSS_COMPAT).c
LIBNSS_COMPAT_OBJ = $(LIBNSS_CACHE_OSLOGIN_DIR)/$(LIBNSS_COMPAT).o

# PAM
PAM = pam_$(BASENAME)
PAM_DIR = pam_module
PAM_ADMIN = $(PAM)_admin
PAM_ADMIN_SRC = $(PAM_DIR)/$(PAM_ADMIN).cc
PAM_ADMIN_OBJ = $(PAM_DIR)/$(PAM_ADMIN).o
PAM_ADMIN_MOD = $(PAM_ADMIN).so
PAM_LOGIN = $(PAM)_login
PAM_LOGIN_SRC = $(PAM_DIR)/$(PAM_LOGIN).cc
PAM_LOGIN_OBJ = $(PAM_DIR)/$(PAM_LOGIN).o
PAM_LOGIN_MOD = $(PAM_LOGIN).so

# HELPER SCRIPTS
BIN_DIR = bin
OSLOGIN_HELPER = $(BIN_DIR)/google_oslogin_control
BIN_INSTALL_PATH = /usr/bin

# SELINUX POLICY
INSTALL_SELINUX =
POLICY_DIR = policy
SELINUX_INSTALL_NAME = oslogin.pp
SELINUX_MODULE = $(POLICY_DIR)/$(SELINUX_INSTALL_NAME)
SELINUX_INSTALL_PATH = /usr/share/selinux/packages

LIBS = -lcurl -ljson-c
PAM_LIBS = -lpam $(LIBS)

ifdef INSTALL_SELINUX
all: $(NSS) $(NSS_CACHE_BIN) $(LIBNSS_CACHE_OSLOGIN_NAME) $(PAM) $(AUTHKEYS_BIN)
else
all: $(NSS) $(NSS_CACHE_BIN) $(LIBNSS_CACHE_OSLOGIN_NAME) $(PAM) $(AUTHKEYS_BIN)
endif

$(NSS): $(NSS_LIBRARY_SOURCE) $(UTILS)
	$(CXX) $(CXXFLAGS) $(NSSFLAGS) -o $(NSS_LIBRARY_NAME) \
	$(NSS_SRC) $(UTILS) $(LIBS)

$(NSS_CACHE_BIN): $(NSS_CACHE_SRC) $(UTILS_SRC)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDE_FLAGS) -o $(NSS_CACHE_BIN) $(NSS_CACHE_SRC) $(UTILS_SRC) $(LIBS)

$(LIBNSS_CACHE_OSLOGIN_NAME): $(LIBNSS_CACHE_OBJ) $(LIBNSS_COMPAT_OBJ)
	$(CXX) $(LIBNSS_SO_FLAGS) -o $(LIBNSS_CACHE_OSLOGIN_NAME) $(LIBNSS_CACHE_OBJ) $(LIBNSS_COMPAT_OBJ)

$(LIBNSS_CACHE_OBJ): $(LIBNSS_CACHE_SRC)
	$(CC) $(LIBNSSFLAGS) -c -o $(LIBNSS_CACHE_OBJ) $(LIBNSS_CACHE_SRC)

$(LIBNSS_COMPAT_OBJ): $(LIBNSS_COMPAT_SRC)
	$(CC) $(LIBNSSFLAGS) -c -o $(LIBNSS_COMPAT_OBJ) $(LIBNSS_COMPAT_SRC)

$(PAM): $(PAM_ADMIN_MOD) $(PAM_LOGIN_MOD)

$(PAM_LOGIN_MOD): $(PAM_LOGIN_OBJ) $(UTILS)
	$(CXX) $(PAMFLAGS) -o $(PAM_LOGIN_MOD) $(PAM_LOGIN_OBJ) $(UTILS) $(PAM_LIBS)

$(PAM_ADMIN_MOD): $(PAM_ADMIN_OBJ) $(UTILS)
	$(CXX) $(PAMFLAGS) -o $(PAM_ADMIN_MOD) $(PAM_ADMIN_OBJ) $(UTILS) $(PAM_LIBS)

$(PAM_LOGIN_OBJ): $(PAM_LOGIN_SRC)
	$(CXX) $(CXXFLAGS) -c $(PAM_LOGIN_SRC) -o $(PAM_LOGIN_OBJ)

$(PAM_ADMIN_OBJ): $(PAM_ADMIN_SRC)
	$(CXX) $(CXXFLAGS) -c $(PAM_ADMIN_SRC) -o $(PAM_ADMIN_OBJ)

$(AUTHKEYS_BIN): $(AUTHKEYS_SRC) $(UTILS_SRC)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDE_FLAGS) -o $(AUTHKEYS_BIN) $(AUTHKEYS_SRC) $(UTILS_SRC) $(LIBS)

$(UTILS): $(UTILS_SRC)
	$(CXX) $(CXXFLAGS) $(INCLUDE_FLAGS) -c $(UTILS_SRC) -o $(UTILS)

install: $(NSS_LIBRARY_NAME) $(LIBNSS_OSLOGIN_CACHE_NAME) $(PAM_ADMIN_MOD) $(PAM_LOGIN_MOD) $(AUTHKEYS_BIN) $(NSS_CACHE_BIN)
	mkdir -p $(DESTDIR)$(PREFIX)/$(NSS_INSTALL_PATH)
	mkdir -p $(DESTDIR)$(PREFIX)/$(PAM_INSTALL_PATH)
	mkdir -p $(DESTDIR)$(PREFIX)/$(AUTHKEYS_INSTALL_PATH)
	mkdir -p $(DESTDIR)$(PREFIX)/$(BIN_INSTALL_PATH)
	install -m 0644 $(LIBNSS_CACHE_OSLOGIN_NAME) $(DESTDIR)$(PREFIX)/$(NSS_INSTALL_PATH)
	install -m 0644 $(NSS_LIBRARY_NAME) $(DESTDIR)$(PREFIX)/$(NSS_INSTALL_PATH)
	install -m 0644 $(PAM_ADMIN_MOD) $(PAM_LOGIN_MOD) $(DESTDIR)$(PREFIX)/$(PAM_INSTALL_PATH)
	install -m 0755 $(AUTHKEYS_BIN) $(DESTDIR)$(PREFIX)/$(AUTHKEYS_INSTALL_PATH)
	install -m 0755 $(OSLOGIN_HELPER) $(DESTDIR)$(PREFIX)/$(BIN_INSTALL_PATH)
	install -m 0755 $(NSS_CACHE_BIN) $(DESTDIR)$(PREFIX)/$(BIN_INSTALL_PATH)
ifdef INSTALL_SELINUX
	mkdir -p $(DESTDIR)$(PREFIX)/$(SELINUX_INSTALL_PATH)
	install -T -m 0644 $(SELINUX_MODULE) $(DESTDIR)$(PREFIX)/$(SELINUX_INSTALL_PATH)/$(SELINUX_INSTALL_NAME)
endif

uninstall:
	rm -f $(DESTDIR)$(PREFIX)/$(NSS_INSTALL_PATH)/$(LIBNSS_CACHE_OSLOGIN_NAME)
	rm -f $(DESTDIR)$(PREFIX)/$(NSS_INSTALL_PATH)/$(NSS_LIBRARY_NAME)
	rm -f $(DESTDIR)$(PREFIX)/$(PAM_INSTALL_PATH)/$(PAM_ADMIN_MOD)
	rm -f $(DESTDIR)$(PREFIX)/$(PAM_INSTALL_PATH)/$(PAM_LOGIN_MOD)
	rm -f $(DESTDIR)$(PREFIX)/$(AUTHKEYS_INSTALL_PATH)/$(AUTHKEYS_BIN)
	rm -f $(DESTDIR)$(PREFIX)/$(BIN_INSTALL_PATH)/$(OSLOGIN_HELPER)
	rm -f $(DESTDIR)$(PREFIX)/$(BIN_INSTALL_PATH)/$(NSS_CACHE_BIN)
clean:
	rm -f $(UTILS) $(NSS_LIBRARY_NAME) $(LIBNSS_CACHE_OSLOGIN_NAME) $(LIBNSS_CACHE_OBJ) $(LIBNSS_COMPAT_OBJ) $(PAM_ADMIN_OBJ) $(PAM_ADMIN_MOD) $(PAM_LOGIN_OBJ) $(PAM_LOGIN_MOD) $(AUTHKEYS_BIN) $(NSS_CACHE_BIN)