summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/onigmo/win32/Makefile.mingw
blob: 041d2839dcaa3d6688400a1630500ebb7fee42d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Onigmo Makefile for mingw32

product_name = onigmo

# Comment out the next line, if you don't want to use LTCG.
USE_LTCG = 1

# Enable the next line, if you want to use a .def file.
#DEFFILE = onig.def


# Get the default ARCH. (i686, x86-64, etc.)
ifndef ARCH
ARCH := $(shell $(CC) -dumpmachine | sed -e 's/-.*//' -e 's/_/-/' -e 's/^mingw32$$/i686/')
endif


CPPFLAGS =
CFLAGS = -O2 -Wall
LDFLAGS =
LOADLIBES =
ARLIB = ar
ARLIB_FLAGS = cr
ARDLL = gcc
ARDLL_FLAGS = -shared $(LINKFLAGS)
LINKFLAGS =

INSTALL = install -c
CP      = cp
RMDIR   = rm -rf
CC = gcc
RC = windres
DEFS = -DHAVE_CONFIG_H -DEXPORT

ifneq ($(ARCH),x86-64)
PYTHON = py -3.4-32
else
PYTHON = py -3
endif

WORKDIR = build_$(ARCH)

ifdef DEFFILE
# Use a .def file to export APIs.
CFLAGS = $(CFLAGS) -DONIG_EXTERN=extern
ARDLL_FLAGS = $(ARDLL_FLAGS) $(DEFFILE)
endif

subdirs =

libbase   = onigmo
libname   = $(WORKDIR)/lib$(libbase).a
dllname   = $(WORKDIR)/$(libbase).dll
dlllib    = $(WORKDIR)/lib$(libbase).dll.a

onigheaders  = onigmo.h regint.h regparse.h regenc.h st.h
posixheaders = onigmoposix.h
headers      = $(posixheaders) $(onigheaders)

onigobjs      = $(WORKDIR)/reggnu.o $(WORKDIR)/regerror.o \
		$(WORKDIR)/regparse.o $(WORKDIR)/regext.o \
		$(WORKDIR)/regcomp.o $(WORKDIR)/regexec.o \
		$(WORKDIR)/regenc.o $(WORKDIR)/regsyntax.o \
		$(WORKDIR)/regtrav.o $(WORKDIR)/regversion.o \
		$(WORKDIR)/st.o
posixobjs     = $(WORKDIR)/regposix.o $(WORKDIR)/regposerr.o
libobjs       = $(onigobjs) $(posixobjs)

jp_objs       = $(WORKDIR)/euc_jp.o $(WORKDIR)/shift_jis.o \
		$(WORKDIR)/windows_31j.o

iso_8859_objs = $(WORKDIR)/iso_8859_1.o  $(WORKDIR)/iso_8859_2.o \
		$(WORKDIR)/iso_8859_3.o  $(WORKDIR)/iso_8859_4.o \
		$(WORKDIR)/iso_8859_5.o  $(WORKDIR)/iso_8859_6.o \
		$(WORKDIR)/iso_8859_7.o  $(WORKDIR)/iso_8859_8.o \
		$(WORKDIR)/iso_8859_9.o  $(WORKDIR)/iso_8859_10.o \
		$(WORKDIR)/iso_8859_11.o $(WORKDIR)/iso_8859_13.o \
		$(WORKDIR)/iso_8859_14.o $(WORKDIR)/iso_8859_15.o \
		$(WORKDIR)/iso_8859_16.o

encobjs       = $(WORKDIR)/ascii.o $(WORKDIR)/utf_8.o \
		$(WORKDIR)/unicode.o \
		$(WORKDIR)/utf_16be.o $(WORKDIR)/utf_16le.o \
		$(WORKDIR)/utf_32be.o $(WORKDIR)/utf_32le.o \
		$(jp_objs) $(iso_8859_objs) \
		$(WORKDIR)/euc_tw.o $(WORKDIR)/euc_kr.o $(WORKDIR)/big5.o \
		$(WORKDIR)/gb18030.o \
		$(WORKDIR)/koi8_r.o $(WORKDIR)/koi8_u.o \
		$(WORKDIR)/windows_1250.o $(WORKDIR)/windows_1251.o \
		$(WORKDIR)/windows_1252.o $(WORKDIR)/windows_1253.o \
		$(WORKDIR)/windows_1254.o $(WORKDIR)/windows_1257.o

resobj        = $(WORKDIR)/onigmo.o

onigsources  = regerror.c regparse.c regext.c regcomp.c regexec.c regenc.c \
	       regsyntax.c regtrav.c regversion.c reggnu.c st.c
posixsources = regposix.c regposerr.c
libsources   = $(posixsources) $(onigsources)

encdir       = enc
distfiles    = README COPYING HISTORY \
		Makefile.in configure.in config.h.in configure \
		$(headers) $(libsources) \
		test.rb testconv.rb
testc        = testc
testcu       = testu
testp        = testp

makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)'

.SUFFIXES:
.SUFFIXES: .o .c .h .ps .dvi .info .texinfo .res .rc

$(WORKDIR)/%.o: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -Iwin32 -I. -o $@ -c $<

$(WORKDIR)/%.o: $(encdir)/%.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -Iwin32 -I. -I$(encdir)/unicode -o $@ -c $<

$(WORKDIR)/%.o: win32/%.rc
	$(RC) -O coff -I. $< $@

# targets
default: all

setup:


all: lib dll

lib: $(libname)
dll: $(dllname)

$(libname): $(WORKDIR) $(libobjs) $(encobjs)
	$(ARLIB) $(ARLIB_FLAGS) $@ $(libobjs) $(encobjs)

$(dllname): $(WORKDIR) $(libobjs) $(encobjs) $(resobj) $(DEFFILE)
	$(ARDLL) $(libobjs) $(encobjs) $(resobj) -o $@ $(ARDLL_FLAGS) -Wl,--out-implib,$(dlllib)

$(WORKDIR):
	-mkdir $(WORKDIR)

$(WORKDIR)/regparse.o:  regparse.c $(onigheaders) win32/config.h st.h
$(WORKDIR)/regext.o:    regext.c   $(onigheaders) win32/config.h
$(WORKDIR)/regtrav.o:   regtrav.c  $(onigheaders) win32/config.h
$(WORKDIR)/regcomp.o:   regcomp.c  $(onigheaders) win32/config.h
$(WORKDIR)/regexec.o:   regexec.c  regint.h regenc.h onigmo.h win32/config.h
$(WORKDIR)/reggnu.o:    reggnu.c   regint.h regenc.h onigmo.h win32/config.h onigmognu.h
$(WORKDIR)/regerror.o:  regerror.c regint.h regenc.h onigmo.h win32/config.h
$(WORKDIR)/regenc.o:    regenc.c   regint.h regenc.h onigmo.h win32/config.h
$(WORKDIR)/regsyntax.o: regsyntax.c regint.h regenc.h onigmo.h win32/config.h
$(WORKDIR)/regversion.o: regversion.c onigmo.h win32/config.h
$(WORKDIR)/regposix.o:  regposix.c $(posixheaders) onigmo.h win32/config.h
$(WORKDIR)/regposerr.o: regposerr.c $(posixheaders) win32/config.h
$(WORKDIR)/st.o:        st.c regint.h onigmo.h win32/config.h st.h

$(WORKDIR)/ascii.o:      $(encdir)/ascii.c regenc.h win32/config.h
$(WORKDIR)/unicode.o:    $(encdir)/unicode.c regint.h regenc.h win32/config.h $(encdir)/unicode/casefold.h $(encdir)/unicode/name2ctype.h
$(WORKDIR)/utf_8.o:      $(encdir)/utf_8.c regenc.h win32/config.h
$(WORKDIR)/utf_16be.o:   $(encdir)/utf_16be.c regenc.h win32/config.h
$(WORKDIR)/utf_16le.o:   $(encdir)/utf_16le.c regenc.h win32/config.h
$(WORKDIR)/utf_32be.o:   $(encdir)/utf_32be.c regenc.h win32/config.h
$(WORKDIR)/utf_32le.o:   $(encdir)/utf_32le.c regenc.h win32/config.h
$(WORKDIR)/euc_jp.o:     $(encdir)/euc_jp.c regenc.h win32/config.h $(encdir)/jis/props.h
$(WORKDIR)/euc_tw.o:     $(encdir)/euc_tw.c regenc.h win32/config.h
$(WORKDIR)/euc_kr.o:     $(encdir)/euc_kr.c regenc.h win32/config.h
$(WORKDIR)/shift_jis.o:  $(encdir)/shift_jis.c $(encdir)/shift_jis.h regenc.h win32/config.h $(encdir)/jis/props.h
$(WORKDIR)/windows_31j.o: $(encdir)/windows_31j.c $(encdir)/shift_jis.h regenc.h win32/config.h $(encdir)/jis/props.h
$(WORKDIR)/iso_8859_1.o:  $(encdir)/iso_8859_1.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_2.o:  $(encdir)/iso_8859_2.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_3.o:  $(encdir)/iso_8859_3.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_4.o:  $(encdir)/iso_8859_4.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_5.o:  $(encdir)/iso_8859_5.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_6.o:  $(encdir)/iso_8859_6.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_7.o:  $(encdir)/iso_8859_7.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_8.o:  $(encdir)/iso_8859_8.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_9.o:  $(encdir)/iso_8859_9.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_10.o: $(encdir)/iso_8859_10.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_11.o: $(encdir)/iso_8859_11.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_13.o: $(encdir)/iso_8859_13.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_14.o: $(encdir)/iso_8859_14.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_15.o: $(encdir)/iso_8859_15.c regenc.h win32/config.h
$(WORKDIR)/iso_8859_16.o: $(encdir)/iso_8859_16.c regenc.h win32/config.h
#$(WORKDIR)/koi8.o:       $(encdir)/koi8.c   regenc.h win32/config.h
$(WORKDIR)/koi8_r.o:     $(encdir)/koi8_r.c regenc.h win32/config.h
$(WORKDIR)/koi8_u.o:     $(encdir)/koi8_u.c regenc.h win32/config.h
$(WORKDIR)/windows_1250.o: $(encdir)/windows_1250.c regenc.h win32/config.h
$(WORKDIR)/windows_1251.o: $(encdir)/windows_1251.c regenc.h win32/config.h
$(WORKDIR)/windows_1252.o: $(encdir)/windows_1252.c regenc.h win32/config.h
$(WORKDIR)/windows_1253.o: $(encdir)/windows_1253.c regenc.h win32/config.h
$(WORKDIR)/windows_1254.o: $(encdir)/windows_1254.c regenc.h win32/config.h
$(WORKDIR)/windows_1257.o: $(encdir)/windows_1257.c regenc.h win32/config.h
$(WORKDIR)/big5.o:       $(encdir)/big5.c   regenc.h win32/config.h
$(WORKDIR)/gb18030.o:    $(encdir)/gb18030.c   regenc.h win32/config.h

$(WORKDIR)/onigmo.o: win32/onigmo.rc onigmo.h


# Tests
test: all ctest utest ptest pytest

# C library test
ctest: $(WORKDIR)/$(testc)
	$(WORKDIR)/$(testc)

# C library test (Unicode)
utest: $(WORKDIR)/$(testcu)
	$(WORKDIR)/$(testcu)

# POSIX C library test
ptest: $(WORKDIR)/$(testp)
	$(WORKDIR)/$(testp)

# Python test
pytest:
	cd $(WORKDIR) && $(PYTHON) ../testpy.py EUC-JP
	cd $(WORKDIR) && $(PYTHON) ../testpy.py SJIS
	cd $(WORKDIR) && $(PYTHON) ../testpy.py UTF-8
	cd $(WORKDIR) && $(PYTHON) ../testpy.py UTF-16LE
	cd $(WORKDIR) && $(PYTHON) ../testpy.py UTF-16BE
	cd $(WORKDIR) && $(PYTHON) ../testpy.py UTF-32LE
	cd $(WORKDIR) && $(PYTHON) ../testpy.py UTF-32BE


$(WORKDIR)/$(testc): win32/$(testc).c $(libname)
	$(CC) $(CFLAGS) -o $(WORKDIR)/$(testc) -DONIG_EXTERN=extern win32/$(testc).c -I. $(libname)

$(WORKDIR)/$(testp): win32/$(testc).c $(dlllib)
	$(CC) $(CFLAGS) -DPOSIX_TEST -o $(WORKDIR)/$(testp) win32/$(testc).c -I. $(dlllib)

#$(testc)u.c: test.rb testconvu.rb
#	ruby -Ke testconvu.rb test.rb > $@

$(WORKDIR)/$(testcu): $(testcu).c $(libname)
	$(CC) $(CFLAGS) -o $(WORKDIR)/$(testcu) -DONIG_EXTERN=extern $(testcu).c -I. $(libname)

$(libbase).def: win32/makedef.py onigmo.h regenc.h onigmognu.h onigmoposix.h
	$(PYTHON) win32/makedef.py > $@

clean:
	-$(RMDIR) $(WORKDIR)


samples: all
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/simple  sample\simple.c  $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/posix   sample\posix.c   $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/names   sample\names.c   $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/listcap sample\listcap.c $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/sql     sample\sql.c     $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/encode  sample\encode.c  $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/syntax  sample\syntax.c  $(dlllib)
	$(CC) $(CFLAGS) -I. -o $(WORKDIR)/crnl    sample\crnl.c    $(dlllib)