Skip to content

Commit

Permalink
Added pkg-config to Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Jul 26, 2022
1 parent d38e01e commit e379593
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

FC = gfortran
AR = ar
FFLAGS = -Wall
FFLAGS = -Wall `pkg-config --cflags lua-5.3`
ARFLAGS = rcs
LDFLAGS = -I/usr/local/include/lua53/ -L/usr/local/lib/lua/5.3/
LDLIBS = -llua-5.3
LDFLAGS = `pkg-config --libs-only-L lua-5.3`
LDLIBS = `pkg-config --libs-only-l lua-5.3`
TARGET = libfortran-lua53.a

FIBONACCI = examples/fibonacci/fibonacci
LIBRARY = examples/library/fortran.so
STRING = examples/string/string
TABLE = examples/table/table

.PHONY: all clean
.PHONY: all clean examples

all: $(TARGET) $(FIBONACCI) $(LIBRARY) $(STRING) $(TABLE)
all: $(TARGET)

examples: $(FIBONACCI) $(LIBRARY) $(STRING) $(TABLE)

$(TARGET):
$(FC) $(FFLAGS) -fPIC -c src/lua.f90
Expand Down
4 changes: 3 additions & 1 deletion examples/table/table.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ program main
call lual_openlibs(l) ! Open Lua standard library.
rc = lual_dofile(l, 'table.lua') ! Open Lua file.
rc = lua_pcall(l, 0, 0, 0) ! Run the script once.
rc = lua_getglobal(l, 'a') ! Get the table.

! Get the table.
rc = lua_getglobal(l, 'a')

if (lua_istable(l, -1) == 1) then
! Get table field.
Expand Down
10 changes: 5 additions & 5 deletions src/lua.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ module lua
implicit none
private

integer, parameter, public :: lua_integer = c_int
integer, parameter, public :: lua_number = c_double

public :: lua_arith
public :: lua_call
public :: lua_callk
Expand Down Expand Up @@ -83,6 +80,9 @@ module lua
private :: c_f_str_ptr
private :: copy

integer, parameter, public :: lua_integer = c_int
integer, parameter, public :: lua_number = c_double

! Option for multiple returns in `lua_pcall()` and `lua_call()`.
integer(kind=c_int), parameter, public :: LUA_MULTRET = -1

Expand Down Expand Up @@ -793,7 +793,7 @@ end function lua_tonumber
! const char *lua_tostring(lua_State *L, int index)
function lua_tostring(l, i)
!! Wrapper that calls `lua_tolstring()` and converts the returned C
!! pointer to Fortran string.
!! pointer to Fortran string. Returns an unallocated character on error.
type(c_ptr), intent(in) :: l
integer, intent(in) :: i
character(len=:), allocatable :: lua_tostring
Expand All @@ -807,7 +807,7 @@ end function lua_tostring
! const char *lua_typename(lua_State *L, int tp)
function lua_typename(l, tp)
!! Wrapper that calls `lua_typename_()` and converts the returned C
!! pointer to Fortran string.
!! pointer to Fortran string. Returns an unallocated character on error.
type(c_ptr), intent(in) :: l
integer, intent(in) :: tp
character(len=:), allocatable :: lua_typename
Expand Down

0 comments on commit e379593

Please sign in to comment.