]> granicus.if.org Git - linux-pam/blob - libpam/Makefile
80fbf9572ed6a9dc7e16cf01a9736c8745a4aa26
[linux-pam] / libpam / Makefile
1 #
2 # $Id$
3 #
4 #
5
6 include ../Make.Rules
7
8 # need to tell libpam about the default directory for PAMs
9 MOREFLAGS=-D"DEFAULT_MODULE_PATH=\"$(SECUREDIR)/\""
10
11 ifeq ($(WITH_LIBDEBUG),yes)
12  LIBNAME=libpamd
13 else
14  LIBNAME=libpam
15 endif
16 VERSION=.$(MAJOR_REL)
17 MODIFICATION=.$(MINOR_REL)
18
19 # ---------------------------------------------
20
21 dummy: ../Make.Rules all
22
23 # ---------------------------------------------
24
25 CFLAGS += $(DYNAMIC) $(STATIC) $(MOREFLAGS) \
26   -DLIBPAM_VERSION_MAJOR=$(MAJOR_REL) \
27   -DLIBPAM_VERSION_MINOR=$(MINOR_REL)
28
29 # dynamic library names
30
31 LIBPAM = $(LIBNAME).$(DYNTYPE)
32 LIBPAMNAME = $(LIBPAM)$(VERSION)
33 LIBPAMFULL = $(LIBPAMNAME)$(MODIFICATION)
34
35 # static library name
36
37 LIBPAMSTATIC = $(LIBNAME).a
38
39 ifdef STATIC
40 @echo Did you mean to set STATIC\?
41 MODULES = $(shell cat ../modules/_static_module_objects)
42 STATICOBJ = pam_static.o
43 else
44 MODULES =
45 endif
46
47 ifdef MEMORY_DEBUG
48 EXTRAS += pam_malloc.o
49 endif
50
51 LIBOBJECTS = pam_item.o pam_strerror.o pam_end.o pam_start.o pam_data.o \
52                 pam_delay.o pam_dispatch.o pam_handlers.o pam_misc.o \
53                 pam_account.o pam_auth.o pam_session.o pam_password.o \
54                 pam_env.o pam_log.o $(EXTRAS)
55
56 ifeq ($(DYNAMIC_LIBPAM),yes)
57 # libpam.so needs -ldl, too.
58 DLIBOBJECTS = $(addprefix dynamic/,$(LIBOBJECTS) $(STATICOBJ))
59 ifeq ($(STATICOBJ),yes)
60 dynamic/pam_static.o: pam_static.c ../modules/_static_module_objects
61         $(CC) $(CFLAGS) -c pam_static.c -o $@
62 endif
63 endif
64
65 ifeq ($(STATIC_LIBPAM),yes)
66 SLIBOBJECTS = $(addprefix static/,$(LIBOBJECTS) $(STATICOBJ))
67 ifdef STATICOBJ
68 static/pam_static.o: pam_static.c ../modules/_static_module_objects
69         $(CC) $(CFLAGS) -c pam_static.c -o $@
70 endif
71 endif
72
73 # ---------------------------------------------
74 ## rules
75
76 all: dirs $(LIBPAM) $(LIBPAMSTATIC) ../Make.Rules
77
78 dirs:
79 ifeq ($(DYNAMIC_LIBPAM),yes)
80         $(MKDIR) dynamic
81 endif
82 ifeq ($(STATIC_LIBPAM),yes)
83         $(MKDIR) static
84 endif
85
86 dynamic/%.o : %.c
87         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
88
89 static/%.o : %.c
90         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
91
92 $(LIBPAM): $(DLIBOBJECTS)
93 ifeq ($(DYNAMIC_LIBPAM),yes)
94     ifeq ($(USESONAME),yes)
95         $(LD_L) $(SOSWITCH) $(LIBPAMNAME) -o $@ $(DLIBOBJECTS) \
96                 $(MODULES) $(LINKLIBS)
97     else
98         $(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
99     endif
100     ifeq ($(NEEDSONAME),yes)
101         rm -f $(LIBPAMFULL)
102         ln -sf $(LIBPAM) $(LIBPAMFULL)
103         rm -f $(LIBPAMNAME)
104         ln -sf $(LIBPAM) $(LIBPAMNAME)
105     endif
106 endif
107
108 $(LIBPAMSTATIC): $(SLIBOBJECTS)
109 ifeq ($(STATIC_LIBPAM),yes)
110         ar cr $@ $(SLIBOBJECTS) $(MODULES)
111         $(RANLIB) $@
112 endif
113
114 install: all
115         $(MKDIR) $(FAKEROOT)$(INCLUDED) $(FAKEROOT)$(libdir)
116         $(INSTALL) -m 644 include/security/pam_appl.h $(FAKEROOT)$(INCLUDED)
117         $(INSTALL) -m 644 include/security/pam_modules.h $(FAKEROOT)$(INCLUDED)
118         $(INSTALL) -m 644 include/security/_pam_macros.h $(FAKEROOT)$(INCLUDED)
119         $(INSTALL) -m 644 include/security/_pam_types.h $(FAKEROOT)$(INCLUDED)
120         $(INSTALL) -m 644 include/security/_pam_compat.h $(FAKEROOT)$(INCLUDED)
121 ifdef MEMORY_DEBUG
122         $(INSTALL) -m 644 include/security/pam_malloc.h $(FAKEROOT)$(INCLUDED)
123 endif
124 ifeq ($(DYNAMIC_LIBPAM),yes)
125         $(INSTALL) -m $(SHLIBMODE) $(LIBPAM) $(FAKEROOT)$(libdir)/$(LIBPAMFULL)
126         $(LDCONFIG)
127   ifneq ($(DYNTYPE),"sl")
128         ( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBPAM) ; \
129           ln -sf $(LIBPAMNAME) $(LIBPAM) )
130   endif
131 endif
132 ifeq ($(STATIC_LIBPAM),yes)
133         $(INSTALL) -m 644 $(LIBPAMSTATIC) $(FAKEROOT)$(libdir)
134 endif
135
136 remove:
137         rm -f $(FAKEROOT)$(INCLUDED)/_pam_types.h
138         rm -f $(FAKEROOT)$(INCLUDED)/_pam_macros.h
139         rm -f $(FAKEROOT)$(INCLUDED)/pam_appl.h
140         rm -f $(FAKEROOT)$(INCLUDED)/pam_modules.h
141         rm -f $(FAKEROOT)$(INCLUDED)/pam_malloc.h
142         rm -f $(FAKEROOT)$(libdir)/$(LIBPAM).*
143         rm -f $(FAKEROOT)$(libdir)/$(LIBPAM)
144         $(LDCONFIG)
145         rm -f $(FAKEROOT)$(libdir)/$(LIBPAMSTATIC)
146
147 clean:
148         rm -f a.out core *~ static/*.o dynamic/*.o
149         rm -f *.a *.o *.so ./include/security/*~
150         if [ -d dynamic ]; then rmdir dynamic ; fi
151         if [ -d static ]; then rmdir static ; fi