ifeq ($(OS),Windows_NT)
#Windows

opts=-shared lua53.dll -I C:\kandy\doc\coding\lua\lua53\lua-5.3.0-64\src -Wall

all: lua_getkey.dll lua_lscd.dll lua_getch.dll lua_sqlite3.dll lua_tcl.dll putenv.dll attributes.dll binstd.dll lua_console_codes.dll setenv.dll

clean:
	rm lua_getkey.dll lua_lscd.dll lua_getch.dll lua_sqlite3.dll lua_tcl.dll putenv.dll attributes.dll binstd.dll lua_console_codes.dll setenv.dll

lua_getkey.dll: lua_getkey.c
	gcc -o lua_getkey.dll $(opts) lua_getkey.c

lua_lscd.dll: lscd.c
	gcc -o lua_lscd.dll $(opts) lscd.c -DWINDOWS -D_FILE_OFFSET_BITS=64

lua_getch.dll: lua_getch.c
	gcc -o lua_getch.dll $(opts) lua_getch.c

lua_sqlite3.dll: lua_sqlite3.c
	gcc -o lua_sqlite3.dll $(opts) lua_sqlite3.c C:\msys64\mingw64\lib\libsqlite3.a

lua_tcl.dll: lua_tcl.c
	gcc -o lua_tcl.dll \
	-L/usr/local/lib \
	-I/usr/local/include \
	$(opts) \
	lua_tcl.c \
	-ltcl86

putenv.dll: putenv.c
	gcc -o putenv.dll $(opts) putenv.c

attributes.dll: attributes.c
	gcc -o attributes.dll $(opts) attributes.c

binstd.dll: binstd.c
	gcc -o binstd.dll $(opts) binstd.c -D_FILE_OFFSET_BITS=64

lua_console_codes.dll: lua_setup_ansi_codes.c
	gcc -o lua_console_codes.dll $(opts) lua_setup_ansi_codes.c

setenv.dll: setenv.c
	gcc -o setenv.dll $(opts) setenv.c


else

#Linux
opts=-shared -fPIC -I/usr/include/lua5.3 -llua5.3

all: lua_getkey.so lua_lscd.so lua_getch.so lua_sql.so lua_tcl.so putenv.so

most: lua_getkey.so lua_lscd.so lua_getch.so lua_sql.so putenv.so

clean:
	rm *.so

lua_getkey.so: lua_getkey_linux.c
	gcc -o lua_getkey.so lua_getkey_linux.c $(opts)

lua_lscd.so: lscd.c
	gcc -o lua_lscd.so lscd.c $(opts)

lua_getch.so: lua_getch_linux.c
	gcc -o lua_getch.so lua_getch_linux.c $(opts)

lua_sql.so: lua_sqlite3.c
	gcc -o lua_sql.so lua_sqlite3.c -lsqlite3 $(opts)

lua_tcl.so: lua_tcl.c
	gcc lua_tcl.c \
	-o lua_tcl.so \
	-I /usr/include/tcl8.6 \
	-l tcl8.6 \
	$(opts)

putenv.so: putenv.c
	gcc -o putenv.so putenv.c $(opts)

endif
