# Makefile for Lua BitOp -- a bit operations library for Lua 5.1 - 5.5.
# This is a modified Makefile for MinGW. C:\MinGW\bin must be in your PATH.
# Compile: mingw32-make -f Makefile.mingw
# Install: mingw32-make -f Makefile.mingw install

# Lua executable name. Used for testing.
LUA= lua

# Include path where lua.h, luaconf.h and lauxlib.h reside:
INCLUDES= "-I.."

# Path of lua51.dll:
LUADLLPATH= "..\lua51.dll"

# Path where C modules for Lua should be installed:
LUACMODPATH= ".."

CC= gcc
CCOPT= -O2 -fomit-frame-pointer
CCWARN = -Wall
SOCC= $(CC) -shared
SOCFLAGS= $(CCOPT) $(CCWARN) $(INCLUDES) $(CFLAGS)
SOLDFLAGS= $(LDFLAGS)
RM= del
STRIP= strip --strip-unneeded
INSTALL= copy

MODNAME= bit
MODSO= $(MODNAME).dll

all: $(MODSO)

$(MODNAME).o: $(MODNAME).c
	$(CC) $(SOCFLAGS) -c -o $@ $<

$(MODSO): $(MODNAME).o
	$(SOCC) $(SOLDFLAGS) -o $@ $< $(LUADLLPATH)
	$(STRIP) $@

install: $(MODSO)
	$(INSTALL) $< $(LUACMODPATH)

test: $(MODSO)
	@$(LUA) bittest.lua && echo "basic test OK"
	@$(LUA) nsievebits.lua && echo "nsievebits test OK"
	@$(LUA) md5test.lua && echo "MD5 test OK"

clean:
	$(RM) *.o *.so *.obj *.lib *.exp *.dll *.manifest

.PHONY: all install test clean

