Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 1 | libdir=/usr/lib |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 2 | sbindir=/usr/sbin |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 3 | includedir=/usr/include |
| 4 | |
| 5 | PACKAGE_DEPS=libsystemd |
| 6 | SONAME=libmapper.so |
| 7 | VERSION=1 |
| 8 | LIBMAPPER=$(SONAME).$(VERSION) |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 9 | BIN=mapper |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 10 | INCLUDES=mapper.h |
| 11 | |
| 12 | LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS)) |
Matthew Barth | f2b894e | 2016-08-18 14:45:34 -0500 | [diff] [blame] | 13 | ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) \ |
| 14 | -fPIC -Wall -Werror $(CFLAGS) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 15 | |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 16 | all: $(SONAME) $(BIN) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 17 | |
| 18 | %.o: %.c |
| 19 | $(CC) -c $(ALL_CFLAGS) -o $@ $< |
| 20 | |
| 21 | $(SONAME): $(LIBMAPPER) |
| 22 | ln -sf $^ $@ |
| 23 | |
| 24 | $(LIBMAPPER): lib%.so.$(VERSION): %.o |
| 25 | $(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(SONAME) \ |
| 26 | -o $@ $^ $(LDLIBS) |
| 27 | |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 28 | $(BIN): app.o $(LIBMAPPER) |
| 29 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) |
| 30 | |
| 31 | install: $(SONAME) $(LIBMAPPER) $(BIN) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 32 | @mkdir -p $(DESTDIR)$(includedir) |
| 33 | install $(INCLUDES) $(DESTDIR)$(includedir) |
| 34 | @mkdir -p $(DESTDIR)$(libdir) |
| 35 | install $(LIBMAPPER) $(DESTDIR)$(libdir) |
| 36 | ln -sf $(LIBMAPPER) $(DESTDIR)$(libdir)/$(SONAME) |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 37 | @mkdir -p $(DESTDIR)$(sbindir) |
| 38 | install $(BIN) $(DESTDIR)$(sbindir) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 39 | |
| 40 | clean: |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame] | 41 | rm -f *.o $(LIBMAPPER) $(SONAME) $(BIN) |