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