]> granicus.if.org Git - linux-pam/blob - Makefile
Relevant BUGIDs: 124136
[linux-pam] / Makefile
1 ##
2 ## $Id$
3 ##
4
5 ## Note, ideally I would prefer it if this top level makefile did
6 ## not get created by autoconf. As I find typing 'make' and relying
7 ## on it to take care of all dependencies much more friendly than
8 ## the multi-stage autoconf+make and also worry about updates to
9 ## configure.in not getting propagated down the tree. (AGM) [I realise
10 ## that this may not prove possible, but at least I tried.. Sigh.]
11
12 DISTNAME=Linux-PAM
13
14 ifeq ($(shell test \! -f Make.Rules || echo yes),yes)
15     include Make.Rules
16 endif
17
18 THINGSTOMAKE = modules libpam libpamc libpam_misc doc examples
19
20 all: $(THINGSTOMAKE)
21
22 prep:
23         rm -f security
24         ln -sf . security
25
26 clean:
27         if [ ! -f Make.Rules ]; then touch Make.Rules ; fi
28         for i in $(THINGSTOMAKE) ; do $(MAKE) -C $$i clean ; done
29         rm -f security *~ *.orig *.rej Make.Rules #*#
30
31 distclean: clean
32         rm -f Make.Rules _pam_aconf.h
33         rm -f config.status config.cache config.log core
34
35 maintainer-clean: distclean
36         @echo files should be ok for packaging now.
37
38 # NB _pam_aconf.h.in changes will remake this too
39 Make.Rules: configure Make.Rules.in _pam_aconf.h.in
40         @echo XXX - not sure how to preserve past configure options..
41         @echo XXX - so not attempting to. Feel free to run ./configure
42         @echo XXX - by hand, with the options you want.
43         ./configure
44
45 _pam_aconf.h: Make.Rules
46
47 configure: configure.in
48         @echo
49         @echo You do not appear to have an up-to-date ./configure file.
50         @echo Please run autoconf, and then ./configure [..options..]
51         @echo
52         @rm -f configure
53         @exit 1
54
55 $(THINGSTOMAKE): _pam_aconf.h prep
56         $(MAKE) -C $@ all
57
58 install: _pam_aconf.h prep
59         $(MKDIR) $(FAKEROOT)$(INCLUDED)
60         $(INSTALL) -m 444 security/_pam_aconf.h $(FAKEROOT)$(INCLUDED)
61         for x in $(THINGSTOMAKE) ; do make -C $$x install ; done
62
63 remove:
64         rm -f $(FAKEROOT)$(INCLUDED)/_pam_aconf.h
65         for x in $(THINGSTOMAKE) ; do make -C $$x remove ; done
66
67 release:
68         @if [ ! -f Make.Rules ]; then echo make Make.Rules first ; exit 1; fi
69         @if [ ! -L ../$(DISTNAME)-$(MAJOR_REL).$(MINOR_REL) ]; then \
70            echo generating ../$(DISTNAME)-$(MAJOR_REL).$(MINOR_REL) link ; \
71            ln -sf $(DISTNAME) ../$(DISTNAME)-$(MAJOR_REL).$(MINOR_REL) ; \
72            echo to ../$(DISTNAME) . ; fi
73         @diff ../$(DISTNAME)-$(MAJOR_REL).$(MINOR_REL)/Make.Rules Make.Rules
74         make distclean
75         cd .. ; tar zvfc $(DISTNAME)-$(MAJOR_REL).$(MINOR_REL).tar.gz --exclude CVS --exclude .cvsignore --exclude '.#*' $(DISTNAME)-$(MAJOR_REL).$(MINOR_REL)/*
76
77 ## =================
78
79 ifdef LEGACY_OLD_MAKEFILE
80
81 # major and minor numbers of this release
82 MAJOR_REL=0
83 MINOR_REL=72
84 DEBUG_REL=no
85 #DEBUG_REL=yes
86
87 # this should be the name of this directory (under CVS)
88 DISTNAME = Linux-PAM
89 # this should be the name of this directory (when generating the release)
90 RELNAME = $(DISTNAME)-$(MAJOR_REL).$(MINOR_REL)
91
92 # this is the name of the archive file
93 DISTFILE = $(RELNAME).tar.gz
94
95 # define this to indicate to subdirectories that they are part of the 
96 # full source tree.
97 FULL_LINUX_PAM_SOURCE_TREE=yes
98 export FULL_LINUX_PAM_SOURCE_TREE
99
100 DYNLOAD="dl"
101 DYNTYPE="so"
102
103 # Comment out either line to disable that type of linking for *modules only*
104 # Both at once is a legal configuration!
105 DYNAMIC=-DPAM_DYNAMIC
106 #STATIC=-DPAM_STATIC
107
108 # Comment out these lines to disable building dynamic/static libpam.*
109 DYNAMIC_LIBPAM=yes
110 #STATIC_LIBPAM=yes
111
112 # All combinations of the above four variable definitions are legal,
113 # however, not defining either dynamic or static modules and yet
114 # creating a some flavor of LIBPAM will make an authentication library
115 # that always fails!
116
117 # Here we indicate which libraries are present on the local system
118 # they control the building of some modules in this distribution
119 # Note, these definitions are all "export"ed below...
120
121 HAVE_PWDBLIB=yes
122 HAVE_CRACKLIB=yes
123 HAVE_AFSLIBS=no
124 HAVE_KRBLIBS=no
125
126 # NB. The following is the generic defines for compilation.
127 # They can be overridden in the default.defs file below
128 #
129 WARNINGS = -ansi -D_POSIX_SOURCE -Wall -Wwrite-strings \
130         -Wpointer-arith -Wcast-qual -Wcast-align \
131         -Wtraditional -Wstrict-prototypes -Wmissing-prototypes \
132         -Wnested-externs -Winline -Wshadow -pedantic
133 PIC=-fPIC
134
135 # Mode to install shared libraries with
136 SHLIBMODE=755
137
138 #
139 # Conditional defines..
140 #
141
142 ifdef DYNAMIC
143 # need the dynamic library functions
144 LIBDL=-l$(DYNLOAD)
145 ifdef STATIC_LIBPAM
146 # needed because pam_xxx() fn's are now in statically linked library
147 RDYNAMIC = -rdynamic
148 endif
149 endif
150
151 # Here we include the defines for the preferred operating system
152 # these include things like CC, CFLAGS and destination directories 
153 # etc.. By default, this is a symbolic link to one of the .defs files
154 # the .../defs/ directory. Please take a moment to check that you are
155 # using the correct one.
156
157 include default.defs
158
159 # to turn on the fprintf(stderr, ..) debugging lines throughout the
160 # distribution uncomment this line
161 #EXTRAS += -DDEBUG
162
163 # For serious memory allocation tracing uncomment the following
164 #MEMORY_DEBUG=-DMEMORY_DEBUG
165
166 #######################################################################
167 # The pam_unix module in this file will not work on NIS based systems.#
168 #######################################################################
169
170 # ////////////////////////////////////////////////////
171 # // You should not modify anything below this line //
172 # ////////////////////////////////////////////////////
173
174 # the sub-directories to make things in
175
176 DIRS = modules libpam conf libpam_misc libpamc examples
177
178 #
179 # basic defines
180 #
181
182 INCLUDEDIR=-I$(shell pwd)/include
183 PAMLIB=-L$(shell pwd)/libpam
184 PAMMISCLIB=-L$(shell pwd)/libpam_misc
185 ifeq ($(DEBUG_REL),yes)
186  PAMLIB += -lpamd
187  PAMMISCLIB += -lpamd_misc
188 else
189  PAMLIB += -lpam
190  PAMMISCLIB += -lpam_misc
191 endif
192
193
194 # This is Linux-PAM and not a version from Sun etc..
195 # [Note, this does not describe the operating system you are using
196 # only that you are compiling the "Linux" (read FREE) implementation
197 # of Pluggable Authentication Modules.
198 EXTRAS += -DLINUX_PAM
199
200 #
201 # build composite defines
202 #
203
204 LOADLIBES = $(PAMLIB) $(RDYNAMIC) $(PAMMISCLIB) $(LIBDL) $(ULIBS)
205
206 CFLAGS += $(EXTRAS) $(MEMORY_DEBUG) $(WARNINGS) $(INCLUDEDIR) $(PIC)
207 ifneq ($(strip $(OS)),)
208 CFLAGS += -D$(OS)
209 endif
210 ifneq ($(strip $(ARCH)),)
211 CFLAGS += -D$(ARCH)
212 endif
213
214 #
215 # export the libraries-available info; the modules should know how
216 # to deal with this...
217 #
218 export HAVE_PWDBLIB             
219 export HAVE_CRACKLIB
220 export HAVE_AFSLIBS
221 export HAVE_KRBLIBS
222
223 #
224 # generic exports
225 #
226 export MAJOR_REL                # the major release of this distribution
227 export MINOR_REL                # the minor release of this distribution
228 export DEBUG_REL                # for installing a debugging version of PAM
229 export OS                       # operating system
230 export ARCH                     # architecture
231 export CC                       # the C compiler
232 export INSTALL                  # to do instalations with
233 export MKDIR                    # to ensure directories exist
234 export CFLAGS                   # CC flags used to compile everything
235 export LD_D                     # build a shared object file (module)
236 export LD_L                     # build a shared library (e.g. libpam)
237 export USESONAME                # does shlib link command require soname option
238 export SOSWITCH                 # shlib lib soname switch name
239 export LINKLIBS                 # libraries to append when making dynamic libs
240 export NEEDSONAME               # does shared library link need versioned lib
241 export LD                       # build a generic library
242 export LDCONFIG                 # rebuild the shared libraries
243 export AR                       # build a static library
244 export RANLIB                   # reorder a static library
245 export LOADLIBES                # libraries needed for application linking
246 export PAMLIB                   # where to find the local libpam.xx file
247 export DYNTYPE                  # which suffix is used for libraries
248 export SHLIBMODE                # file mode for shared objects
249 export EXTRALS                  # libraries that some modules need
250 export LIBDL                    # extra library for libpam.so
251 #
252 # where to install things
253 #
254 export FAKEROOT                 # for package maintainers
255 #
256 export PREFIX                   # basic prefix for all other directories
257 export SUPLEMENTED              # where to store module helper binaries
258 export LIBDIR                   # where libpam and libpam_misc go
259 export SECUREDIR                # where the modules will be placed
260 export INCLUDED                 # where to store pam---.h files
261 export CONFIGED                 # where pam.conf and pam.d/ go
262 export SCONFIGED                # where modules' config files go
263
264 #
265 # Conditional exporting ( ... these go on for a while... )
266 #
267 ifdef DYNAMIC 
268 export DYNAMIC
269 endif
270 ifdef STATIC
271 export STATIC
272 endif
273 ifdef DYNAMIC_LIBPAM
274 export DYNAMIC_LIBPAM
275 endif
276 ifdef STATIC_LIBPAM
277 export STATIC_LIBPAM
278 endif
279 ifdef MEMORY_DEBUG
280 export MEMORY_DEBUG
281 endif
282
283 ##
284 ## the rules
285 ##
286
287 all: .freezemake headers
288
289         @for i in $(DIRS) ; do \
290                 $(MAKE) -C $$i all ; \
291                 if [ $$? -ne 0 ]; then break ; fi ; \
292         done
293
294 .freezemake: Makefile
295         @touch .freezemake
296         @echo "*WARNING*: If you are running a system that is dependent"
297         @echo "  on PAM to work. DO NOT make sterile NOR make remove."
298         @echo "  These options will delete the PAM files on your system"
299         @echo "  and make it unusable!"
300         @echo ""
301         @echo "If you are in any doubt, just do 'make all' (or just"
302         @echo "'make'). It is likely that this is the SAFEST thing to do...."
303         @exit 1
304
305 install:
306         @for i in $(DIRS) ; do \
307                 $(MAKE) -C $$i install ; \
308                 if [ $$? -ne 0 ]; then break ; fi ; \
309         done
310
311 sterile: .freezemake
312         @$(MAKE) remove
313         @$(MAKE) extraclean
314
315 remove: .freezemake
316         @for i in $(DIRS) ; do \
317                 $(MAKE) -C $$i remove ; \
318         done
319
320 clean:
321         @rm -f *~ core
322         @for i in $(DIRS) ; do \
323                 $(MAKE) -C $$i clean ; \
324         done
325
326 headers:
327         @mkdir -p include/security && cd include/security \
328           && ln -fs ../../libpam/include/security/*.h . \
329           && ln -fs ../../libpam_misc/*.h . \
330           && ln -fs ../../libpamc/include/security/*.h .
331
332 cl_headers:
333         @cd include/security ; rm -f *.h
334
335 extraclean:
336         make cl_headers
337         @for i in $(DIRS) doc ; do \
338                 $(MAKE) -C $$i extraclean ; \
339         done
340
341 check:
342         @$(MAKE) -C conf check
343
344 open:
345         @find . \( -type f -a -perm 644 \) -print
346
347 release:
348         @egrep '^DEBUG\_REL\=yes' Makefile|grep -v grep > /dev/null ;\
349                 if [ $$? -eq 0 ]; then \
350                 echo "You should first set DEBUG_REL to no" ; exit 1 ; fi
351         $(MAKE) extraclean
352         rm -f .freezemake
353         touch .filelist
354         chmod 600 .filelist
355         cd .. ; find $(RELNAME) \! -type d -print | fgrep -v 'conf/.md5sum' > $(RELNAME)/.filelist
356         chmod 400 .filelist
357         $(MAKE) check
358         (cat .filelist ; echo $(RELNAME)/conf/.md5sum) | (cd .. ; tar -cz -f$(DISTFILE) -T-)
359
360 endif # LEGACY_OLD_MAKEFILE