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