diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-08-05 10:46:21 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-08-05 10:46:21 +0000 |
commit | f791d91f13b1105ef2c70df385120e52dae4b7c7 (patch) | |
tree | 1ba2554e39771b62c62adebc2ae063d07b43f2e0 | |
parent | 43eb0fe5069da73af2074aa33a56f1a5c9de31b1 (diff) | |
download | ceph-libs3-f791d91f13b1105ef2c70df385120e52dae4b7c7.tar.gz |
* Improve build system
* Add libs3.spec for building RPMs
-rw-r--r-- | GNUmakefile | 91 | ||||
-rw-r--r-- | INSTALL | 17 | ||||
-rw-r--r-- | inc/libs3.h | 6 | ||||
-rw-r--r-- | libs3.spec | 58 |
4 files changed, 148 insertions, 24 deletions
diff --git a/GNUmakefile b/GNUmakefile index 9f595d3..fb293c1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -39,6 +39,20 @@ LIBS3_VER_MINOR := 3 # -------------------------------------------------------------------------- +# BUILD directory +ifndef BUILD + BUILD := build +endif + + +# -------------------------------------------------------------------------- +# INSTALL directory +ifndef INSTALL + INSTALL := /usr +endif + + +# -------------------------------------------------------------------------- # Acquire configuration information for libraries that libs3 depends upon ifndef CURL_LIBS @@ -71,53 +85,101 @@ CFLAGS += -Wall -Werror -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \ # -------------------------------------------------------------------------- # Default targets are the library and driver program -all: libs3 s3 +.PHONY: exported +exported: libs3 s3 headers + + +# -------------------------------------------------------------------------- +# Install target + +.PHONY: install +install: libs3 s3 headers + install -Dps -m ugo+rx $(BUILD)/bin/s3 $(INSTALL)/bin/s3 + install -Dp -m ugo+r $(BUILD)/include/libs3.h $(INSTALL)/include/libs3.h + install -Dps -m ugo+r $(BUILD)/lib/libs3.a $(INSTALL)/lib/libs3.a + install -Dps -m ugo+r \ + $(BUILD)/lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) \ + $(INSTALL)/lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) + ln -sf libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) \ + $(INSTALL)/lib/libs3.so.$(LIBS3_VER_MAJOR) + + +# -------------------------------------------------------------------------- +# Uninstall target + +.PHONY: uninstall +uninstall: + rm -f $(INSTALL)/bin/s3 \ + $(INSTALL)/include/libs3.h \ + $(INSTALL)/lib/libs3.a \ + $(INSTALL)/lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) \ + $(INSTALL)/lib/libs3.so.$(LIBS3_VER_MAJOR) # -------------------------------------------------------------------------- # Compile target patterns -obj/%.o: src/%.c - gcc $(CFLAGS) -o $@ -c $< +$(BUILD)/obj/%.o: src/%.c + @mkdir -p $(dir $@) + gcc $(CFLAGS) -o $@ -c $< -obj/%.do: src/%.c - gcc $(CFLAGS) -fpic -fPIC -o $@ -c $< +$(BUILD)/obj/%.do: src/%.c + @mkdir -p $(dir $@) + gcc $(CFLAGS) -fpic -fPIC -o $@ -c $< # -------------------------------------------------------------------------- # libs3 library targets -LIBS3_SHARED = lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) +LIBS3_SHARED = $(BUILD)/lib/libs3.so.$(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR) -libs3: $(LIBS3_SHARED) lib/libs3.a +.PHONY: libs3 +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 \ src/response_headers_handler.c src/service.c \ src/simplexml.c src/util.c -$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=obj/%.do) +$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.do) + @mkdir -p $(dir $@) gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) -o $@ $^ -lib/libs3.a: $(LIBS3_SOURCES:src/%.c=obj/%.o) +$(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o) + @mkdir -p $(dir $@) $(AR) cr $@ $^ # -------------------------------------------------------------------------- # Driver program targets -s3: bin/s3 +.PHONY: s3 +s3: $(BUILD)/bin/s3 -bin/s3: obj/s3.o lib/libs3.a +$(BUILD)/bin/s3: $(BUILD)/obj/s3.o $(BUILD)/lib/libs3.a + @mkdir -p $(dir $@) gcc -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread -lssl # -------------------------------------------------------------------------- +# libs3 header targets + +.PHONY: headers +headers: $(BUILD)/include/libs3.h + +$(BUILD)/include/libs3.h: inc/libs3.h + @mkdir -p $(dir $@) + cp $< $@ + + +# -------------------------------------------------------------------------- # Test targets -test: bin/testsimplexml +.PHONY: test +test: $(BUILD)/bin/testsimplexml -bin/testsimplexml: src/testsimplexml.o lib/libs3.a +$(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o $(BUILD)/lib/libs3.a + @mkdir -p $(dir $@) gcc -o $@ $^ $(LIBXML2_LIBS) @@ -126,5 +188,4 @@ bin/testsimplexml: src/testsimplexml.o lib/libs3.a .PHONY: clean clean: - rm -f obj/*.o obj/*.do $(LIBS3_SHARED) lib/libs3.a \ - bin/s3 bin/testsimplexml + rm -rf $(BUILD) @@ -2,16 +2,21 @@ To install libs3 on a POSIX system (except Microsoft Windows): -------------------------------------------------------------- -* CFLAGS=-O3 make +*** For RPM-based systems *** -* cp -a bin/s3 /usr/bin +rpmbuild -ta <libs3 archive> -* cp -a lib/libs3.* /usr/lib +for example: -* cp -a inc/libs3.h /usr/include +rpmbuild -ta libs3-0.3.tar.gz -This is currently very primitive; eventually, support for a variety of systems -via software packaging will be supported. +*** For all other systems *** + +* CFLAGS=-O3 make install + +Note that additionally, the installation directory can be specified: + +* CFLAGS=-O3 INSTALL=/usr/local make install To install libs3 on a Microsoft Windows system: diff --git a/inc/libs3.h b/inc/libs3.h index 5b0ccdd..081885b 100644 --- a/inc/libs3.h +++ b/inc/libs3.h @@ -37,9 +37,9 @@ * - To provide a simple and straightforward API for accessing all of S3's * functionality * - To not require the developer using libs3 to need to know anything about: - * - HTTP - * - XML - * - SSL + * - HTTP + * - XML + * - SSL * In other words, this API is meant to stand on its own, without requiring * any implicit knowledge of how S3 services are accessed using HTTP * protocols. diff --git a/libs3.spec b/libs3.spec new file mode 100644 index 0000000..eaeb62f --- /dev/null +++ b/libs3.spec @@ -0,0 +1,58 @@ +Summary: C Library for Amazon S3 Access +Name: libs3 +Version: trunk +Release: 1 +License: GPL +Group: Development/Tools +URL: http://sourceforge.net/projects/reallibs3 +Source0: libs3-trunk.tar.gz +Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root +Buildrequires: curl-devel +Buildrequires: libxml2-devel +Buildrequires: make +Requires: curl +Requires: libxml2 + +%define debug_package %{nil} + +%description +This library provides an API for using Amazon's S3 service (see +http://s3.amazonaws.com). Its design goals are: + +- To provide a simple and straightforward API for accessing all of S3's + functionality +- To not require the developer using libs3 to need to know anything about: + - HTTP + - XML + - SSL + In other words, this API is meant to stand on its own, without requiring + any implicit knowledge of how S3 services are accessed using HTTP + protocols. +- To be usable from multithreaded code +- To be usable by code which wants to process multiple S3 requests + simultaneously from a single thread +- To be usable in the simple, straightforward way using sequentialized + blocking requests + +%prep +%setup -q + +%build +CFLAGS=-O3 BUILD=$RPM_BUILD_ROOT/build make exported + +%install +BUILD=$RPM_BUILD_ROOT/build INSTALL=$RPM_BUILD_ROOT/usr make install +rm -rf $RPM_BUILD_ROOT/build + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +/usr/bin/* +/usr/include/* +/usr/lib/* + +%changelog +* Tue Aug 05 2008 <bryan@ischo,com> Bryan Ischo +- Initial build. |