import from branch_1_1:
[freeradius.git] / Makefile
index 52f1c7d..21709e8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# Makefile     Makefile for the cistron-radius package.
+# Makefile
 #
 #              NOTE: This top-level Makefile must not
 #              use GNU-make extensions. The lower ones can.
@@ -9,7 +9,9 @@
 
 include Make.inc
 
-SUBDIRS                = libltdl src raddb doc scripts
+.PHONY: all clean install
+
+SUBDIRS                = $(LTDL_SUBDIRS) src raddb scripts doc
 WHAT_TO_MAKE   = all
 
 all:
@@ -19,38 +21,52 @@ clean:
        @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
        @rm -f *~
 
+#
+# The $(R) is a magic variable not defined anywhere in this source.
+# It's purpose is to allow an admin to create an installation 'tar'
+# file *without* actually installing it.  e.g.:
+#
+#  $ R=/home/root/tmp make install
+#  $ cd /home/root/tmp
+#  $ tar -cf ~/freeradius-package.tar *
+#
+# The 'tar' file can then be un-tar'd on any similar machine.  It's a
+# cheap way of creating packages, without using a package manager.
+# Many of the platform-specific packaging tools use the $(R) variable
+# when creating their packages.
+#
+# For compatibility with typical GNU packages (e.g. as seen in libltdl),
+# we make sure DESTDIR is defined.
+#
+export DESTDIR := $(R)
 install:
-       @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
-       $(INSTALL) -d -m 755    $(R)$(mandir);
+       $(INSTALL) -d -m 755    $(R)$(sbindir)
+       $(INSTALL) -d -m 755    $(R)$(bindir)
+       $(INSTALL) -d -m 755    $(R)$(raddbdir)
+       $(INSTALL) -d -m 755    $(R)$(mandir)
+       $(INSTALL) -d -m 755    $(R)$(RUNDIR)
+       $(INSTALL) -d -m 700    $(R)$(logdir)
+       $(INSTALL) -d -m 700    $(R)$(radacctdir)
+       $(INSTALL) -d -m 755    $(R)$(datadir)
+       $(INSTALL) -d -m 755    $(R)$(dictdir)
        for i in 1 5 8; do \
                $(INSTALL) -d -m 755    $(R)$(mandir)/man$$i; \
                for p in man/man$$i/*.$$i; do \
                        $(INSTALL) -m 644 $$p $(R)$(mandir)/man$$i; \
                done \
        done
-       @echo "Creating/updating files in $(R)$(raddbdir)"; \
-       $(INSTALL) -d -m 755    $(R)$(raddbdir); \
-       cd raddb; \
-       for i in [a-c]* [e-z]*; do \
-               [ $$i != radiusd.conf.in -a ! -f $(R)$(raddbdir)/$$i ] && \
-                $(INSTALL) -m 644 $$i $(R)$(raddbdir); \
-       done; \
+       @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
+       @echo "Installing dictionary files in $(R)$(dictdir)"; \
+       cd share; \
        for i in dictionary*; do \
-               [ ! -f $(R)$(raddbdir)/$$i ] && $(INSTALL) -m 644 $$i $(R)$(raddbdir); \
-               if [ "`find $$i -newer $(R)$(raddbdir)/$$i`" ]; then \
-                       echo "** $(R)$(raddbdir)/$$i"; \
-                       nt=1; \
-               fi; \
-       done; \
-       if [ "$$nt" ]; then \
-               echo "** The samples in ../raddb are newer than these files";\
-               echo "** Please investigate and copy manually if appropriate";\
-       fi
+               $(INSTALL) -m 644 $$i $(R)$(dictdir); \
+       done
+       $(LIBTOOL) --finish $(R)$(libdir)
 
 common:
        @for dir in $(SUBDIRS); do \
                echo "Making $(WHAT_TO_MAKE) in $$dir..."; \
-               (cd $$dir && $(MAKE) $(MFLAGS) $(WHAT_TO_MAKE)) || exit 1;\
+               $(MAKE) $(MFLAGS) -C $$dir $(WHAT_TO_MAKE) || exit $$?; \
        done
 
 distclean: clean
@@ -66,12 +82,6 @@ distclean: clean
        -find src/modules -name config.h | \
                while read file; do rm -f $$file; done
 
-ifndef prefix  # catch runs without configuring, and give helpful advice.
-Make.inc:
-       @echo "   Sorry!  You must run 'configure', before 'make'.";
-       @false
-endif
-
 ######################################################################
 #
 #  Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
@@ -96,3 +106,10 @@ config.status: configure
        ./config.status --recheck
 
 configure.in:
+
+.PHONY: check-includes
+check-includes:
+       scripts/min-includes.pl `find . -name "*.c" -print`
+
+TAGS:
+       etags `find src -type f -name '*.[ch]' -print`