vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 1 | LIBS += libwritefrudata.so |
| 2 | HOST_LIBS += libstrgfnhandler.so |
| 3 | libwritefrudata.so_OBJS += frup.o writefrudata.o |
| 4 | libstrgfnhandler.so_OBJS += strgfnhandler.o |
| 5 | |
| 6 | EXES += phosphor-read-eeprom |
| 7 | |
| 8 | phosphor-read-eeprom_OBJS += readeeprom.o argument.o |
| 9 | phosphor-read-eeprom_EXTRA_LIBS += writefrudata |
| 10 | libstrgfnhandler.so_EXTRA_LIBS += writefrudata |
| 11 | libwritefrudata.so_NEEDED += libsystemd |
| 12 | phosphor-read-eeprom_NEEDED += libsystemd |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 13 | |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 14 | #### -----------------------------------------------------------------------#### |
| 15 | # # |
| 16 | ## Compilare Regulas Sequi ## |
| 17 | # # |
| 18 | #### -----------------------------------------------------------------------#### |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 19 | OPTFLAGS ?= -O3 -g -pipe -G -K |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 20 | CFLAGS ?= $(OPTFLAGS) |
| 21 | CXXFLAGS ?= $(OPTFLAGS) |
| 22 | CFLAGS += -Wall -flto -fPIC |
Chris Austen | b45c4cb | 2015-11-01 06:34:56 -0600 | [diff] [blame] | 23 | CXXFLAGS += --std=gnu++14 -Wall -flto -fPIC |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 24 | |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 25 | __PKG_CONFIG = $(if $1,$(shell pkg-config $2 $1)) |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 26 | __EXTRA_LIB_RESOLV = $(if $1,$1) |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 27 | |
| 28 | define __BUILD_EXE |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 29 | $1 : $$($1_OBJS) | $$(LIBS) $$(HOST_LIBS) |
| 30 | $$(LINK.cpp) -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs) |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 31 | |
| 32 | $(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags)) |
| 33 | |
| 34 | #include $$($1_OBJS:.o=.d) |
| 35 | endef |
| 36 | |
| 37 | $(foreach exe,$(EXES),$(eval $(call __BUILD_EXE,$(exe)))) |
| 38 | |
| 39 | define __BUILD_LIB |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 40 | $1 : $$($1_OBJS) | $$(addsuffix .so,$$(addprefix lib,$$($1_EXTRA_LIBS))) |
| 41 | $$(LINK.cpp) -fPIC -shared -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs) |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 42 | |
| 43 | $(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags)) |
| 44 | |
| 45 | #include $$($1_OBJS:.o=.d) |
| 46 | endef |
| 47 | |
| 48 | $(foreach lib,$(LIBS),$(eval $(call __BUILD_LIB,$(lib)))) |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 49 | $(foreach lib,$(HOST_LIBS),$(eval $(call __BUILD_LIB,$(lib)))) |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 50 | |
| 51 | .PHONY: clean |
| 52 | clean: |
| 53 | $(RM) $(foreach exe,$(EXES),$(exe) $($(exe)_OBJS)) \ |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 54 | $(foreach lib,$(LIBS),$(lib) $($(lib)_OBJS)) \ |
| 55 | $(foreach lib,$(HOST_LIBS),$(lib) $($(lib)_OBJS)) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 56 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 57 | DESTDIR ?= / |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 58 | BINDIR ?= /usr/bin |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 59 | LIBDIR ?= /usr/lib |
| 60 | |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 61 | .PHONY: install |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 62 | install: |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 63 | $(if $(EXES),\ |
| 64 | install -m 0755 -d $(DESTDIR)$(BINDIR) && \ |
| 65 | install -m 0755 $(EXES) $(DESTDIR)$(BINDIR) \ |
| 66 | ) |
| 67 | $(if $(LIBS),\ |
| 68 | install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid && \ |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame^] | 69 | install -m 0755 $(HOST_LIBS) $(DESTDIR)$(LIBDIR)/host-ipmid \ |
| 70 | install -m 0755 $(LIBS) $(DESTDIR)$(LIBDIR) \ |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame] | 71 | ) |
| 72 | |
| 73 | .DEFAULT_GOAL: all |
| 74 | .PHONY: all |
| 75 | all: $(EXES) $(LIBS) |