Skip to content

Commit 6063d5a

Browse files
authored
Merge pull request #8 from Spinojara/master
Add top level Makefile for compiling a shared object
2 parents 9cda72d + de5cbdd commit 6063d5a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
MKDIR_P = mkdir -p
2+
RM = rm
3+
INSTALL = install
4+
5+
CC ?= gcc
6+
CFLAGS = -std=gnu99 -O2 -Wall -Wshadow -Isrc
7+
LDFLAGS = $(CFLAGS)
8+
9+
PREFIX = /usr/local
10+
LIBDIR = $(PREFIX)/lib64
11+
INCDIR = $(PREFIX)/include
12+
13+
libfathom.so: obj/tbprobe.o
14+
$(CC) $(LDFLAGS) -shared $^ -o $@
15+
16+
obj/tbprobe.o: src/tbprobe.c src/tbchess.c src/stdendian.h src/tbprobe.h
17+
@$(MKDIR_P) obj
18+
$(CC) $(CFLAGS) -fPIC -c $< -o $@
19+
20+
clean:
21+
$(RM) -f libfathom.so
22+
$(RM) -rf obj
23+
24+
install: libfathom.so
25+
$(MKDIR_P) $(DESTDIR)$(LIBDIR)
26+
$(INSTALL) -m 0644 libfathom.so $(DESTDIR)$(LIBDIR)
27+
$(INSTALL) -m 0644 src/{stdendian,tbconfig,tbprobe}.h $(DESTDIR)$(INCDIR)
28+
29+
uninstall:
30+
$(RM) -f $(DESTDIR)$(LIBDIR)/libfathom.so
31+
$(RM) -f $(DESTDIR)$(INCDIR)/{stdendian,tbconfig,tbprobe}.h
32+
33+
.PHONY: clean install uninstall

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ are:
1212
Fathom is compilable under either C99 or C++ and supports a variety of
1313
platforms, including at least Windows, Linux, and MacOS.
1414

15+
Building the library
16+
--------------------
17+
It is possible to build and install Fathom as a shared library on Unix-like
18+
systems. Simply run the commands
19+
20+
make
21+
make install
22+
23+
in the top level directory.
24+
1525
Tool
1626
----
1727

0 commit comments

Comments
 (0)