summaryrefslogtreecommitdiff
path: root/GNUmakefile.mingw
diff options
context:
space:
mode:
authorBryan Ischo <bryan@ischo.com>2008-08-07 14:20:31 +0000
committerBryan Ischo <bryan@ischo.com>2008-08-07 14:20:31 +0000
commit035dd9752eeefdcbb885bc234cda04563f68d319 (patch)
tree1854a13b20f9532cf9b767df55789362bfde76e6 /GNUmakefile.mingw
parent744c19acf5d8dd7c02193bf3fafd2e6a548f43e4 (diff)
downloadceph-libs3-035dd9752eeefdcbb885bc234cda04563f68d319.tar.gz
* Support build on Microsoft Windows via MingW
* Don't verify Amazon S3's SSL certificate, doing so causes problems * Added error code to properly report the case where the SSL certificate verification fails
Diffstat (limited to 'GNUmakefile.mingw')
-rw-r--r--GNUmakefile.mingw208
1 files changed, 208 insertions, 0 deletions
diff --git a/GNUmakefile.mingw b/GNUmakefile.mingw
new file mode 100644
index 0000000..29994a5
--- /dev/null
+++ b/GNUmakefile.mingw
@@ -0,0 +1,208 @@
+# 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 := 0
+LIBS3_VER_MINOR := 3
+LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
+
+
+# --------------------------------------------------------------------------
+# BUILD directory
+ifndef BUILD
+ BUILD := build
+endif
+
+
+# --------------------------------------------------------------------------
+# DESTDIR directory
+ifndef DESTDIR
+ DESTDIR := destdir
+endif
+
+
+# --------------------------------------------------------------------------
+# Acquire configuration information for libraries that libs3 depends upon
+
+ifndef CURL_LIBS
+ CURL_LIBS := -Lc:\libs3-libs\bin -lcurl
+endif
+
+ifndef CURL_CFLAGS
+ CURL_CFLAGS := -Ic:\libs3-libs\include
+endif
+
+ifndef LIBXML2_LIBS
+ LIBXML2_LIBS := -Lc:\libs3-libs\bin -lxml2
+endif
+
+ifndef LIBXML2_CFLAGS
+ LIBXML2_CFLAGS := -Ic:\libs3-libs\include
+endif
+
+ifndef OPENSSL_LIBS
+ OPENSSL_LIBS := -Lc:\openssl -lssl32 -leay32
+endif
+
+ifndef OPENSSL_CFLAGS
+ OPENSSL_CFLAGS := -Ic:\openssl\include
+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 -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
+ $(OPENSSL_CFLAGS) \
+ -DLIBS3_VER_MAJOR=$(LIBS3_VER_MAJOR) \
+ -DLIBS3_VER_MINOR=$(LIBS3_VER_MINOR) \
+ -Dsleep=Sleep \
+ -Iinc/mingw -include windows.h
+
+
+# --------------------------------------------------------------------------
+# Default targets are the library and driver program
+
+.PHONY: exported
+exported: libs3 s3 headers
+
+
+# --------------------------------------------------------------------------
+# Install target
+
+.PHONY: install
+install: libs3 s3 headers
+ 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
+ install -Dps -m u+rw,go+r $(BUILD)/lib/libs3.a $(DESTDIR)/lib/libs3.a
+ install -Dps -m u+rw,go+r $(BUILD)/lib/libs3.so \
+ $(DESTDIR)/lib/libs3.so
+ ln -sf libs3.so $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR)
+ ln -sf libs3.so.$(LIBS3_VER_MAJOR) \
+ $(DESTDIR)/lib/libs3.so.$(LIBS3_VER)
+
+
+# --------------------------------------------------------------------------
+# Uninstall target
+
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)/bin/s3 \
+ $(DESTDIR)/include/libs3.h \
+ $(DESTDIR)/lib/libs3.a \
+ $(DESTDIR)/lib/libs3.so \
+ $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR) \
+ $(DESTDIR)/lib/libs3.so.$(LIBS3_VER) \
+
+
+# --------------------------------------------------------------------------
+# Compile target patterns
+
+$(BUILD)/obj/%.o: src/%.c
+ -@mkdir $(subst /,\,$(dir $@))
+ gcc $(CFLAGS) -o $@ -c $<
+
+
+# --------------------------------------------------------------------------
+# libs3 library targets
+
+LIBS3_SHARED = $(BUILD)/lib/libs3.dll
+
+.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 src/mingw_functions.c
+
+$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
+ -@mkdir $(subst /,\,$(dir $@))
+ gcc -shared -Wl,--out-implib,libs3.a -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) $(OPENSSL_LIBS) -lws2_32
+
+$(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
+ -@mkdir $(subst /,\,$(dir $@))
+ $(AR) cr $@ $^
+
+
+# --------------------------------------------------------------------------
+# Driver program targets
+
+.PHONY: s3
+s3: $(BUILD)/bin/s3.exe
+
+$(BUILD)/bin/s3.exe: $(BUILD)/obj/s3.o $(BUILD)/lib/libs3.a
+ -@mkdir $(subst /,\,$(dir $@))
+ gcc -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) $(OPENSSL_LIBS) -lws2_32
+
+
+# --------------------------------------------------------------------------
+# libs3 header targets
+
+.PHONY: headers
+headers: $(BUILD)\include\libs3.h
+
+$(BUILD)\include\libs3.h: inc\libs3.h
+ -@mkdir $(subst /,\,$(dir $@))
+ copy $< $@
+
+
+# --------------------------------------------------------------------------
+# Test targets
+
+.PHONY: test
+test: $(BUILD)/bin/testsimplexml
+
+$(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o $(BUILD)/lib/libs3.a
+ -@mkdir $(subst /,\,$(dir $@))
+ gcc -o $@ $^ $(LIBXML2_LIBS)
+
+
+# --------------------------------------------------------------------------
+# Clean target
+
+.PHONY: clean
+clean:
+ mswin\rmrf.bat $(BUILD)