]> git.sur5r.net Git - openldap/blob - Makefile
Fix formating
[openldap] / Makefile
1 #
2 # You will usually NOT need to edit this file at all:  instead, edit the
3 # Make-common file.  See the LDAP INSTALL file for more information.
4 #
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 1994 Regents of the University of Michigan.
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms are permitted
10 # provided that this notice is preserved and that due credit is given
11 # to the University of Michigan at Ann Arbor. The name of the University
12 # may not be used to endorse or promote products derived from this
13 # software without specific prior written permission. This software
14 # is provided ``as is'' without express or implied warranty.
15 #
16 #       LDAP lightweight X.500 Directory access top level makefile
17 #
18 #-----------------------------------------------------------------------------
19 #
20 ############################################################################
21 #                                                                          #
22 # Usually you will not need to edit anything in this file                  #
23 #                                                                          #
24 ############################################################################
25 #
26 # Note that these definitions of standard Unix utilities are only used
27 # in this Makefile.  The Make-common (and .make-platform) files have a
28 # similar set of definitions that are used in all the other LDAP Makefiles.
29 #
30 RM=rm -f
31 MV=mv -f
32 CP=cp
33 CAT=cat
34 PWD=pwd
35 TAIL=tail
36 CHMOD=chmod
37 FIND=find
38 SED=sed
39 LN=ln -s
40 MKDIR=mkdir
41 GREP=grep
42 DIRNAME=dirname
43 BASENAME=basename
44 TAR=tar
45 COMPRESS=compress
46 CO=co
47 CI=ci
48
49
50 SRCDIRS= include libraries clients servers doc
51 TESTDIR= tests
52
53 #
54 # LDAPSRC is used by the links rule
55 #
56 LDAPSRC= ..
57
58
59 #
60 # rules to make the software
61 #
62
63 all: makeconfig
64         @echo "making all"
65         @for i in $(SRCDIRS); do \
66             echo; echo "  cd $$i; $(MAKE) $(MFLAGS) all"; \
67             ( cd $$i; $(MAKE) $(MFLAGS) all ); \
68         done
69
70 lib-only: makeconfig
71         @echo "making libraries only"
72         @echo "  cd include; $(MAKE) $(MFLAGS) all"; \
73                 cd include; $(MAKE) $(MFLAGS) all
74         @echo "  cd libraries; $(MAKE) $(MFLAGS) all"; \
75                 cd libraries; $(MAKE) $(MFLAGS) all
76
77
78 #
79 # rules to install the software
80 #
81
82 install:        makeconfig
83         @for i in $(SRCDIRS); do \
84             echo; echo "cd $$i; $(MAKE) $(MFLAGS) install"; \
85             ( cd $$i; $(MAKE) $(MFLAGS) install ); \
86         done
87
88 inst-lib:       makeconfig
89         @echo "cd libraries; $(MAKE) $(MFLAGS) install"
90         @( cd libraries; $(MAKE) $(MFLAGS) install )
91
92
93 #
94 # rules to test the LDAP software
95 #
96 test:   all
97         @echo " cd $(TESTDIR); $(MAKE) $(MFLAGS) all"; \
98         ( cd $(TESTDIR); $(MAKE) $(MFLAGS) all );
99
100 #
101 # rules to make clean
102 #
103
104 clean:  FORCE
105         @if [ -f .makefiles ]; then \
106             for i in $(SRCDIRS) $(TESTDIR); do \
107                 echo; echo "cd $$i; $(MAKE) $(MFLAGS) clean"; \
108                 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
109             done; \
110         fi; \
111         ( for d in ./obj-*; do \
112             if [ $$d != "./obj-*" ]; then \
113                 ( echo "making clean in $$d..."; \
114                   cd $$d; $(MAKE) $(MFLAGS) clean; ) \
115             else \
116                 exit 0; \
117             fi; \
118         done )
119
120 veryclean:      FORCE
121         @echo; echo "cd build; $(MAKE) $(MFLAGS) -f Make-template veryclean"; \
122         ( cd build; $(MAKE) $(MFLAGS) -f Make-template veryclean ); \
123         if [ -f .makefiles ]; then \
124             for i in $(SRCDIRS) $(TESTDIR); do \
125                 echo; echo "cd $$i; $(MAKE) $(MFLAGS) veryclean"; \
126                 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
127             done; \
128             echo "finding and removing Makefiles..."; \
129             for i in `$(FIND) . -type d -print`; do \
130                 if [ -f $$i/Make-template ]; then \
131                     echo "removing file $$i/Makefile"; \
132                     $(RM) $$i/Makefile; \
133                 fi; \
134             done; \
135             echo "removing file .makefiles"; \
136             $(RM) .makefiles; \
137         fi; \
138         ( for d in ./obj-*; do \
139             if [ $$d != "./obj-*" ]; then \
140                 echo "removing $$d..."; $(RM) -r $$d; \
141             else \
142                 exit 0; \
143             fi; \
144         done ); \
145         if [ -f .make-platform ]; then \
146             echo "removing link .make-platform"; \
147             $(RM) .make-platform; \
148         else \
149             exit 0; \
150         fi
151
152
153 #
154 # rules to make depend
155 #
156 #
157 depend: makeconfig
158         @echo "making depend everywhere"; \
159         echo "  cd include; $(MAKE) $(MFLAGS) all"; \
160                 ( cd include; $(MAKE) $(MFLAGS) all ); \
161         for i in $(SRCDIRS); do \
162             echo; echo "cd $$i; $(MAKE) $(MFLAGS) depend"; \
163             ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
164         done; \
165         $(MAKE) $(MFLAGS) makefiles
166
167 #
168 # rules to check out and in Make-template files
169 #
170 co-mktmpls:     FORCE
171         @echo "checking out Make-template files..."; \
172         for mkfile in `$(FIND) . -name Make-template -type f -print`; do \
173             $(CO) -l $$mkfile; \
174         done
175
176 ci-mktmpls:     FORCE
177         @echo "enter a one-word log message:"; \
178         read logmsg; \
179         echo "checking in Make-template files..."; \
180         for mkfile in `$(FIND) . -name Make-template -type f -print`; do \
181             $(CI) -m$$logmsg -u $$mkfile; \
182         done
183
184
185 lib-depend:     makeconfig
186         @echo "cd libraries; $(MAKE) $(MFLAGS) depend"
187         @( cd libraries; $(MAKE) $(MFLAGS) depend )"
188
189 #
190 # rules to cut a new ldap distribution
191 #
192 distribution:   makeconfig checkin tar
193
194 checkin:        FORCE
195         @-VERSION=V`cat ./build/version | $(SED) -e 's/\.//'` ; \
196         echo "Checking in version $$VERSION"; \
197         for i in `$(FIND) . -name \*,v -print | \
198                 $(SED) -e 's%RCS/%%' -e 's%,v%%'`; \
199             do ( \
200                 ci -m"pre-version $$VERSION check-in" -u $$i; \
201                 rcs -N$$VERSION: $$i ) \
202             done
203
204 tar:    veryclean
205         @PWD=`pwd`; \
206         $(RM) ./Make-common;  \
207         $(CP) ./Make-common.dist ./Make-common; \
208         $(CHMOD) 644 ./Make-common; \
209         $(RM) ./include/ldapconfig.h.edit; \
210         $(CP) ./include/ldapconfig.h.dist ./include/ldapconfig.h.edit; \
211         $(CHMOD) 644 ./include/ldapconfig.h.edit; \
212         BASE=`$(BASENAME) $$PWD`; XFILE=/tmp/ldap-x.$$$$; \
213         ( cd .. ; $(CAT) $$BASE/exclude >$$XFILE; \
214           $(FIND) $$BASE -name RCS -print >> $$XFILE ; \
215           $(FIND) $$BASE -name obj-\* -print >> $$XFILE ; \
216           $(FIND) $$BASE -name tags -print >> $$XFILE ; \
217           $(TAR) cvfX ./$$BASE.tar $$XFILE $$BASE; \
218         ); \
219         $(RM) $$XFILE; \
220         echo "compressing ../$$BASE.tar..."; \
221         $(COMPRESS) ../$$BASE.tar 
222
223 #
224 # rule to force check for change of platform
225 #
226 platform:       FORCE
227         @if [ -f .make-platform ]; then \
228             echo "removing old link .make-platform"; \
229             $(RM) .make-platform; \
230         fi; \
231         $(MAKE) $(MFLAGS) .make-platform
232
233
234 makeconfig:     .makefiles buildtools
235
236 .make-platform:
237         @if [ -f /usr/bin/swconfig ]; then \
238             UNAME=./build/uname.sh; \
239         elif [ -f /bin/uname ]; then \
240             UNAME=/bin/uname; \
241         elif [ -f /usr/bin/uname ]; then \
242             UNAME=/usr/bin/uname; \
243         else \
244             UNAME=./build/uname.sh; \
245         fi; \
246         if [ -z "$$UNAME" ]; then \
247             echo "unknown platform (no $$UNAME or /usr/bin/uname)"; \
248             echo "see the file  build/PORTS  for more information."; \
249             exit 1; \
250         else \
251             OS=`$$UNAME -s` ; OSRELEASE=`$$UNAME -r` ; \
252             OSVERSION=`$$UNAME -v` ; \
253             case $$OS in \
254             SunOS) \
255                 if [ $$OSRELEASE -gt "5" -o $$OSRELEASE -lt "4" ]; then \
256                     echo "SunOS release $$OSRELEASE unknown..."; exit 1; \
257                 fi; \
258                 if [ $$OSRELEASE -ge "5" ]; then \
259                     PLATFORM="sunos5"; \
260                 else \
261                     PLATFORM="sunos4"; \
262                 fi; \
263                 ;; \
264             ULTRIX) \
265                 PLATFORM="ultrix" \
266                 ;; \
267             OSF1) \
268                 PLATFORM="osf1" \
269                 ;; \
270             AIX) \
271                 PLATFORM="aix" \
272                 ;; \
273             HP-UX) \
274                 PLATFORM="hpux" \
275                 ;; \
276             Linux) \
277                 PLATFORM="linux" \
278                 ;; \
279             NetBSD) \
280                 PLATFORM="netbsd" \
281                 ;; \
282             FreeBSD) \
283                 PLATFORM="freebsd" \
284                 ;; \
285             NeXTSTEP) \
286                 PLATFORM="nextstep" \
287                 ;; \
288             SCO) \
289                 PLATFORM="sco" \
290                 ;; \
291             IRIX|IRIX64) \
292                 PLATFORM="irix" \
293                 ;; \
294             *) echo "unknown platform ($$OS $$OSVERSION $$OSRELEASE)..."; \
295                echo "see the file  build/PORTS  for more information."; \
296                 exit 1; \
297                 ;; \
298             esac; \
299         fi; \
300         CC=$(CC); \
301         OLDIFS="$$IFS"; \
302         IFS=":"; \
303         for dir in $$PATH; do \
304             if [ -f $$dir/gcc ]; then \
305                 CC=gcc; \
306                 break; \
307             fi; \
308         done; \
309         IFS="$$OLDIFS"; \
310         $(LN) ./build/platforms/$$PLATFORM-$$CC/Make-platform .make-platform; \
311         echo ""; \
312         echo "** Set platform to $$PLATFORM with compiler $$CC..."; \
313         echo ""
314
315 #
316 # rule to build Makefiles by concatenating Make-template file in each
317 # subdirectory with global Make-common, .make-platform, and
318 # build/Make-append files
319 #
320 .makefiles:     Make-common .make-platform build/Make-append
321         @echo "making Makefiles..."; \
322         HDRFILE=/tmp/Makehdr.$$$$; \
323         DEFSFILE=/tmp/Makedefs.$$$$; \
324         $(CAT) build/Make-append ./.make-platform ./Make-common > $$DEFSFILE; \
325         echo "# --------------------------------------------------------" >  $$HDRFILE; \
326         echo "#  This file was automatically generated.  Do not edit it."  >> $$HDRFILE; \
327         echo "#  Instead, edit the Make-common file (located in the root"  >> $$HDRFILE; \
328         echo "#  (of the LDAP distribution).  See the LDAP INSTALL file"   >> $$HDRFILE; \
329         echo "#  for more information." >> $$HDRFILE; \
330         echo "# --------------------------------------------------------" >> $$HDRFILE; \
331         echo "#" >> $$HDRFILE; \
332         for i in `$(FIND) . -type d -print`; do \
333             if [ -f $$i/Make-template ]; then \
334                 echo "  creating $$i/Makefile"; \
335                 $(RM) $$i/Makefile; \
336                 $(CAT) $$HDRFILE $$i/Make-template $$DEFSFILE > $$i/Makefile; \
337                 $(CHMOD) 444 $$i/Makefile; \
338             fi; \
339         done; \
340         $(RM) .makefiles; \
341         touch .makefiles; \
342         $(RM) $$HDRFILE $$DEFSFILE
343
344 #
345 # rule to always build makefiles
346 #
347 makefiles:      FORCE
348         $(RM) .makefiles
349         $(MAKE) $(MFLAGS) .makefiles
350
351 #
352 # rule to create any tools we need to build everything else
353 #
354 buildtools:     FORCE
355         @echo "making buildtools"
356         @echo "  cd build; $(MAKE) $(MFLAGS)"
357         @( cd build; $(MAKE) $(MFLAGS) )
358
359 #
360 # rule to make a shadow (linked) build area
361 #
362 links:  FORCE
363         @if [ -f /usr/bin/swconfig ]; then \
364             UNAME=./build/uname.sh; \
365         elif [ -f /bin/uname ]; then \
366             UNAME=/bin/uname; \
367         elif [ -f /usr/bin/uname ]; then \
368             UNAME=/usr/bin/uname; \
369         else \
370             UNAME=./build/uname.sh; \
371         fi; \
372         if [ ! -z "$(DEST)" ]; then \
373             DEST="$(DEST)"; \
374         else \
375             DEST=./obj-`$$UNAME -s`-`$$UNAME -r` ; \
376         fi; \
377         echo "making links in $$DEST..."; \
378         LINKLIST=/tmp/ldaplinklist.$$$$; \
379         $(RM) $$LINKLIST; \
380         $(MKDIR) $$DEST; \
381         cd $$DEST; $(LN) $(LDAPSRC) .src; \
382         $(LN) .src/Makefile . ; \
383         $(CP) .src/Make-common . ; $(CHMOD) 644 ./Make-common; \
384         for d in build $(SRCDIRS) $(TESTDIR); do \
385                 ( $(MKDIR) $$d; cd $$d; $(LN) ../.src/$$d .src; \
386                   $(LN) .src/Make-template . ; \
387                   $(MAKE) $(MFLAGS) MKDIR="$(MKDIR)" LN="$(LN)" \
388                         -f Make-template links ) ; \
389         done; \
390         echo ""; echo "Now type:"; echo "  cd $$DEST"; echo "and make there"
391
392 FORCE: