forked from openbmc/ipmi-fru-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (64 loc) · 2.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
LIBS += libwritefrudata.so
HOST_LIBS += libstrgfnhandler.so
libwritefrudata.so_OBJS += frup.o writefrudata.o
libwritefrudata.so_VERSION = 1
libstrgfnhandler.so_OBJS += strgfnhandler.o
libstrgfnhandler.so_VERSION = 1
EXES += phosphor-read-eeprom
phosphor-read-eeprom_OBJS += readeeprom.o argument.o
phosphor-read-eeprom_EXTRA_LIBS += writefrudata
libstrgfnhandler.so_EXTRA_LIBS += writefrudata
libwritefrudata.so_NEEDED += libsystemd
phosphor-read-eeprom_NEEDED += libsystemd
#### -----------------------------------------------------------------------####
# #
## Compilare Regulas Sequi ##
# #
#### -----------------------------------------------------------------------####
OPTFLAGS ?= -O3 -g -pipe -G -K
CFLAGS ?= $(OPTFLAGS)
CXXFLAGS ?= $(OPTFLAGS)
CFLAGS += -Wall -flto -fPIC
CXXFLAGS += --std=gnu++14 -Wall -flto -fPIC
__PKG_CONFIG = $(if $1,$(shell pkg-config $2 $1))
__EXTRA_LIB_RESOLV = $(if $1,$1)
define __BUILD_EXE
$1 : $$($1_OBJS) | $$(LIBS) $$(HOST_LIBS)
$$(LINK.cpp) -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs)
$(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags))
#include $$($1_OBJS:.o=.d)
endef
$(foreach exe,$(EXES),$(eval $(call __BUILD_EXE,$(exe))))
define __BUILD_LIB
$1 : $$($1_OBJS) | $$(addsuffix .so,$$(addprefix lib,$$($1_EXTRA_LIBS)))
$$(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)
ln -sf $$(addsuffix .$($1_VERSION), $$@) $1
$(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags))
#include $$($1_OBJS:.o=.d)
endef
$(foreach lib,$(LIBS),$(eval $(call __BUILD_LIB,$(lib))))
$(foreach lib,$(HOST_LIBS),$(eval $(call __BUILD_LIB,$(lib))))
.PHONY: clean
clean:
$(RM) $(foreach exe,$(EXES),$(exe) $($(exe)_OBJS)) \
$(foreach lib,$(LIBS),$(addsuffix .$($(lib)_VERSION), $(lib)) $(lib) $($(lib)_OBJS)) \
$(foreach lib,$(HOST_LIBS),$(addsuffix .$($(lib)_VERSION), $(lib)) $(lib) $($(lib)_OBJS))
DESTDIR ?= /
BINDIR ?= /usr/bin
LIBDIR ?= /usr/lib
.PHONY: install
install:
$(if $(EXES),\
install -m 0755 -d $(DESTDIR)$(BINDIR) && \
install -m 0755 $(EXES) $(DESTDIR)$(BINDIR) \
)
$(if $(LIBS),\
install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid && \
install -m 0755 $(foreach lib,$(HOST_LIBS),$(addsuffix .$($(lib)_VERSION), $(lib))) $(DESTDIR)$(LIBDIR)/host-ipmid && \
install -m 0755 $(foreach lib,$(LIBS),$(addsuffix .$($(lib)_VERSION), $(lib))) $(DESTDIR)$(LIBDIR) \
$(foreach lib,$(HOST_LIBS), && ln -sf $(addsuffix .$($(lib)_VERSION), $(lib)) $(DESTDIR)$(LIBDIR)/host-ipmid/$(lib)) \
$(foreach lib,$(LIBS), && ln -sf $(addsuffix .$($(lib)_VERSION), $(lib)) $(DESTDIR)$(LIBDIR)/$(lib)) \
)
.DEFAULT_GOAL: all
.PHONY: all
all: $(EXES) $(LIBS)