Skip to content

Commit e04220f

Browse files
committed
Build/Link: mention pkg-config and autotools
1 parent b60a6f7 commit e04220f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

docs/guides/build-and-link/index.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,26 @@ Then select "Add Other…":
115115
Browse to the location where the libgit2 binaries are located (if you're working from source, this is `/path/to/libgit2/build`), select the `libgit2.dylib` file, and click OK.
116116

117117

118-
## Makefiles
118+
## Makefiles, Autotools
119119

120-
The binaries that are output from the build are dependent on the build system you're using.
121-
On posix-type systems, the output is typically a `libgit2.so` (or `libgit2.a` if you built statically).
120+
The binaries that are output from the build are dependent on the build system you're using. On posix-type systems, the output is typically a `libgit2.so` (`.dylib` on MacOS, `libgit2.a` if you built statically).
122121

123-
Using these files is dependent on your application's project system.
124-
For a Makefile-based build, this is what you'll need:
122+
Using these files is dependent on your application's project system. If you installed the library to a standard system location, you can use `pkg-config` to get the right flags to pass to the compiler.
123+
124+
```
125+
LDFLAGS = $(shell pkg-config --libs libgit2)
126+
CFLAGS = $(shell pkg-config --cflags libgit2)
127+
```
128+
129+
In the same vein, using GNU Autotools, pkg-config can help you there
130+
131+
```
132+
PKG_CHECK_MODULES([libgit2], [libgit2])
133+
AC_SUBST([libgit2_LIBS])
134+
AC_SUBST([libgit2_FLAGS])
135+
```
136+
137+
If none of these options are available, then you can do it by hand with
125138

126139
```
127140
CFLAGS += -I/path/to/libgit2/include

0 commit comments

Comments
 (0)