-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
113 lines (94 loc) · 3.94 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
SHELL=/bin/bash
user_name=$(shell whoami)
user_id=$(shell id -u)
INCLUDES=\
-Iaws-sdk-cpp/aws-cpp-sdk-core/include \
-Iaws-sdk-cpp/aws-cpp-sdk-iam/include \
-Iaws-sdk-cpp/aws-cpp-sdk-sts/include \
-Iaws-sdk-cpp/build/.deps/install/include
LIBS=\
aws-sdk-cpp/build/aws-cpp-sdk-iam/libaws-cpp-sdk-iam.a \
aws-sdk-cpp/build/aws-cpp-sdk-sts/libaws-cpp-sdk-sts.a \
aws-sdk-cpp/build/aws-cpp-sdk-core/libaws-cpp-sdk-core.a \
aws-sdk-cpp/build/.deps/install/lib/libaws-c-event-stream.a \
aws-sdk-cpp/build/.deps/install/lib/libaws-checksums.a \
aws-sdk-cpp/build/.deps/install/lib/libaws-c-common.a \
-lssl \
-lcrypto \
-lcurl \
-lpthread
CC=gcc
CPP=g++
DEBUG=-g
INSTALL=/usr/bin/install
INSTALL_PROGRAM=${INSTALL}
INSTALL_DATA=${INSTALL} -m 644
prefix=""
libnss_iam: iam libnss_iam.c
${CC} ${INCLUDES} ${DEBUG} -fPIC -Wall -shared -o libnss_iam.so.2 -Wl,-soname,libnss_iam.so.2 libnss_iam.c iam.o helper.o ${LIBS} -lstdc++
iam: helper.c iam.cpp
${CPP} ${INCLUDES} ${DEBUG} -c -O3 helper.c iam.cpp -std=c++11 -fno-exceptions helper.c -fpermissive -fPIC
pam: pam.cpp
${CPP} ${INCLUDES} ${DEBUG} -c -O3 pam.cpp -std=c++11 -fno-exceptions helper.c -fpermissive -fPIC
test: iam pam
${CC} -O3 -o iam test.c -fno-exceptions -fPIC -DTEST pam.o iam.o helper.o ${LIBS} -lstdc++
install:
# /lib/libnss_compat.so.2 -> libnss_compat-2.3.6.so
${INSTALL_DATA} libnss_iam.so.2 ${prefix}/lib/libnss_iam-2.3.6.so
cd ${prefix}/lib && ln -fs libnss_iam-2.3.6.so libnss_iam.so.2
ldconfig -n
DISTRO=ubuntu-18-04
docker-build:
docker build -t "sdk-builder-$(DISTRO)" \
--build-arg nonroot_user=$(user_name) \
--build-arg nonroot_uid=$(user_id) \
--file ./Dockerfile.$(DISTRO) .
docker-shell:
@docker run -it --rm \
--hostname "aws-sdk-builder-$(DISTRO)" \
--volume $(HOME)/.aws:/home/$(user_name)/.aws \
--volume $(HOME)/.ssh:/home/$(user_name)/.ssh \
--volume $(CURDIR):/home/$(user_name)/libnss-iam \
--user $(user_name) \
--workdir=/home/$(user_name)/libnss-iam \
--env PS1='\u:\w\$$ ' \
--entrypoint /bin/bash \
"sdk-builder-$(DISTRO)" \
deps:
if [[ ! -d aws-sdk-cpp ]]; then git clone https://github.com/aws/aws-sdk-cpp.git; fi
mkdir -p aws-sdk-cpp/build
(cd aws-sdk-cpp/build; cmake .. \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_ONLY="monitoring;sts;iam" \
-DAUTORUN_UNIT_TESTS=OFF \
-DBUILD_SHARED_LIBS=false)
(cd aws-sdk-cpp/build; make -j 1)
DPKG_VERSION=0.1
DPKG_ROOT=libnss-iam-$(DPKG_VERSION)
deb:
mkdir -p "$(DPKG_ROOT)/DEBIAN"
echo -e \
Package: libnss-iam \\n\
Version: $(DPKG_VERSION) \\n\
Architecture: amd64 \\n\
Maintainer: George Fleury \<gfleury@gmail.com\> \\n\
Homepage: https://github.com/gfleury/libnss-iam \\n\
Description: Lib NSS module to integrate IAM users/groups \\n\
> "$(DPKG_ROOT)/DEBIAN/control"
echo -e \
\#!/bin/sh \\n\
set -e \\n\
ldconfig -n \\n\
exit 0 \\n\
> "$(DPKG_ROOT)/DEBIAN/postinst" && chmod 755 "$(DPKG_ROOT)/DEBIAN/postinst"
mkdir -p "$(DPKG_ROOT)/lib/"
cp "libnss_iam.so.2" "$(DPKG_ROOT)/lib/libnss_iam-$(DPKG_VERSION).so"
chmod 644 "$(DPKG_ROOT)/lib/libnss_iam-$(DPKG_VERSION).so"
cd "$(DPKG_ROOT)/lib" && ln -fs "libnss_iam-$(DPKG_VERSION).so" "libnss_iam.so.2"
mkdir -p "$(DPKG_ROOT)/usr/local/bin"
cp "iam" "$(DPKG_ROOT)/usr/local/bin/iam"
dpkg-deb --build "$(DPKG_ROOT)"
clean:
rm -f libnss_iam.so.2 libnss_iam_test iam "$(DPKG_ROOT).deb"
rm -rf "$(DPKG_ROOT)"
rm -rf aws-sdk-cpp/build