3 # Copyright 2008 Bryan Ischo <bryan@ischo.com>
5 # This file is part of libs3.
7 # libs3 is free software: you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation, version 3 of the License.
11 # In addition, as a special exception, the copyright holders give
12 # permission to link the code of this library and its programs with the
13 # OpenSSL library, and distribute linked combinations including the two.
15 # libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 # You should have received a copy of the GNU General Public License version 3
21 # along with libs3, in a file named COPYING. If not, see
22 # <http://www.gnu.org/licenses/>.
24 # I tried to use the autoconf/automake/autolocal/etc (i.e. autohell) tools
25 # but I just couldn't stomach them. Since this is a Makefile for POSIX
26 # systems, I will simply do away with autohell completely and use a GNU
27 # Makefile. GNU make ought to be available pretty much everywhere, so I
28 # don't see this being a significant issue for portability.
30 # All commands assume a GNU compiler. For systems which do not use a GNU
31 # compiler, write scripts with the same names as these commands, and taking
32 # the same arguments, and translate the arguments and commands into the
33 # appropriate non-POSIX ones as needed. libs3 assumes a GNU toolchain as
34 # the most portable way to build software possible. Non-POSIX, non-GNU
35 # systems can do the work of supporting this build infrastructure.
38 # --------------------------------------------------------------------------
39 # Set libs3 version number
43 LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
46 # --------------------------------------------------------------------------
53 # --------------------------------------------------------------------------
56 DESTDIR := libs3-$(LIBS3_VER)
60 # --------------------------------------------------------------------------
61 # Acquire configuration information for libraries that libs3 depends upon
64 CURL_LIBS := -Lc:\libs3-libs\bin -lcurl
68 CURL_CFLAGS := -Ic:\libs3-libs\include
72 LIBXML2_LIBS := -Lc:\libs3-libs\bin -lxml2
76 LIBXML2_CFLAGS := -Ic:\libs3-libs\include
80 # --------------------------------------------------------------------------
81 # These CFLAGS assume a GNU compiler. For other compilers, write a script
82 # which converts these arguments into their equivalent for that particular
89 CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
90 $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
91 -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
92 -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
93 -DLIBS3_VER=\"$(LIBS3_VER)\" \
96 -D_POSIX_C_SOURCE=200112L \
97 -Dsleep=Sleep -DFOPEN_EXTRA_FLAGS=\"b\" \
98 -Iinc/mingw -include windows.h
100 LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS)
102 # --------------------------------------------------------------------------
103 # Default targets are everything
109 # --------------------------------------------------------------------------
110 # Exported targets are the library and driver program
113 exported: libs3 s3 headers
116 # --------------------------------------------------------------------------
121 -@mkdir $(DESTDIR)\bin
122 -@mkdir $(DESTDIR)\include
123 -@mkdir $(DESTDIR)\lib
124 copy $(BUILD)\bin\s3.exe $(DESTDIR)\bin
125 copy $(BUILD)\bin\libs3.dll $(DESTDIR)\bin
126 copy $(BUILD)\lib\libs3.a $(DESTDIR)\lib
127 copy mswin\libs3.def $(DESTDIR)\lib
128 copy $(BUILD)\include\libs3.h $(DESTDIR)\include
129 copy LICENSE $(DESTDIR)
130 copy COPYING $(DESTDIR)
133 # --------------------------------------------------------------------------
134 # Compile target patterns
136 $(BUILD)/obj/%.o: src/%.c
137 -@mkdir $(subst /,\,$(dir $@))
138 gcc $(CFLAGS) -o $@ -c $<
141 # --------------------------------------------------------------------------
142 # libs3 library targets
144 LIBS3_SHARED = $(BUILD)/bin/libs3.dll
147 libs3: $(LIBS3_SHARED) $(BUILD)/lib/libs3.a
149 LIBS3_SOURCES := src/acl.c src/bucket.c src/error_parser.c src/general.c \
150 src/object.c src/request.c src/request_context.c \
151 src/response_headers_handler.c src/service_access_logging.c \
152 src/service.c src/simplexml.c src/util.c src/mingw_functions.c
154 $(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
155 -@mkdir $(subst /,\,$(dir $@))
156 gcc -shared -o $@ $^ $(LDFLAGS) -lws2_32
158 $(BUILD)/lib/libs3.a: $(LIBS3_SHARED)
159 -@mkdir $(subst /,\,$(dir $@))
160 dlltool --def mswin\libs3.def --dllname $(subst /,\,$<) \
161 --output-lib $(subst /,\,$@)
164 # --------------------------------------------------------------------------
165 # Driver program targets
168 s3: $(BUILD)/bin/s3.exe
170 $(BUILD)/bin/s3.exe: $(BUILD)/obj/s3.o $(BUILD)/obj/mingw_s3_functions.o \
172 -@mkdir $(subst /,\,$(dir $@))
173 gcc -o $@ $^ $(LDFLAGS) -lws2_32
176 # --------------------------------------------------------------------------
177 # libs3 header targets
180 headers: $(BUILD)\include\libs3.h
182 $(BUILD)\include\libs3.h: inc\libs3.h
183 -@mkdir $(subst /,\,$(dir $@))
187 # --------------------------------------------------------------------------
191 test: $(BUILD)/bin/testsimplexml
193 $(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o \
194 $(BUILD)/obj/simplexml.o
195 -@mkdir $(subst /,\,$(dir $@))
196 gcc -o $@ $^ $(LIBXML2_LIBS)
199 # --------------------------------------------------------------------------
204 mswin\rmrf.bat $(BUILD)