Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame^] | 1 | LIBS += libwritefrudata.so |
| 2 | libwritefrudata.so_OBJS += frup.o writefrudata.o |
| 3 | libwritefrudata.so_NEEDED += libsystemd |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 4 | |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame^] | 5 | #### -----------------------------------------------------------------------#### |
| 6 | # # |
| 7 | ## Compilare Regulas Sequi ## |
| 8 | # # |
| 9 | #### -----------------------------------------------------------------------#### |
| 10 | OPTFLAGS ?= -O3 -g -pipe |
| 11 | CFLAGS ?= $(OPTFLAGS) |
| 12 | CXXFLAGS ?= $(OPTFLAGS) |
| 13 | CFLAGS += -Wall -flto -fPIC |
| 14 | CXXFLAGS += --std=gnu++14 -Wall -flto -fPIC -I. |
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 | __PKG_CONFIG = $(if $1,$(shell pkg-config $2 $1)) |
| 17 | |
| 18 | define __BUILD_EXE |
| 19 | $1 : $$($1_OBJS) $$(LIBS) |
| 20 | $$(LINK.cpp) -o $$@ $$^ $(call __PKG_CONFIG,$($1_NEEDED),--libs) |
| 21 | |
| 22 | $(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags)) |
| 23 | |
| 24 | #include $$($1_OBJS:.o=.d) |
| 25 | endef |
| 26 | |
| 27 | $(foreach exe,$(EXES),$(eval $(call __BUILD_EXE,$(exe)))) |
| 28 | |
| 29 | define __BUILD_LIB |
| 30 | $1 : $$($1_OBJS) |
| 31 | $$(LINK.cpp) -shared -o $$@ $$^ $(call __PKG_CONFIG,$($1_NEEDED),--libs) |
| 32 | |
| 33 | $(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags)) |
| 34 | |
| 35 | #include $$($1_OBJS:.o=.d) |
| 36 | endef |
| 37 | |
| 38 | $(foreach lib,$(LIBS),$(eval $(call __BUILD_LIB,$(lib)))) |
| 39 | |
| 40 | .PHONY: clean |
| 41 | clean: |
| 42 | $(RM) $(foreach exe,$(EXES),$(exe) $($(exe)_OBJS)) \ |
| 43 | $(foreach lib,$(LIBS),$(lib) $($(lib)_OBJS)) |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 44 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 45 | DESTDIR ?= / |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame^] | 46 | BINDIR ?= /usr/bin |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 47 | LIBDIR ?= /usr/lib |
| 48 | |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame^] | 49 | .PHONY: install |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 50 | install: |
Patrick Williams | 7bb1b15 | 2015-10-31 23:27:17 -0500 | [diff] [blame^] | 51 | $(if $(EXES),\ |
| 52 | install -m 0755 -d $(DESTDIR)$(BINDIR) && \ |
| 53 | install -m 0755 $(EXES) $(DESTDIR)$(BINDIR) \ |
| 54 | ) |
| 55 | $(if $(LIBS),\ |
| 56 | install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid && \ |
| 57 | install -m 0755 $(LIBS) $(DESTDIR)$(LIBDIR)/host-ipmid \ |
| 58 | ) |
| 59 | |
| 60 | .DEFAULT_GOAL: all |
| 61 | .PHONY: all |
| 62 | all: $(EXES) $(LIBS) |