| 1 |
# Onigmo Makefile for Win32 |
| 2 |
|
| 3 |
product_name = onigmo |
| 4 |
|
| 5 |
# Comment out the next line, if you don't want to use LTCG. |
| 6 |
USE_LTCG = 1 |
| 7 |
|
| 8 |
# Comment out the next line, if you don't want to use multiprocess build. |
| 9 |
USE_MP = 1 |
| 10 |
|
| 11 |
# Enable the next line, if you want to enable .pdb file on release build. |
| 12 |
#ENABLE_PDB = 1 |
| 13 |
|
| 14 |
# Enable the next line, if you want to use a .def file. |
| 15 |
#DEFFILE = onigmo.def |
| 16 |
|
| 17 |
|
| 18 |
# Set ARCH. "x64" or "x86". |
| 19 |
!ifndef ARCH |
| 20 |
!if ("$(CPU)"=="AMD64" && !DEFINED(386)) || "$(TARGET_CPU)"=="x64" || DEFINED(AMD64) || "$(PLATFORM)"=="x64" || "$(PLATFORM)"=="X64" |
| 21 |
ARCH = x64 |
| 22 |
!else |
| 23 |
ARCH = x86 |
| 24 |
!endif |
| 25 |
!endif |
| 26 |
|
| 27 |
|
| 28 |
CPPFLAGS = |
| 29 |
CFLAGS = -O2 -nologo -W3 |
| 30 |
LDFLAGS = |
| 31 |
LOADLIBES = |
| 32 |
ARLIB = lib |
| 33 |
ARLIB_FLAGS = -nologo |
| 34 |
ARDLL = cl |
| 35 |
ARDLL_FLAGS = -nologo -LD $(LINKFLAGS) -dll |
| 36 |
LINKFLAGS = -link -incremental:no |
| 37 |
|
| 38 |
INSTALL = install -c |
| 39 |
CP = copy |
| 40 |
RMDIR = rd /s/q |
| 41 |
CC = cl |
| 42 |
RC = rc |
| 43 |
DEFS = -DHAVE_CONFIG_H -DEXPORT |
| 44 |
|
| 45 |
!if "$(ARCH)"=="x86" |
| 46 |
PYTHON = py -3.4-32 |
| 47 |
!else |
| 48 |
PYTHON = py -3 |
| 49 |
!endif |
| 50 |
|
| 51 |
!ifdef DEBUG |
| 52 |
DBGFLG = d |
| 53 |
!else |
| 54 |
DBGFLG = |
| 55 |
!endif |
| 56 |
|
| 57 |
WORKDIR = build_$(ARCH)$(DBGFLG) |
| 58 |
|
| 59 |
# Get the version of cl.exe. |
| 60 |
# 1. Write the version to a work file (mscver$(_NMAKE_VER).~). |
| 61 |
!if ![(echo _MSC_VER>mscver$(_NMAKE_VER).c) && \ |
| 62 |
(for /f %I in ('"$(CC) /EP mscver$(_NMAKE_VER).c 2>nul"') do @echo _MSC_VER=%I> mscver$(_NMAKE_VER).~)] |
| 63 |
# 2. Include it. |
| 64 |
!include mscver$(_NMAKE_VER).~ |
| 65 |
# 3. Clean up. |
| 66 |
!if [del mscver$(_NMAKE_VER).~ mscver$(_NMAKE_VER).c] |
| 67 |
!endif |
| 68 |
!endif |
| 69 |
|
| 70 |
!if DEFINED(USE_MP) && $(_MSC_VER) >= 1600 |
| 71 |
# Enable multiprocess build on VC2010+. |
| 72 |
CFLAGS = $(CFLAGS) -MP |
| 73 |
!endif |
| 74 |
|
| 75 |
!ifdef DEBUG |
| 76 |
|
| 77 |
# Debug Build |
| 78 |
|
| 79 |
# Enable debug information. |
| 80 |
CFLAGS = $(CFLAGS) -Zi -DDEBUG=1 -D_DEBUG=1 -MTd |
| 81 |
# Debug flags. (see regint.h) |
| 82 |
#CFLAGS = $(CFLAGS) -DONIG_DEBUG_PARSE_TREE -DONIG_DEBUG_COMPILE -DONIG_DEBUG_SEARCH -DONIG_DEBUG_MATCH -DONIG_DONT_OPTIMIZE |
| 83 |
ARDLL_FLAGS = -MTd $(ARDLL_FLAGS) -debug |
| 84 |
|
| 85 |
!else # DEBUG |
| 86 |
|
| 87 |
# Release Build |
| 88 |
|
| 89 |
!if DEFINED(USE_LTCG) && $(_MSC_VER) >= 1300 |
| 90 |
# Use LTCG (Link Time Code Generation) on VC++ 7.0 or later. |
| 91 |
CFLAGS = $(CFLAGS) -GL |
| 92 |
ARLIB_FLAGS = $(ARLIB_FLAGS) -LTCG |
| 93 |
ARDLL_FLAGS = $(ARDLL_FLAGS) -LTCG |
| 94 |
!endif |
| 95 |
!ifdef ENABLE_PDB |
| 96 |
CFLAGS = $(CFLAGS) -Zi |
| 97 |
ARDLL_FLAGS = $(ARDLL_FLAGS) -debug -PDBALTPATH:%%_PDB%% |
| 98 |
!endif |
| 99 |
|
| 100 |
!endif # DEBUG |
| 101 |
|
| 102 |
!ifdef DEFFILE |
| 103 |
# Use a .def file to export APIs. |
| 104 |
CFLAGS = $(CFLAGS) -DONIG_EXTERN=extern |
| 105 |
ARDLL_FLAGS = $(ARDLL_FLAGS) -def:$(DEFFILE) |
| 106 |
!endif |
| 107 |
|
| 108 |
subdirs = |
| 109 |
|
| 110 |
libbase = onigmo |
| 111 |
libname = $(WORKDIR)\$(libbase)_s.lib |
| 112 |
dllname = $(WORKDIR)\$(libbase).dll |
| 113 |
dlllib = $(WORKDIR)\$(libbase).lib |
| 114 |
|
| 115 |
onigheaders = onigmo.h regint.h regparse.h regenc.h st.h |
| 116 |
posixheaders = onigmoposix.h |
| 117 |
headers = $(posixheaders) $(onigheaders) |
| 118 |
|
| 119 |
onigobjs = $(WORKDIR)\reggnu.obj $(WORKDIR)\regerror.obj \ |
| 120 |
$(WORKDIR)\regparse.obj $(WORKDIR)\regext.obj \ |
| 121 |
$(WORKDIR)\regcomp.obj $(WORKDIR)\regexec.obj \ |
| 122 |
$(WORKDIR)\regenc.obj $(WORKDIR)\regsyntax.obj \ |
| 123 |
$(WORKDIR)\regtrav.obj $(WORKDIR)\regversion.obj \ |
| 124 |
$(WORKDIR)\st.obj |
| 125 |
posixobjs = $(WORKDIR)\regposix.obj $(WORKDIR)\regposerr.obj |
| 126 |
libobjs = $(onigobjs) $(posixobjs) |
| 127 |
|
| 128 |
jp_objs = $(WORKDIR)\euc_jp.obj $(WORKDIR)\shift_jis.obj \ |
| 129 |
$(WORKDIR)\windows_31j.obj |
| 130 |
|
| 131 |
iso_8859_objs = $(WORKDIR)\iso_8859_1.obj $(WORKDIR)\iso_8859_2.obj \ |
| 132 |
$(WORKDIR)\iso_8859_3.obj $(WORKDIR)\iso_8859_4.obj \ |
| 133 |
$(WORKDIR)\iso_8859_5.obj $(WORKDIR)\iso_8859_6.obj \ |
| 134 |
$(WORKDIR)\iso_8859_7.obj $(WORKDIR)\iso_8859_8.obj \ |
| 135 |
$(WORKDIR)\iso_8859_9.obj $(WORKDIR)\iso_8859_10.obj \ |
| 136 |
$(WORKDIR)\iso_8859_11.obj $(WORKDIR)\iso_8859_13.obj \ |
| 137 |
$(WORKDIR)\iso_8859_14.obj $(WORKDIR)\iso_8859_15.obj \ |
| 138 |
$(WORKDIR)\iso_8859_16.obj |
| 139 |
|
| 140 |
encobjs = $(WORKDIR)\ascii.obj $(WORKDIR)\utf_8.obj \ |
| 141 |
$(WORKDIR)\unicode.obj \ |
| 142 |
$(WORKDIR)\utf_16be.obj $(WORKDIR)\utf_16le.obj \ |
| 143 |
$(WORKDIR)\utf_32be.obj $(WORKDIR)\utf_32le.obj \ |
| 144 |
$(jp_objs) $(iso_8859_objs) \ |
| 145 |
$(WORKDIR)\euc_tw.obj $(WORKDIR)\euc_kr.obj $(WORKDIR)\big5.obj \ |
| 146 |
$(WORKDIR)\gb18030.obj \ |
| 147 |
$(WORKDIR)\koi8_r.obj $(WORKDIR)\koi8_u.obj \ |
| 148 |
$(WORKDIR)\windows_1250.obj $(WORKDIR)\windows_1251.obj \ |
| 149 |
$(WORKDIR)\windows_1252.obj $(WORKDIR)\windows_1253.obj \ |
| 150 |
$(WORKDIR)\windows_1254.obj $(WORKDIR)\windows_1257.obj |
| 151 |
|
| 152 |
resobj = $(WORKDIR)\onigmo.res |
| 153 |
|
| 154 |
onigsources = regerror.c regparse.c regext.c regcomp.c regexec.c regenc.c \ |
| 155 |
regsyntax.c regtrav.c regversion.c reggnu.c st.c |
| 156 |
posixsources = regposix.c regposerr.c |
| 157 |
libsources = $(posixsources) $(onigsources) |
| 158 |
|
| 159 |
encdir = enc |
| 160 |
distfiles = README COPYING HISTORY \ |
| 161 |
Makefile.in configure.in config.h.in configure \ |
| 162 |
$(headers) $(libsources) \ |
| 163 |
test.rb testconv.rb |
| 164 |
testc = testc |
| 165 |
testcu = testu |
| 166 |
testp = testp |
| 167 |
|
| 168 |
makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' |
| 169 |
|
| 170 |
.SUFFIXES: |
| 171 |
.SUFFIXES: .obj .c .h .ps .dvi .info .texinfo .res .rc |
| 172 |
|
| 173 |
!ifdef NOBatch |
| 174 |
.c{$(WORKDIR)\}.obj: |
| 175 |
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) /Iwin32 /I. /I.. /I$(encdir)\unicode /Fo$@ /c $< |
| 176 |
!else |
| 177 |
# batch-mode inference rules |
| 178 |
.c{$(WORKDIR)\}.obj:: |
| 179 |
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) /Iwin32 /I. /Fo$(WORKDIR)\ /c $< |
| 180 |
{$(encdir)\}.c{$(WORKDIR)\}.obj:: |
| 181 |
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) /Iwin32 /I. /I$(encdir)\unicode /Fo$(WORKDIR)\ /c $< |
| 182 |
!endif |
| 183 |
|
| 184 |
{win32\}.rc{$(WORKDIR)}.res: |
| 185 |
$(RC) /Fo$@ $< |
| 186 |
|
| 187 |
# targets |
| 188 |
default: all |
| 189 |
|
| 190 |
setup: |
| 191 |
|
| 192 |
|
| 193 |
all: lib dll |
| 194 |
|
| 195 |
lib: $(libname) |
| 196 |
dll: $(dllname) |
| 197 |
|
| 198 |
$(libname): $(WORKDIR) $(libobjs) $(encobjs) |
| 199 |
$(ARLIB) $(ARLIB_FLAGS) -out:$@ $(libobjs) $(encobjs) |
| 200 |
|
| 201 |
$(dllname): $(WORKDIR) $(libobjs) $(encobjs) $(resobj) $(DEFFILE) |
| 202 |
$(ARDLL) $(libobjs) $(encobjs) $(resobj) -Fe$@ $(ARDLL_FLAGS) |
| 203 |
|
| 204 |
$(WORKDIR): |
| 205 |
-mkdir $(WORKDIR) |
| 206 |
|
| 207 |
$(WORKDIR)\regparse.obj: regparse.c $(onigheaders) win32\config.h st.h |
| 208 |
$(WORKDIR)\regext.obj: regext.c $(onigheaders) win32\config.h |
| 209 |
$(WORKDIR)\regtrav.obj: regtrav.c $(onigheaders) win32\config.h |
| 210 |
$(WORKDIR)\regcomp.obj: regcomp.c $(onigheaders) win32\config.h |
| 211 |
$(WORKDIR)\regexec.obj: regexec.c regint.h regenc.h onigmo.h win32\config.h |
| 212 |
$(WORKDIR)\reggnu.obj: reggnu.c regint.h regenc.h onigmo.h win32\config.h onigmognu.h |
| 213 |
$(WORKDIR)\regerror.obj: regerror.c regint.h regenc.h onigmo.h win32\config.h |
| 214 |
$(WORKDIR)\regenc.obj: regenc.c regint.h regenc.h onigmo.h win32\config.h |
| 215 |
$(WORKDIR)\regsyntax.obj: regsyntax.c regint.h regenc.h onigmo.h win32\config.h |
| 216 |
$(WORKDIR)\regversion.obj: regversion.c onigmo.h win32\config.h |
| 217 |
$(WORKDIR)\regposix.obj: regposix.c $(posixheaders) onigmo.h win32\config.h |
| 218 |
$(WORKDIR)\regposerr.obj: regposerr.c $(posixheaders) win32\config.h |
| 219 |
$(WORKDIR)\st.obj: st.c regint.h onigmo.h win32\config.h st.h |
| 220 |
|
| 221 |
$(WORKDIR)\ascii.obj: $(encdir)\ascii.c regenc.h win32\config.h |
| 222 |
$(WORKDIR)\unicode.obj: $(encdir)\unicode.c regint.h regenc.h win32\config.h $(encdir)\unicode\casefold.h $(encdir)\unicode\name2ctype.h |
| 223 |
$(WORKDIR)\utf_8.obj: $(encdir)\utf_8.c regenc.h win32\config.h |
| 224 |
$(WORKDIR)\utf_16be.obj: $(encdir)\utf_16be.c regenc.h win32\config.h |
| 225 |
$(WORKDIR)\utf_16le.obj: $(encdir)\utf_16le.c regenc.h win32\config.h |
| 226 |
$(WORKDIR)\utf_32be.obj: $(encdir)\utf_32be.c regenc.h win32\config.h |
| 227 |
$(WORKDIR)\utf_32le.obj: $(encdir)\utf_32le.c regenc.h win32\config.h |
| 228 |
$(WORKDIR)\euc_jp.obj: $(encdir)\euc_jp.c regenc.h win32\config.h $(encdir)\jis\props.h |
| 229 |
$(WORKDIR)\euc_tw.obj: $(encdir)\euc_tw.c regenc.h win32\config.h |
| 230 |
$(WORKDIR)\euc_kr.obj: $(encdir)\euc_kr.c regenc.h win32\config.h |
| 231 |
$(WORKDIR)\shift_jis.obj: $(encdir)\shift_jis.c regenc.h win32\config.h $(encdir)\jis\props.h |
| 232 |
$(WORKDIR)\windows_31j.obj: $(encdir)\windows_31j.c $(encdir)\shift_jis.c regenc.h win32\config.h $(encdir)\jis\props.h |
| 233 |
$(WORKDIR)\iso_8859_1.obj: $(encdir)\iso_8859_1.c regenc.h win32\config.h |
| 234 |
$(WORKDIR)\iso_8859_2.obj: $(encdir)\iso_8859_2.c regenc.h win32\config.h |
| 235 |
$(WORKDIR)\iso_8859_3.obj: $(encdir)\iso_8859_3.c regenc.h win32\config.h |
| 236 |
$(WORKDIR)\iso_8859_4.obj: $(encdir)\iso_8859_4.c regenc.h win32\config.h |
| 237 |
$(WORKDIR)\iso_8859_5.obj: $(encdir)\iso_8859_5.c regenc.h win32\config.h |
| 238 |
$(WORKDIR)\iso_8859_6.obj: $(encdir)\iso_8859_6.c regenc.h win32\config.h |
| 239 |
$(WORKDIR)\iso_8859_7.obj: $(encdir)\iso_8859_7.c regenc.h win32\config.h |
| 240 |
$(WORKDIR)\iso_8859_8.obj: $(encdir)\iso_8859_8.c regenc.h win32\config.h |
| 241 |
$(WORKDIR)\iso_8859_9.obj: $(encdir)\iso_8859_9.c regenc.h win32\config.h |
| 242 |
$(WORKDIR)\iso_8859_10.obj: $(encdir)\iso_8859_10.c regenc.h win32\config.h |
| 243 |
$(WORKDIR)\iso_8859_11.obj: $(encdir)\iso_8859_11.c regenc.h win32\config.h |
| 244 |
$(WORKDIR)\iso_8859_13.obj: $(encdir)\iso_8859_13.c regenc.h win32\config.h |
| 245 |
$(WORKDIR)\iso_8859_14.obj: $(encdir)\iso_8859_14.c regenc.h win32\config.h |
| 246 |
$(WORKDIR)\iso_8859_15.obj: $(encdir)\iso_8859_15.c regenc.h win32\config.h |
| 247 |
$(WORKDIR)\iso_8859_16.obj: $(encdir)\iso_8859_16.c regenc.h win32\config.h |
| 248 |
#$(WORKDIR)\koi8.obj: $(encdir)\koi8.c regenc.h win32\config.h |
| 249 |
$(WORKDIR)\koi8_r.obj: $(encdir)\koi8_r.c regenc.h win32\config.h |
| 250 |
$(WORKDIR)\koi8_u.obj: $(encdir)\koi8_u.c regenc.h win32\config.h |
| 251 |
$(WORKDIR)\windows_1250.obj: $(encdir)\windows_1250.c regenc.h win32\config.h |
| 252 |
$(WORKDIR)\windows_1251.obj: $(encdir)\windows_1251.c regenc.h win32\config.h |
| 253 |
$(WORKDIR)\windows_1252.obj: $(encdir)\windows_1252.c regenc.h win32\config.h |
| 254 |
$(WORKDIR)\windows_1253.obj: $(encdir)\windows_1253.c regenc.h win32\config.h |
| 255 |
$(WORKDIR)\windows_1254.obj: $(encdir)\windows_1254.c regenc.h win32\config.h |
| 256 |
$(WORKDIR)\windows_1257.obj: $(encdir)\windows_1257.c regenc.h win32\config.h |
| 257 |
$(WORKDIR)\big5.obj: $(encdir)\big5.c regenc.h win32\config.h |
| 258 |
$(WORKDIR)\gb18030.obj: $(encdir)\gb18030.c regenc.h win32\config.h |
| 259 |
|
| 260 |
$(WORKDIR)\onigmo.res: win32\onigmo.rc onigmo.h |
| 261 |
|
| 262 |
|
| 263 |
# Tests |
| 264 |
test: all ctest utest ptest pytest |
| 265 |
|
| 266 |
# C library test |
| 267 |
ctest: $(WORKDIR)\$(testc).exe |
| 268 |
$(WORKDIR)\$(testc) |
| 269 |
|
| 270 |
# C library test (Unicode) |
| 271 |
utest: $(WORKDIR)\$(testcu).exe |
| 272 |
$(WORKDIR)\$(testcu) |
| 273 |
|
| 274 |
# POSIX C library test |
| 275 |
ptest: $(WORKDIR)\$(testp).exe |
| 276 |
$(WORKDIR)\$(testp) |
| 277 |
|
| 278 |
# Python test |
| 279 |
pytest: |
| 280 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py EUC-JP |
| 281 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py SJIS |
| 282 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py UTF-8 |
| 283 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py UTF-16LE |
| 284 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py UTF-16BE |
| 285 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py UTF-32LE |
| 286 |
cd $(WORKDIR) && $(PYTHON) ..\testpy.py UTF-32BE |
| 287 |
|
| 288 |
|
| 289 |
$(WORKDIR)\$(testc).exe: win32\$(testc).c $(libname) |
| 290 |
$(CC) $(CFLAGS) -Fe$(WORKDIR)\$(testc) -DONIG_EXTERN=extern win32\$(testc).c -I. $(libname) |
| 291 |
|
| 292 |
$(WORKDIR)\$(testp).exe: win32\$(testc).c $(dlllib) |
| 293 |
$(CC) $(CFLAGS) -DPOSIX_TEST -Fe$(WORKDIR)\$(testp) win32\$(testc).c -I. $(dlllib) |
| 294 |
|
| 295 |
#$(testc)u.c: test.rb testconvu.rb |
| 296 |
# ruby -Ke testconvu.rb test.rb > $@ |
| 297 |
|
| 298 |
$(WORKDIR)\$(testcu).exe: $(testcu).c $(libname) |
| 299 |
$(CC) $(CFLAGS) -Fe$(WORKDIR)\$(testcu) -DONIG_EXTERN=extern $(testcu).c -I. $(libname) |
| 300 |
|
| 301 |
$(libbase).def: win32\makedef.py onigmo.h regenc.h onigmognu.h onigmoposix.h |
| 302 |
$(PYTHON) win32\makedef.py > $@ |
| 303 |
|
| 304 |
clean: |
| 305 |
-$(RMDIR) $(WORKDIR) |
| 306 |
|
| 307 |
|
| 308 |
samples: all |
| 309 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Fesimple ..\sample\simple.c ..\$(dlllib) |
| 310 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Feposix ..\sample\posix.c ..\$(dlllib) |
| 311 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Fenames ..\sample\names.c ..\$(dlllib) |
| 312 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Felistcap ..\sample\listcap.c ..\$(dlllib) |
| 313 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Fesql ..\sample\sql.c ..\$(dlllib) |
| 314 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Feencode ..\sample\encode.c ..\$(dlllib) |
| 315 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Fesyntax ..\sample\syntax.c ..\$(dlllib) |
| 316 |
cd $(WORKDIR) && $(CC) $(CFLAGS) -I.. -Fecrnl ..\sample\crnl.c ..\$(dlllib) |