summaryrefslogtreecommitdiff
path: root/Makefile
blob: f2fd8f968951ad31e0115f964d6e9012eea588f2 (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

NAME_SOURCE=nss_mapname.c map_common.c
NSSNAMELIB =libnss_mapname.so.2
UID_SOURCE=nss_mapuid.c map_common.c
NSSUIDLIB =libnss_mapuid.so.2

# set to x86_64-linux-gnu, arm-linux-gnueabi, etc. by packaging tools
# If not set, just install directly to /lib
LIBDIR=/lib/${DEB_TARGET_GNU_TYPE}

CC = gcc

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
		OPTFLAGS = -O2
else
		OPTFLAGS = -g3 -O0
endif
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
	STRIP = strip
    FVISIBILITY = -fvisibility=hidden
else
	STRIP=echo Nostrip
    FVISIBILITY = -fvisibility=default
endif

CPPFLAGS = -D_FORTIFY_SOURCE=2
CFLAGS = $(CPPFLAGS) ${OPTFLAGS} -fPIC -fstack-protector-strong \
		 -Wformat -Werror=format-security -Wall $(FVISIBILITY)
LDLIBS = -laudit
LDFLAGS = -shared  -fPIC -DPIC \
		  -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,-soname -Wl,$@ $(LDLIBS)

all: $(NSSNAMELIB) $(NSSUIDLIB)

$(NSSUIDLIB): $(UID_SOURCE:.c=.o)
	$(CC) $(LDFLAGS) $^ -o $@

$(NSSNAMELIB): $(NAME_SOURCE:.c=.o)
	$(CC) $(LDFLAGS) $^ -o $@

install: all
	install -m 755 -d $(DESTDIR)/$(LIBDIR) $(DESTDIR)/etc
	install -m 644 $(NSSNAMELIB) $(NSSUIDLIB) $(DESTDIR)$(LIBDIR)
	$(STRIP) --strip-all --keep-symbol=_nss_mapname_getpwnam_r \
			$(DESTDIR)$(LIBDIR)/${NSSNAMELIB}
	$(STRIP) --strip-all --keep-symbol=_nss_mapuid_getpwuid_r \
			$(DESTDIR)$(LIBDIR)/${NSSUIDLIB}
	install -m 644 nss_mapuser.conf $(DESTDIR)/etc/

clean:
	rm -f *.o $(NSSNAMELIB) $(NSSUIDLIB)

.PHONY: all install clean distclean