xref: /openbmc/skeleton/libopenbmc_intf/Makefile (revision ea3d8a41)
1libdir=/usr/lib
2includedir=/usr/include
3
4PACKAGE_DEPS=gio-unix-2.0 glib-2.0
5SONAME=libopenbmc_intf.so
6VERSION=1
7LIBOBMC=$(SONAME).$(VERSION)
8INCLUDES=openbmc_intf.h openbmc.h gpio.h gpio_configs.h
9
10LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS)) -lcjson
11ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
12
13all: $(SONAME)
14
15%.o: %.c
16	$(CC) -c $(ALL_CFLAGS) -o $@ $<
17
18$(SONAME): $(LIBOBMC)
19	ln -sf $^ $@
20
21$(LIBOBMC): lib%.so.$(VERSION): %.o gpio.o gpio_configs.o gpio_json.o
22	$(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(SONAME) \
23		-o $@ $^ $(LDLIBS)
24
25install: $(SONAME) $(LIBOBMC)
26	@mkdir -p $(DESTDIR)$(includedir)
27	install $(INCLUDES) $(DESTDIR)$(includedir)
28	@mkdir -p $(DESTDIR)$(libdir)
29	install $(LIBOBMC) $(DESTDIR)$(libdir)
30	ln -sf $(LIBOBMC) $(DESTDIR)$(libdir)/$(SONAME)
31
32clean:
33	rm -f *.o $(LIBOBMC) $(SONAME)
34