summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Ischo <bryan@ischo.com>2008-08-04 21:02:45 +0000
committerBryan Ischo <bryan@ischo.com>2008-08-04 21:02:45 +0000
commit43eb0fe5069da73af2074aa33a56f1a5c9de31b1 (patch)
treeb10f634e505f445ccde72800c7d55ec00f5d7c69
parentbe5b0fd999f86c3d73847f4d43fc5c925a5940f9 (diff)
downloadceph-libs3-43eb0fe5069da73af2074aa33a56f1a5c9de31b1.tar.gz
* Added some standard GNU files
* Moved Makefile to GNUmakefile (since it requires gnu make), and updated it to build a shared library * Bumped version number to 0.3
-rw-r--r--ChangeLog5
-rw-r--r--GNUmakefile130
-rw-r--r--INSTALL20
-rw-r--r--Makefile66
-rw-r--r--README4
-rw-r--r--src/s3.c2
6 files changed, 160 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..09bb5f1
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,5 @@
+
+Tue Aug 5 08:52:33 NZST 2008 bryan@ischo.com
+ * Bumped version number to 0.3
+ * Moved Makefile to GNUmakefile, added shared library build
+ * Added a bunch of GNU standard files (README, INSTALL, ChangeLog, etc)
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..9f595d3
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,130 @@
+# GNUmakefile
+#
+# Copyright 2008 Bryan Ischo <bryan@ischo.com>
+#
+# This file is part of libs3.
+#
+# libs3 is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, version 3 of the License.
+#
+# libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License version 3
+# along with libs3, in a file named COPYING. If not, see
+# <http://www.gnu.org/licenses/>.
+
+# I tried to use the autoconf/automake/autolocal/etc (i.e. autohell) tools
+# but I just couldn't stomach them. Since this is a Makefile for POSIX
+# systems, I will simply do away with autohell completely and use a GNU
+# Makefile. GNU make ought to be available pretty much everywhere, so I
+# don't see this being a significant issue for portability.
+
+# All commands assume a GNU compiler. For systems which do not use a GNU
+# compiler, write scripts with the same names as these commands, and taking
+# the same arguments, and translate the arguments and commands into the
+# appropriate non-POSIX ones as needed. libs3 assumes a GNU toolchain as
+# the most portable way to build software possible. Non-POSIX, non-GNU
+# systems can do the work of supporting this build infrastructure.
+
+
+# --------------------------------------------------------------------------
+# Set libs3 version number
+
+LIBS3_VER_MAJOR := 0
+LIBS3_VER_MINOR := 3
+
+
+# --------------------------------------------------------------------------
+# Acquire configuration information for libraries that libs3 depends upon
+
+ifndef CURL_LIBS
+ CURL_LIBS := $(shell curl-config --libs)
+endif
+
+ifndef CURL_CFLAGS
+ CURL_CFLAGS := $(shell curl-config --cflags)
+endif
+
+ifndef LIBXML2_LIBS
+ LIBXML2_LIBS := $(shell xml2-config --libs)
+endif
+
+ifndef LIBXML2_CFLAGS
+ LIBXML2_CFLAGS := $(shell xml2-config --cflags)
+endif
+
+
+# --------------------------------------------------------------------------
+# These CFLAGS assume a GNU compiler. For other compilers, write a script
+# which converts these arguments into their equivalent for that particular
+# compiler.
+
+CFLAGS += -Wall -Werror -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
+ -DLIBS3_VER_MAJOR=$(LIBS3_VER_MAJOR) \
+ -DLIBS3_VER_MINOR=$(LIBS3_VER_MINOR)
+
+
+# --------------------------------------------------------------------------
+# Default targets are the library and driver program
+
+all: libs3 s3
+
+
+# --------------------------------------------------------------------------
+# Compile target patterns
+
+obj/%.o: src/%.c
+ gcc $(CFLAGS) -o $@ -c $<
+
+obj/%.do: src/%.c
+ gcc $(CFLAGS) -fpic -fPIC -o $@ -c $<
+
+
+# --------------------------------------------------------------------------
+# libs3 library targets
+
+LIBS3_SHARED = lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
+
+libs3: $(LIBS3_SHARED) lib/libs3.a
+
+LIBS3_SOURCES := src/acl.c src/bucket.c src/error_parser.c src/general.c \
+ src/object.c src/request.c src/request_context.c \
+ src/response_headers_handler.c src/service.c \
+ src/simplexml.c src/util.c
+
+$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=obj/%.do)
+ gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) -o $@ $^
+
+lib/libs3.a: $(LIBS3_SOURCES:src/%.c=obj/%.o)
+ $(AR) cr $@ $^
+
+
+# --------------------------------------------------------------------------
+# Driver program targets
+
+s3: bin/s3
+
+bin/s3: obj/s3.o lib/libs3.a
+ gcc -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread -lssl
+
+
+# --------------------------------------------------------------------------
+# Test targets
+
+test: bin/testsimplexml
+
+bin/testsimplexml: src/testsimplexml.o lib/libs3.a
+ gcc -o $@ $^ $(LIBXML2_LIBS)
+
+
+# --------------------------------------------------------------------------
+# Clean target
+
+.PHONY: clean
+clean:
+ rm -f obj/*.o obj/*.do $(LIBS3_SHARED) lib/libs3.a \
+ bin/s3 bin/testsimplexml
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..01debc2
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,20 @@
+
+To install libs3 on a POSIX system (except Microsoft Windows):
+--------------------------------------------------------------
+
+* CFLAGS=-O3 make
+
+* cp -a bin/s3 /usr/bin
+
+* cp -a lib/libs3.* /usr/lib
+
+* cp -a inc/libs3.h /usr/include
+
+This is currently very primitive; eventually, support for a variety of systems
+via software packaging will be supported.
+
+
+To install libs3 on a Microsoft Windows system:
+-----------------------------------------------
+
+(TBD)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d742fbd..0000000
--- a/Makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Makefile
-#
-# Copyright 2008 Bryan Ischo <bryan@ischo.com>
-#
-# This file is part of libs3.
-#
-# libs3 is free software: you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation, version 3 of the License.
-#
-# libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License version 3
-# along with libs3, in a file named COPYING. If not, see
-# <http://www.gnu.org/licenses/>.
-
-
-LIBS3_VER_MAJOR := 0
-LIBS3_VER_MINOR := 2
-
-ifndef CURL_LIBS
- CURL_LIBS := $(shell curl-config --libs)
-endif
-
-ifndef CURL_CFLAGS
- CURL_CFLAGS := $(shell curl-config --cflags)
-endif
-
-ifndef LIBXML2_LIBS
- LIBXML2_LIBS := $(shell xml2-config --libs)
-endif
-
-ifndef LIBXML2_CFLAGS
- LIBXML2_CFLAGS := $(shell xml2-config --cflags)
-endif
-
-CFLAGS += -Wall -Werror -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
- -DLIBS3_VER_MAJOR=$(LIBS3_VER_MAJOR) \
- -DLIBS3_VER_MINOR=$(LIBS3_VER_MINOR)
-
-all: libs3 s3
-
-libs3: lib/libs3.a
-
-lib/libs3.a: src/acl.o src/bucket.o src/error_parser.o src/general.o \
- src/object.o src/request.o src/request_context.o \
- src/response_headers_handler.o src/service.o src/simplexml.o \
- src/util.o
- $(AR) cr $@ $^
-
-s3: bin/s3
-
-bin/s3: src/s3.o lib/libs3.a
- $(CC) -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread -lssl
-
-test: bin/testsimplexml
-
-bin/testsimplexml: src/testsimplexml.o lib/libs3.a
- $(CC) -o $@ $^ $(LIBXML2_LIBS)
-
-.PHONY: clean
-clean:
- rm -f src/*.o lib/libs3.a bin/s3
diff --git a/README b/README
new file mode 100644
index 0000000..a44f75e
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+This directory contains the libs3 library.
+
+The libs3 library is free software. See the file COPYING for copying
+permission.
diff --git a/src/s3.c b/src/s3.c
index ced5d98..e140b5a 100644
--- a/src/s3.c
+++ b/src/s3.c
@@ -1830,7 +1830,7 @@ static void get_object(int argc, char **argv, int optind)
}
}
- FILE *outfile;
+ FILE *outfile = 0;
if (filename) {
// Stat the file, and if it doesn't exist, open it in w mode