vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 1 | CXX ?= $(CROSS_COMPILE)g++ |
| 2 | |
Chris Austen | 2fb1173 | 2015-10-15 00:50:25 -0500 | [diff] [blame^] | 3 | TESTER = testit |
| 4 | |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 5 | DAEMON = ipmid |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 6 | DAEMON_OBJ = $(DAEMON).o |
| 7 | LIB_APP_OBJ = apphandler.o \ |
| 8 | sensorhandler.o \ |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 9 | storagehandler.o \ |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 10 | dcmihandler.o \ |
Chris Austen | 2fb1173 | 2015-10-15 00:50:25 -0500 | [diff] [blame^] | 11 | |
| 12 | |
| 13 | TESTER_OBJ = ipmisensor.o \ |
| 14 | testit.o |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 15 | |
| 16 | LIB_APP = libapphandler.so |
Patrick Williams | 224e2df | 2015-10-16 07:36:17 -0500 | [diff] [blame] | 17 | INSTALLED_LIBS += $(LIB_APP) |
| 18 | INSTALLED_HEADERS = ipmid-api.h |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 19 | |
Chris Austen | 0ba649e | 2015-10-13 12:28:13 -0500 | [diff] [blame] | 20 | INC_FLAG += $(shell pkg-config --cflags --libs libsystemd) -I. -O2 --std=gnu++11 |
| 21 | LIB_FLAG += $(shell pkg-config --libs libsystemd) -rdynamic |
Patrick Williams | 78966c2 | 2015-10-16 07:35:45 -0500 | [diff] [blame] | 22 | IPMID_PATH ?= -DHOST_IPMI_LIB_PATH=\"/usr/lib/host-ipmid/\" |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 23 | |
Patrick Williams | 224e2df | 2015-10-16 07:36:17 -0500 | [diff] [blame] | 24 | DESTDIR ?= / |
| 25 | SBINDIR ?= /usr/sbin |
| 26 | INCLUDEDIR ?= /usr/include |
| 27 | LIBDIR ?= /usr/lib |
| 28 | |
Chris Austen | 2fb1173 | 2015-10-15 00:50:25 -0500 | [diff] [blame^] | 29 | all: $(DAEMON) $(LIB_APP) $(TESTER) |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 30 | |
| 31 | %.o: %.C |
| 32 | $(CXX) -fpic -c $< $(CXXFLAGS) $(INC_FLAG) $(IPMID_PATH) -o $@ |
| 33 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 34 | $(LIB_APP): $(LIB_APP_OBJ) |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 35 | $(CXX) $^ -shared $(LDFLAGS) $(LIB_FLAG) -o $@ |
| 36 | |
| 37 | $(DAEMON): $(DAEMON_OBJ) |
| 38 | $(CXX) $^ $(LDFLAGS) $(LIB_FLAG) -o $@ -ldl |
| 39 | |
Chris Austen | 2fb1173 | 2015-10-15 00:50:25 -0500 | [diff] [blame^] | 40 | $(TESTER): $(TESTER_OBJ) |
| 41 | $(CXX) $^ $(LDFLAGS) $(LIB_FLAG) -o $@ -ldl |
| 42 | |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 43 | clean: |
Chris Austen | 2fb1173 | 2015-10-15 00:50:25 -0500 | [diff] [blame^] | 44 | rm -f $(DAEMON) $(TESTER) *.o *.so |
Patrick Williams | 224e2df | 2015-10-16 07:36:17 -0500 | [diff] [blame] | 45 | |
| 46 | install: |
| 47 | install -m 0755 -d $(DESTDIR)$(SBINDIR) |
| 48 | install -m 0755 ipmid $(DESTDIR)$(SBINDIR) |
| 49 | install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid |
| 50 | install -m 0755 $(INSTALLED_LIBS) $(DESTDIR)$(LIBDIR)/host-ipmid |
| 51 | install -m 0755 -d $(DESTDIR)$(INCLUDEDIR)/host-ipmid |
| 52 | install -m 0644 $(INSTALLED_HEADERS) $(DESTDIR)$(INCLUDEDIR)/host-ipmid |
| 53 | |