aab4f02f81b249bc08b70a2c16b9a83178e993d6
[bluesky.git] / libs3-1.4 / GNUmakefile.mingw
1 # GNUmakefile
2
3 # Copyright 2008 Bryan Ischo <bryan@ischo.com>
4
5 # This file is part of libs3.
6
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.
10 #
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.
14 #
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
18 # details.
19 #
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/>.
23
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.
29
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.
36
37
38 # --------------------------------------------------------------------------
39 # Set libs3 version number
40
41 LIBS3_VER_MAJOR := 1
42 LIBS3_VER_MINOR := 4
43 LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
44
45
46 # --------------------------------------------------------------------------
47 # BUILD directory
48 ifndef BUILD
49     BUILD := build
50 endif
51
52
53 # --------------------------------------------------------------------------
54 # DESTDIR directory
55 ifndef DESTDIR
56     DESTDIR := libs3-$(LIBS3_VER)
57 endif
58
59
60 # --------------------------------------------------------------------------
61 # Acquire configuration information for libraries that libs3 depends upon
62
63 ifndef CURL_LIBS
64     CURL_LIBS := -Lc:\libs3-libs\bin -lcurl
65 endif
66
67 ifndef CURL_CFLAGS
68     CURL_CFLAGS := -Ic:\libs3-libs\include
69 endif
70
71 ifndef LIBXML2_LIBS
72     LIBXML2_LIBS := -Lc:\libs3-libs\bin -lxml2
73 endif
74
75 ifndef LIBXML2_CFLAGS
76     LIBXML2_CFLAGS := -Ic:\libs3-libs\include
77 endif
78
79
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
83 # compiler.
84
85 ifndef CFLAGS
86     CFLAGS = -O3
87 endif
88
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)\" \
94           -D__STRICT_ANSI__ \
95           -D_ISOC99_SOURCE \
96           -D_POSIX_C_SOURCE=200112L \
97           -Dsleep=Sleep -DFOPEN_EXTRA_FLAGS=\"b\" \
98           -Iinc/mingw -include windows.h
99
100 LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS)
101
102 # --------------------------------------------------------------------------
103 # Default targets are everything
104
105 .PHONY: all
106 all: exported test
107
108
109 # --------------------------------------------------------------------------
110 # Exported targets are the library and driver program
111
112 .PHONY: exported
113 exported: libs3 s3 headers
114
115
116 # --------------------------------------------------------------------------
117 # Install target
118
119 .PHONY: install
120 install: exported
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)
131
132
133 # --------------------------------------------------------------------------
134 # Compile target patterns
135
136 $(BUILD)/obj/%.o: src/%.c
137         -@mkdir $(subst /,\,$(dir $@))
138         gcc $(CFLAGS) -o $@ -c $<
139
140
141 # --------------------------------------------------------------------------
142 # libs3 library targets
143
144 LIBS3_SHARED = $(BUILD)/bin/libs3.dll
145
146 .PHONY: libs3
147 libs3: $(LIBS3_SHARED) $(BUILD)/lib/libs3.a
148
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
153
154 $(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
155         -@mkdir $(subst /,\,$(dir $@))
156         gcc -shared -o $@ $^ $(LDFLAGS) -lws2_32
157
158 $(BUILD)/lib/libs3.a: $(LIBS3_SHARED)
159         -@mkdir $(subst /,\,$(dir $@))
160         dlltool --def mswin\libs3.def --dllname $(subst /,\,$<) \
161             --output-lib $(subst /,\,$@)
162
163
164 # --------------------------------------------------------------------------
165 # Driver program targets
166
167 .PHONY: s3
168 s3: $(BUILD)/bin/s3.exe
169
170 $(BUILD)/bin/s3.exe: $(BUILD)/obj/s3.o $(BUILD)/obj/mingw_s3_functions.o \
171                      $(BUILD)/lib/libs3.a
172         -@mkdir $(subst /,\,$(dir $@))
173         gcc -o $@ $^ $(LDFLAGS) -lws2_32
174
175
176 # --------------------------------------------------------------------------
177 # libs3 header targets
178
179 .PHONY: headers
180 headers: $(BUILD)\include\libs3.h
181
182 $(BUILD)\include\libs3.h: inc\libs3.h
183         -@mkdir $(subst /,\,$(dir $@))
184         copy $< $@
185
186
187 # --------------------------------------------------------------------------
188 # Test targets
189
190 .PHONY: test
191 test: $(BUILD)/bin/testsimplexml
192
193 $(BUILD)/bin/testsimplexml: $(BUILD)/obj/testsimplexml.o \
194                             $(BUILD)/obj/simplexml.o
195         -@mkdir $(subst /,\,$(dir $@))
196         gcc -o $@ $^ $(LIBXML2_LIBS)
197
198
199 # --------------------------------------------------------------------------
200 # Clean target
201
202 .PHONY: clean
203 clean:
204         mswin\rmrf.bat $(BUILD)