Skip to content

Commit feb5214

Browse files
committed
Added install target.
1 parent b8116c3 commit feb5214

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,31 @@ PPFLAGS = -DSQLITE_ENABLE_COLUMN_METADATA=0
1515
LDFLAGS = -I$(PREFIX)/include -L$(PREFIX)/lib
1616
LDLIBS = -lsqlite3
1717
ARFLAGS = rcs
18-
TARGET = libfortran-sqlite3.a
19-
SRC = src/sqlite3_macro.c src/sqlite3.F90 src/sqlite3_util.f90
18+
INCDIR = $(PREFIX)/include/libfortran-sqlite3
19+
LIBDIR = $(PREFIX)/lib
2020
OBJ = sqlite3.o sqlite3_macro.o sqlite3_util.o
21+
TARGET = libfortran-sqlite3.a
2122

22-
.PHONY: all clean test
23+
.PHONY: all clean install test
2324

2425
all: $(TARGET)
2526

2627
test: test_sqlite3
2728

28-
$(TARGET): $(SRC)
29+
$(TARGET): src/sqlite3_macro.c src/sqlite3.F90 src/sqlite3_util.f90
2930
$(CC) $(CFLAGS) -c src/sqlite3_macro.c
3031
$(FC) $(FFLAGS) -c src/sqlite3_util.f90
3132
$(FC) $(FFLAGS) $(PPFLAGS) -c src/sqlite3.F90
3233
$(AR) $(ARFLAGS) $(TARGET) $(OBJ)
3334

35+
install: $(TARGET)
36+
@echo "--- Installing $(TARGET) to $(LIBDIR)/ ..."
37+
install -d $(LIBDIR)
38+
install -m 644 $(TARGET) $(LIBDIR)/
39+
@echo "--- Installing module files to $(INCDIR)/ ..."
40+
install -d $(INCDIR)
41+
install -m 644 *.mod $(INCDIR)/
42+
3443
test_sqlite3: $(TARGET) test/test_sqlite3.f90
3544
$(FC) $(FFLAGS) $(LDFLAGS) -o test_sqlite3 test/test_sqlite3.f90 $(TARGET) $(LDLIBS)
3645

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $ cd fortran-sqlite3/
2828
Either build the library with `fpm` or `make`. Once compiled, link your Fortran
2929
application against `libfortran-sqlite3.a` and `-lsqlite3`.
3030

31-
### fpm
31+
### Fortran Package Manager
3232

3333
Simply execute the Fortran Package Manager:
3434

@@ -54,7 +54,12 @@ $ make PPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1"
5454
```
5555

5656
You may want to override the default compilers by passing the arguments `CC` (C
57-
compiler) and `FC` (Fortran compiler).
57+
compiler) and `FC` (Fortran compiler). To install the library and the module
58+
files system-wide, for example, to `/opt`, run:
59+
60+
```
61+
$ make install PREFIX=/opt
62+
```
5863

5964
## Source-Code Documentation
6065

@@ -161,15 +166,16 @@ contains
161166
end program example
162167
```
163168

164-
Compile, link, and run the example with:
169+
If the library is installed to `/opt`, then compile, link, and run the example
170+
with:
165171

166172
```
167-
$ gfortran -o example example.f90 libfortran-sqlite3.a -lsqlite3
173+
$ gfortran -I/opt/include/libfortran-sqlite3 -o example example.f90 /opt/lib/libfortran-sqlite3.a -lsqlite3
168174
$ ./example
169175
1 one 12345
170176
```
171177

172-
## fpm
178+
## Fortran Package Manager
173179

174180
You can add *fortran-sqlite3* as an [fpm](https://github.com/fortran-lang/fpm)
175181
dependency to your `fpm.toml`:

src/sqlite3.F90

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
! Licence: ISC
77
module sqlite3
88
use, intrinsic :: iso_c_binding
9-
use, intrinsic :: iso_fortran_env, only: i8 => int64
109
use :: sqlite3_util
1110
implicit none (type, external)
1211
private
@@ -945,14 +944,14 @@ end function sqlite3_bind_parameter_index
945944
function sqlite3_bind_text(stmt, idx, val, destructor)
946945
!! Binds text to column. This wrapper passes destructor
947946
!! `SQLITE_TRANSIENT` by default!
948-
type(c_ptr), intent(inout) :: stmt
949-
integer, intent(in) :: idx
950-
character(len=*), intent(in) :: val
951-
integer(kind=i8), intent(in), optional :: destructor
952-
integer :: sqlite3_bind_text
947+
type(c_ptr), intent(inout) :: stmt
948+
integer, intent(in) :: idx
949+
character(len=*), intent(in) :: val
950+
integer(kind=c_size_t), intent(in), optional :: destructor
951+
integer :: sqlite3_bind_text
953952

954953
if (present(destructor)) then
955-
sqlite3_bind_text = sqlite3_bind_text_(stmt, idx, val, len(val), int(destructor, kind=c_size_t))
954+
sqlite3_bind_text = sqlite3_bind_text_(stmt, idx, val, len(val), destructor)
956955
return
957956
end if
958957

0 commit comments

Comments
 (0)