Start of work to remove need for libtool && libltdl
authorAlan T. DeKok <aland@freeradius.org>
Sun, 19 Jun 2011 10:02:41 +0000 (12:02 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 19 Jun 2011 10:02:41 +0000 (12:02 +0200)
For now, we rely on gcc to do most of the heavy lifting for us.
This hinders portability, but people can always fall back to
libtool.

Make.inc.in
src/lib/Makefile

index 854bade..dce571e 100644 (file)
@@ -107,3 +107,39 @@ ifneq ($(SCAN),)
 CC             := $(SCAN)/scan-build gcc -DFR_SCAN_BUILD
 LIBTOOL                := 
 endif
+
+#
+#  Portability cruft.  This is for replacing libtroll && libltdl
+#  with gcc and dlopen().
+#
+ifeq "$(USE_SHARED_LIBS)" "yes"
+LINK_MODE.exe  = -export-dynamic
+CFLAGS         += -fPIC
+else
+LINK_MODE.exe  = -static
+endif
+
+ifneq "$(LIBTOOL)" ""
+COMPILE.c      := $(LIBTOOL) --mode=compile $(CC)
+LINK.lib       := $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) -rpath $(libdir) -o
+LO             := lo
+LA             := la
+else
+COMPILE.c      := $(CC)
+LO             := o
+
+ifeq "$(USE_SHARED_LIBS)" "yes"
+LINK.lib       := $(CC) -shared -o
+LA             := so
+else
+LINK.lib       := $(AR) cru
+LA             := a
+endif
+
+endif
+
+ifeq "$(LA)" "so"
+ifneq "$(findstring Darwin,$(shell uname -a))" ""
+LA             := dylib
+endif
+endif
index 2557201..135c2b3 100644 (file)
@@ -12,7 +12,7 @@ SRCS          = dict.c filters.c hash.c hmac.c hmacsha1.c isaac.c log.c \
                  valuepair.c fifo.c packet.c event.c getaddrinfo.c vqp.c \
                  heap.c dhcp.c tcp.c
 
-LT_OBJS                = $(SRCS:.c=.lo)
+LT_OBJS                = $(SRCS:.c=.$(LO))
 
 INCLUDES       = ../include/radius.h ../include/libradius.h \
                  ../include/missing.h ../include/autoconf.h \
@@ -25,29 +25,22 @@ CFLAGS              += -D_LIBRADIUS -I$(top_builddir)/src
 # the other end is doing.
 #CFLAGS += -DHMAC_SHA1_DATA_PROBLEMS
 
-ifeq ($(USE_SHARED_LIBS),yes)
-LINK_MODE      = -export-dynamic
-else
-LINK_MODE      = -static
-endif
-
 TARGET         = $(LIBPREFIX)freeradius-radius
 
 # Define new rule for libtool objects
-%.lo : %.c
-       $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<
+%.$(LO) : %.c
+       $(COMPILE.c) $(CFLAGS) -c $<
 
 .PHONY: all clean install reconfig
-all: $(TARGET).la
+all: $(TARGET).$(LA)
 
-$(TARGET).la: $(LT_OBJS)
-       $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
-       $(LDFLAGS) $(LINK_MODE) -o $@ -rpath $(libdir) $^
+$(TARGET).$(LA): $(LT_OBJS)
+       $(LINK.lib) $@ $(LDFLAGS) $^
 
 $(LT_OBJS): $(INCLUDES)
 
 clean:
-       rm -f *.o *.lo $(TARGET).la
+       rm -f *.$(LO) $(TARGET).$(LA)
        rm -rf .libs
 
 install: all