From 23fe8003c0758342f3ded6f7e5249a36bb6d9d72 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Mon, 18 May 2009 14:45:41 -0400
Subject: [PATCH 2/5] Enable automake builds for libreplace

---
 replace/Makefile.am  |   50 +++++++++++++++++++++++++++++++++++
 replace/Makefile.in  |   70 --------------------------------------------------
 replace/acinclude.m4 |    1 +
 replace/aclocal.m4   |    1 -
 replace/configure.ac |   10 +++++--
 5 files changed, 58 insertions(+), 74 deletions(-)
 create mode 100644 replace/Makefile.am
 delete mode 100644 replace/Makefile.in
 create mode 100644 replace/acinclude.m4
 delete mode 100644 replace/aclocal.m4

diff --git a/replace/Makefile.am b/replace/Makefile.am
new file mode 100644
index 0000000..6a0cf57
--- /dev/null
+++ b/replace/Makefile.am
@@ -0,0 +1,50 @@
+libreplace_sources = \
+    dlfcn.c \
+    getaddrinfo.c \
+    getifaddrs.c \
+    getpass.c \
+    inet_aton.c \
+    inet_ntoa.c \
+    inet_ntop.c \
+    inet_pton.c \
+    repdir_getdents.c \
+    repdir_getdirentries.c \
+    replace.c \
+    snprintf.c \
+    socket.c \
+    socketpair.c \
+    strptime.c \
+    timegm.c \
+    getaddrinfo.h \
+    replace.h \
+    win32_replace.h \
+    system/aio.h \
+    system/capability.h \
+    system/dir.h \
+    system/filesys.h \
+    system/glob.h \
+    system/iconv.h \
+    system/kerberos.h \
+    system/locale.h \
+    system/network.h \
+    system/passwd.h \
+    system/readline.h \
+    system/select.h \
+    system/shmem.h \
+    system/syslog.h \
+    system/terminal.h \
+    system/time.h \
+    system/wait.h
+
+noinst_LIBRARIES = \
+    libreplace.a
+
+libreplace_a_SOURCES =
+EXTRA_libreplace_a_SOURCES = \
+    $(libreplace_sources)
+libreplace_a_DEPENDENCIES = \
+    @LIBREPLACEOBJ@
+
+libreplace_a_LIBADD = \
+    @LIBREPLACEOBJ@
+
diff --git a/replace/Makefile.in b/replace/Makefile.in
deleted file mode 100644
index 0986d60..0000000
--- a/replace/Makefile.in
+++ /dev/null
@@ -1,70 +0,0 @@
-#!gmake
-#
-CC = @CC@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-includedir = @includedir@
-libdir = @libdir@
-VPATH = @libreplacedir@
-srcdir = @srcdir@
-builddir = @builddir@
-sharedbuilddir = @sharedbuilddir@
-INSTALLCMD = @INSTALL@
-LIBS = @LIBS@
-
-.PHONY: test all showflags install installcheck clean distclean realdistclean
-
-CFLAGS += -I. @CFLAGS@
-LDFLAGS += @LDFLAGS@
-
-OBJS = @LIBREPLACEOBJ@
-
-all: showflags libreplace.a testsuite
-
-showflags:
-	@echo 'libreplace will be compiled with flags:'
-	@echo '  CC     = $(CC)'
-	@echo '  CFLAGS = $(CFLAGS)'
-	@echo '  LDFLAGS= $(LDFLAGS)'
-	@echo '  LIBS   = $(LIBS)'
-
-install: all
-	${INSTALLCMD} -d $(libdir)
-	${INSTALLCMD} -m 644 libreplace.a $(libdir)
-
-shared-build: all
-	${INSTALLCMD} -d $(sharedbuilddir)/include
-	${INSTALLCMD} -m 644 replace.h $(sharedbuilddir)/include
-	${INSTALLCMD} -d $(sharedbuilddir)/lib
-	${INSTALLCMD} -m 644 libreplace.a $(sharedbuilddir)/lib
-
-libreplace.a: $(OBJS)
-	ar -rcsv $@ $(OBJS)
-
-test: all
-	./testsuite
-
-installcheck: install test
-
-TEST_OBJS = test/main.o test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
-
-testsuite: libreplace.a $(TEST_OBJS)
-	$(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
-
-.c.o:
-	@echo Compiling $*.c
-	@mkdir -p `dirname $@`
-	@$(CC) $(CFLAGS) -c $< -o $@
-
-clean:
-	rm -f *.o test/*.o *.a testsuite
-	rm -f testfile.dat
-
-distclean: clean
-	rm -f *~ */*~
-	rm -f config.log config.status config.h config.cache
-	rm -f Makefile
-
-realdistclean: distclean
-	rm -f configure config.h.in
diff --git a/replace/acinclude.m4 b/replace/acinclude.m4
new file mode 100644
index 0000000..5605e47
--- /dev/null
+++ b/replace/acinclude.m4
@@ -0,0 +1 @@
+m4_include(libreplace.m4)
diff --git a/replace/aclocal.m4 b/replace/aclocal.m4
deleted file mode 100644
index 5605e47..0000000
--- a/replace/aclocal.m4
+++ /dev/null
@@ -1 +0,0 @@
-m4_include(libreplace.m4)
diff --git a/replace/configure.ac b/replace/configure.ac
index 0361825..c90e2a4 100644
--- a/replace/configure.ac
+++ b/replace/configure.ac
@@ -1,8 +1,10 @@
 AC_PREREQ(2.50)
-AC_INIT(replace.c)
+AC_INIT([libreplace], [0.0])
 AC_CONFIG_SRCDIR([replace.c])
 AC_CONFIG_HEADER(config.h)
-
+AC_CONFIG_AUX_DIR([build])
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_PROG_RANLIB
 CFLAGS="$CFLAGS -I$srcdir"
 
 AC_LIBREPLACE_ALL_CHECKS
@@ -30,4 +32,6 @@ AC_SUBST(LIBS)
 
 AC_SUBST(LDFLAGS)
 
-AC_OUTPUT(Makefile)
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
-- 
1.6.2.2

