summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Ischo <bji@lolita.(none)>2009-02-12 08:41:40 +1300
committerBryan Ischo <bji@lolita.(none)>2009-02-12 08:41:40 +1300
commitaff462ced93a8e2ee8267517992dae84b2384cef (patch)
tree8dfeb16da6170673112135f001f59c1e9383c143
parent63203ddc62058c7fe00634172193c1105d9eac44 (diff)
parent48b37dceec73492bfaf397e6a9ced39b5fc3e29d (diff)
downloadceph-libs3-aff462ced93a8e2ee8267517992dae84b2384cef.tar.gz
Merge commit '48b37dceec73492bfaf397e6a9ced39b5fc3e29d'
-rw-r--r--GNUmakefile14
-rw-r--r--GNUmakefile.mingw12
-rw-r--r--GNUmakefile.osx310
-rw-r--r--debian/control.dev2
-rw-r--r--inc/libs3.h5
-rw-r--r--inc/simplexml.h2
-rw-r--r--src/s3.c8
7 files changed, 328 insertions, 25 deletions
diff --git a/GNUmakefile b/GNUmakefile
index c28b0ef..82a851c 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -86,11 +86,14 @@ ifndef CFLAGS
CFLAGS = -O3
endif
-CFLAGS += -Wall -Werror -Wshadow -Wextra -std=c99 -Iinc \
+CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
$(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
-DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
-DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
- -DLIBS3_VER=\"$(LIBS3_VER)\"
+ -DLIBS3_VER=\"$(LIBS3_VER)\" \
+ -D__STRICT_ANSI__ \
+ -D_ISOC99_SOURCE \
+ -D_POSIX_C_SOURCE=200112L
LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread
@@ -113,7 +116,7 @@ exported: libs3 s3 headers
# Install target
.PHONY: install
-install: libs3 s3 headers
+install: exported
install -Dps -m u+rwx,go+rx $(BUILD)/bin/s3 $(DESTDIR)/bin/s3
install -Dp -m u+rw,go+r $(BUILD)/include/libs3.h \
$(DESTDIR)/include/libs3.h
@@ -247,7 +250,7 @@ $(BUILD)/obj/%.do: src/%.c
LIBS3_SHARED = $(BUILD)/lib/libs3.so.$(LIBS3_VER_MAJOR)
.PHONY: libs3
-libs3: $(LIBS3_SHARED) $(LIBS3_SHARED_MAJOR) $(BUILD)/lib/libs3.a
+libs3: $(LIBS3_SHARED) $(BUILD)/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 \
@@ -256,8 +259,7 @@ LIBS3_SOURCES := src/acl.c src/bucket.c src/error_parser.c src/general.c \
$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.do)
@mkdir -p $(dir $@)
- gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) -o $@ $^ \
- $(S3_LIBS) $(LDFLAGS)
+ gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) -o $@ $^ $(LDFLAGS)
$(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
@mkdir -p $(dir $@)
diff --git a/GNUmakefile.mingw b/GNUmakefile.mingw
index afedb9b..7d3f830 100644
--- a/GNUmakefile.mingw
+++ b/GNUmakefile.mingw
@@ -86,12 +86,16 @@ ifndef CFLAGS
CFLAGS = -O3
endif
-CFLAGS += -Wall -Werror -Wshadow -Wextra -std=c99 -Iinc \
+CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
$(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
-DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
-DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
- -Dsleep=Sleep -DFOPEN_EXTRA_FLAGS=\"b\" \
- -Iinc/mingw -include windows.h
+ -DLIBS3_VER=\"$(LIBS3_VER)\" \
+ -D__STRICT_ANSI__ \
+ -D_ISOC99_SOURCE \
+ -D_POSIX_C_SOURCE=200112L \
+ -Dsleep=Sleep -DFOPEN_EXTRA_FLAGS=\"b\" \
+ -Iinc/mingw -include windows.h
LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS)
@@ -113,7 +117,7 @@ exported: libs3 s3 headers
# Install target
.PHONY: install
-install: libs3 s3 headers
+install: exported
-@mkdir $(DESTDIR)\bin
-@mkdir $(DESTDIR)\include
-@mkdir $(DESTDIR)\lib
diff --git a/GNUmakefile.osx b/GNUmakefile.osx
new file mode 100644
index 0000000..5d4bcbb
--- /dev/null
+++ b/GNUmakefile.osx
@@ -0,0 +1,310 @@
+# 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.
+#
+# In addition, as a special exception, the copyright holders give
+# permission to link the code of this library and its programs with the
+# OpenSSL library, and distribute linked combinations including the two.
+#
+# 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 := 1
+LIBS3_VER_MINOR := 4
+LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
+
+
+# --------------------------------------------------------------------------
+# BUILD directory
+ifndef BUILD
+ BUILD := build
+endif
+
+
+# --------------------------------------------------------------------------
+# DESTDIR directory
+ifndef DESTDIR
+ DESTDIR := /usr
+endif
+
+
+# --------------------------------------------------------------------------
+# 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.
+
+ifndef CFLAGS
+ CFLAGS = -O3
+endif
+
+CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
+ $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
+ -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
+ -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
+ -DLIBS3_VER=\"$(LIBS3_VER)\" \
+ -D__STRICT_ANSI__ \
+ -D_ISOC99_SOURCE \
+ -fno-common
+
+LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread
+
+
+# --------------------------------------------------------------------------
+# Default targets are everything
+
+.PHONY: all
+all: exported test
+
+
+# --------------------------------------------------------------------------
+# Exported targets are the library and driver program
+
+.PHONY: exported
+exported: libs3 s3 headers
+
+
+# --------------------------------------------------------------------------
+# Install target
+
+.PHONY: install
+install: exported
+ install -ps -m u+rwx,go+rx $(BUILD)/bin/s3 $(DESTDIR)/bin/s3
+ install -p -m u+rw,go+r $(BUILD)/include/libs3.h \
+ $(DESTDIR)/include/libs3.h
+ install -p -m u+rw,go+r $(BUILD)/lib/libs3.a $(DESTDIR)/lib/libs3.a
+ install -p -m u+rw,go+r $(BUILD)/lib/libs3.$(LIBS3_VER_MAJOR).dylib \
+ $(DESTDIR)/lib/libs3.$(LIBS3_VER).dylib
+ ln -sf libs3.$(LIBS3_VER).dylib \
+ $(DESTDIR)/lib/libs3.$(LIBS3_VER_MAJOR).dylib
+ ln -sf libs3.$(LIBS3_VER_MAJOR).dylib $(DESTDIR)/lib/libs3.dylib
+
+
+# --------------------------------------------------------------------------
+# Uninstall target
+
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)/bin/s3 \
+ $(DESTDIR)/include/libs3.h \
+ $(DESTDIR)/lib/libs3.a \
+ $(DESTDIR)/lib/libs3.dylib \
+ $(DESTDIR)/lib/libs3.$(LIBS3_VER_MAJOR).dylib \
+ $(DESTDIR)/lib/libs3.$(LIBS3_VER).dylib \
+
+
+# --------------------------------------------------------------------------
+# Debian package target
+
+DEBPKG = $(BUILD)/pkg/libs3_$(LIBS3_VER).deb
+DEBDEVPKG = $(BUILD)/pkg/libs3-dev_$(LIBS3_VER).deb
+
+.PHONY: deb
+deb: $(DEBPKG) $(DEBDEVPKG)
+
+$(DEBPKG): DEBARCH = $(shell dpkg-architecture | grep ^DEB_BUILD_ARCH= | \
+ cut -d '=' -f 2)
+$(DEBPKG): exported $(BUILD)/deb/DEBIAN/control $(BUILD)/deb/DEBIAN/shlibs \
+ $(BUILD)/deb/DEBIAN/postinst \
+ $(BUILD)/deb/usr/share/doc/libs3/changelog.gz \
+ $(BUILD)/deb/usr/share/doc/libs3/changelog.Debian.gz \
+ $(BUILD)/deb/usr/share/doc/libs3/copyright
+ DESTDIR=$(BUILD)/deb/usr $(MAKE) install
+ rm -rf $(BUILD)/deb/usr/include
+ rm -f $(BUILD)/deb/usr/lib/libs3.a
+ @mkdir -p $(dir $@)
+ fakeroot dpkg-deb -b $(BUILD)/deb $@
+ mv $@ $(BUILD)/pkg/libs3_$(LIBS3_VER)_$(DEBARCH).deb
+
+$(DEBDEVPKG): DEBARCH = $(shell dpkg-architecture | grep ^DEB_BUILD_ARCH= | \
+ cut -d '=' -f 2)
+$(DEBDEVPKG): exported $(BUILD)/deb-dev/DEBIAN/control \
+ $(BUILD)/deb-dev/usr/share/doc/libs3-dev/changelog.gz \
+ $(BUILD)/deb-dev/usr/share/doc/libs3-dev/changelog.Debian.gz \
+ $(BUILD)/deb-dev/usr/share/doc/libs3-dev/copyright
+ DESTDIR=$(BUILD)/deb-dev/usr $(MAKE) install
+ rm -rf $(BUILD)/deb-dev/usr/bin
+ rm -f $(BUILD)/deb-dev/usr/lib/libs3*.dylib
+ @mkdir -p $(dir $@)
+ fakeroot dpkg-deb -b $(BUILD)/deb-dev $@
+ mv $@ $(BUILD)/pkg/libs3-dev_$(LIBS3_VER)_$(DEBARCH).deb
+
+$(BUILD)/deb/DEBIAN/control: debian/control
+ @mkdir -p $(dir $@)
+ echo -n "Depends: " > $@
+ dpkg-shlibdeps -O $(BUILD)/lib/libs3.$(LIBS3_VER_MAJOR).dylib | \
+ cut -d '=' -f 2- >> $@
+ sed -e 's/LIBS3_VERSION/$(LIBS3_VER)/' \
+ < $< | sed -e 's/DEBIAN_ARCHITECTURE/$(DEBARCH)/' | \
+ grep -v ^Source: >> $@
+
+$(BUILD)/deb-dev/DEBIAN/control: debian/control.dev
+ @mkdir -p $(dir $@)
+ sed -e 's/LIBS3_VERSION/$(LIBS3_VER)/' \
+ < $< | sed -e 's/DEBIAN_ARCHITECTURE/$(DEBARCH)/' > $@
+
+$(BUILD)/deb/DEBIAN/shlibs:
+ echo -n "libs3 $(LIBS3_VER_MAJOR) libs3 " > $@
+ echo "(>= $(LIBS3_VER))" >> $@
+
+$(BUILD)/deb/DEBIAN/postinst: debian/postinst
+ @mkdir -p $(dir $@)
+ cp $< $@
+
+$(BUILD)/deb/usr/share/doc/libs3/copyright: LICENSE
+ @mkdir -p $(dir $@)
+ cp $< $@
+ @echo >> $@
+ @echo -n "An alternate location for the GNU General Public " >> $@
+ @echo "License version 3 on Debian" >> $@
+ @echo "systems is /usr/share/common-licenses/GPL-3." >> $@
+
+$(BUILD)/deb-dev/usr/share/doc/libs3-dev/copyright: LICENSE
+ @mkdir -p $(dir $@)
+ cp $< $@
+ @echo >> $@
+ @echo -n "An alternate location for the GNU General Public " >> $@
+ @echo "License version 3 on Debian" >> $@
+ @echo "systems is /usr/share/common-licenses/GPL-3." >> $@
+
+$(BUILD)/deb/usr/share/doc/libs3/changelog.gz: debian/changelog
+ @mkdir -p $(dir $@)
+ gzip --best -c $< > $@
+
+$(BUILD)/deb-dev/usr/share/doc/libs3-dev/changelog.gz: debian/changelog
+ @mkdir -p $(dir $@)
+ gzip --best -c $< > $@
+
+$(BUILD)/deb/usr/share/doc/libs3/changelog.Debian.gz: debian/changelog.Debian
+ @mkdir -p $(dir $@)
+ gzip --best -c $< > $@
+
+$(BUILD)/deb-dev/usr/share/doc/libs3-dev/changelog.Debian.gz: \
+ debian/changelog.Debian
+ @mkdir -p $(dir $@)
+ gzip --best -c $< > $@
+
+
+# --------------------------------------------------------------------------
+# Compile target patterns
+
+$(BUILD)/obj/%.o: src/%.c
+ @mkdir -p $(dir $@)
+ gcc $(CFLAGS) -o $@ -c $<
+
+$(BUILD)/obj/%.do: src/%.c
+ @mkdir -p $(dir $@)
+ gcc $(CFLAGS) -fpic -fPIC -o $@ -c $<
+
+
+# --------------------------------------------------------------------------
+# libs3 library targets
+
+LIBS3_SHARED = $(BUILD)/lib/libs3.$(LIBS3_VER_MAJOR).dylib
+
+.PHONY: libs3
+libs3: $(LIBS3_SHARED) $(LIBS3_SHARED_MAJOR) $(BUILD)/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_access_logging.c \
+ src/service.c src/simplexml.c src/util.c
+
+$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.do)
+ @mkdir -p $(dir $@)
+ gcc -dynamiclib -install_name libs3.$(LIBS3_VER_MAJOR).dylib \
+ -compatibility_version $(LIBS3_VER_MAJOR) \
+ -current_version $(LIBS3_VER) -o $@ $^ $(LDFLAGS)
+
+$(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
+ @mkdir -p $(dir $@)
+ $(AR) cr $@ $^
+
+
+# --------------------------------------------------------------------------
+# Driver program targets
+
+.PHONY: s3
+s3: $(BUILD)/bin/s3
+
+$(BUILD)/bin/s3: $(BUILD)/obj/s3.o $(LIBS3_SHARED)
+ @mkdir -p $(dir $@)
+ gcc -o $@ $^ $(LDFLAGS)
+
+
+# --------------------------------------------------------------------------
+# libs3 header targets
+
+.PHONY: headers
+headers: $(BUILD)/include/libs3.h
+
+$(BUILD)/include/libs3.h: inc/libs3.h
+ @mkdir -p $(dir $@)
+ cp $< $@
+
+
+# --------------------------------------------------------------------------
+# Test targets
+
+.PHONY: test
+test: $(BUILD)/bin/testsimplexml
+
+$(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o $(BUILD)/lib/libs3.a
+ @mkdir -p $(dir $@)
+ gcc -o $@ $^ $(LIBXML2_LIBS)
+
+
+# --------------------------------------------------------------------------
+# Clean target
+
+.PHONY: clean
+clean:
+ rm -rf $(BUILD)
diff --git a/debian/control.dev b/debian/control.dev
index 93d647d..5ee5ae7 100644
--- a/debian/control.dev
+++ b/debian/control.dev
@@ -5,7 +5,7 @@ Section: libdevel
Priority: extra
Depends: libs3 (>= LIBS3_VERSION)
Maintainer: Bryan Ischo <bryan@ischo.com>
-Homepage: http://reallibs3.svn.sourceforge.net
+Homepage: http://libs3.ischo.com/index.html
Description: C Development Library for Amazon S3 Access
This library provides an API for using Amazon's S3 service (see
http://s3.amazonaws.com). Its design goals are:
diff --git a/inc/libs3.h b/inc/libs3.h
index 89fbcc4..8f06e31 100644
--- a/inc/libs3.h
+++ b/inc/libs3.h
@@ -71,11 +71,6 @@ extern "C" {
* using file descriptors and a select()/poll() loop
* - Shut down libs3 at program exit time by calling S3_deinitialize()
*
- * In order to use libs3 with multiple threads, your program must provide
- * threading callbacks to the S3_initialize() function (if your program is
- * single threaded, you can pass NULL for these callback arguments to
- * S3_initialize()).
- *
* All functions which send requests to S3 return their results via a set of
* callback functions which must be supplied to libs3 at the time that the
* request is initiated. libs3 will call these functions back in the thread
diff --git a/inc/simplexml.h b/inc/simplexml.h
index 66d5ef9..704db07 100644
--- a/inc/simplexml.h
+++ b/inc/simplexml.h
@@ -33,7 +33,7 @@
// Simple XML callback.
//
// elementPath: is the full "path" of the element; i.e.
-// <foo><bar><baz>data</baz><bar><foo> would have 'data' in the element
+// <foo><bar><baz>data</baz></bar></foo> would have 'data' in the element
// foo/bar/baz.
//
// Return of anything other than S3StatusOK causes the calling
diff --git a/src/s3.c b/src/s3.c
index 885a8bc..4f8bdc1 100644
--- a/src/s3.c
+++ b/src/s3.c
@@ -47,14 +47,6 @@
#endif
-// Something is weird with glibc ... setenv/unsetenv/ftruncate are not defined
-// in stdlib.h as they should be. And fileno is not in stdio.h
-extern int setenv(const char *, const char *, int);
-extern int unsetenv(const char *);
-extern int ftruncate(int, off_t);
-extern int fileno(FILE *);
-
-
// Command-line options, saved as globals ------------------------------------
static int forceG = 0;