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)) |
| 13 | ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS) |
| 14 | |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame^] | 15 | all: $(SONAME) $(BIN) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 16 | |
| 17 | %.o: %.c |
| 18 | $(CC) -c $(ALL_CFLAGS) -o $@ $< |
| 19 | |
| 20 | $(SONAME): $(LIBMAPPER) |
| 21 | ln -sf $^ $@ |
| 22 | |
| 23 | $(LIBMAPPER): lib%.so.$(VERSION): %.o |
| 24 | $(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(SONAME) \ |
| 25 | -o $@ $^ $(LDLIBS) |
| 26 | |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame^] | 27 | $(BIN): app.o $(LIBMAPPER) |
| 28 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) |
| 29 | |
| 30 | install: $(SONAME) $(LIBMAPPER) $(BIN) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 31 | @mkdir -p $(DESTDIR)$(includedir) |
| 32 | install $(INCLUDES) $(DESTDIR)$(includedir) |
| 33 | @mkdir -p $(DESTDIR)$(libdir) |
| 34 | install $(LIBMAPPER) $(DESTDIR)$(libdir) |
| 35 | ln -sf $(LIBMAPPER) $(DESTDIR)$(libdir)/$(SONAME) |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame^] | 36 | @mkdir -p $(DESTDIR)$(sbindir) |
| 37 | install $(BIN) $(DESTDIR)$(sbindir) |
Brad Bishop | 62ece2b | 2016-07-25 09:00:51 -0400 | [diff] [blame] | 38 | |
| 39 | clean: |
Brad Bishop | 2afe718 | 2016-08-13 14:08:17 -0400 | [diff] [blame^] | 40 | rm -f *.o $(LIBMAPPER) $(SONAME) $(BIN) |