Skip to content

Commit 59aa12d

Browse files
committed
Added install target.
1 parent 139a1dd commit 59aa12d

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@ FFLAGS = $(RELEASE)
1111
LDFLAGS = -I$(PREFIX)/include -L$(PREFIX)/lib
1212
LDLIBS = -lpcre2-8
1313
ARFLAGS = rcs
14+
INCDIR = $(PREFIX)/include/libfortran-pcre2
15+
LIBDIR = $(PREFIX)/lib
16+
MODULE = pcre2.mod
1417
TARGET = libfortran-pcre2.a
1518
TEST = test_pcre2
1619

17-
.PHONY: all clean test
20+
.PHONY: all clean install test
1821

1922
all: $(TARGET)
2023

2124
$(TARGET): src/pcre2.f90
2225
$(FC) $(FFLAGS) -c src/pcre2.f90
2326
$(AR) $(ARFLAGS) $(TARGET) pcre2.o
2427

28+
install: $(TARGET)
29+
@echo "--- Installing $(TARGET) to $(LIBDIR)/ ..."
30+
install -d $(LIBDIR)
31+
install -m 644 $(TARGET) $(LIBDIR)/
32+
@echo "--- Installing module files to $(INCDIR)/ ..."
33+
install -d $(INCDIR)
34+
install -m 644 $(MODULE) $(INCDIR)/
35+
2536
test:
2637
$(FC) $(FFLAGS) $(LDFLAGS) -o $(TEST) test/test_pcre2.f90 $(TARGET) $(LDLIBS)
2738

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# fortran-pcre2
2+
23
A work-in-progress collection of Fortran 2018 ISO_C_BINDING interfaces to
34
Perl-compatible Regular Expressions 2
45
([PCRE2](https://www.pcre.org/current/doc/html/)). The library is also available
56
on [MacPorts](https://ports.macports.org/port/fortran-pcre2/).
67

78
## Build Instructions
9+
810
You will need *libpcre2* with development headers. On FreeBSD, run:
911

1012
```
@@ -26,16 +28,23 @@ $ cd fortran-pcre2/
2628
$ make
2729
```
2830

31+
Install the library and the modules files system-wide to `/opt`:
32+
33+
```
34+
$ make install PREFIX=/opt
35+
```
36+
2937
Instead of `make`, you may want to build the library using the Fortran Package
3038
Manager:
3139

3240
```
33-
$ fpm build --profile=release
41+
$ fpm build --profile release
3442
```
3543

3644
Link your Fortran programs against `libfortran-pcre2.a` and `-lpcre2-8`.
3745

3846
## Example
47+
3948
The following program just compiles and executes a basic regular expression.
4049

4150
```fortran
@@ -99,15 +108,17 @@ program main
99108
end program main
100109
```
101110

102-
Compile, link, and run the program with, for example:
111+
If the library is installed to `/opt`, then compile, link, and run the program
112+
with:
103113

104114
```
105-
$ gfortran -o example example.f90 libfortran-pcre2.a -lpcre2-8
115+
$ gfortran -I/opt/include/libfortran-pcre2 -o example example.f90 /opt/lib/libfortran-pcre2.a -lpcre2-8
106116
$ ./example
107117
```
108118

109-
## fpm
110-
You can add *fortran-pcre2* as an [fpm](https://github.com/fortran-lang/fpm)
119+
## Fortran Package Manager
120+
121+
You can add *fortran-pcre2* as an [FPM](https://github.com/fortran-lang/fpm)
111122
dependency:
112123

113124
```toml
@@ -116,6 +127,7 @@ fortran-pcre2 = { git = "https://github.com/interkosmos/fortran-pcre2.git" }
116127
```
117128

118129
## Compatibility
130+
119131
It is not necessary to null-terminate character strings given to the procedures
120132
of *fortran-pcre2*. In contrast to the C API of PCRE2, you must not free
121133
substrings with `pcre2_substring_free()`, as this will be done by the wrapper
@@ -142,4 +154,5 @@ functions.
142154
| `pcre2_substring_number_from_name_8` | `pcre2_substring_number_from_name` |
143155

144156
## Licence
157+
145158
ISC

0 commit comments

Comments
 (0)