Standardize makefile for guest-common

Changes done:

 - Create install target in makefile.
 - Move install instructions to makefile.
 - Cleanup in specfile

Story: 2004043
Task: 27558

Change-Id: I045eb3468a6b39dd508abe13b3ee33705539e96a
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
This commit is contained in:
Erich Cordoba 2019-02-08 18:37:51 -06:00
parent 2f1b243350
commit 8ba8d69234
2 changed files with 85 additions and 73 deletions

View File

@ -1,7 +1,6 @@
Summary: Titanium Cloud host guest messaging agents, lib, apps
Name: host-guest-comm
Version: 2.0
%define patchlevel %{tis_patch_ver}
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
@ -76,79 +75,24 @@ for software development.
VER=%{version}
MAJOR=`echo $VER | awk -F . '{print $1}'`
MINOR=`echo $VER | awk -F . '{print $2}'`
PATCH=%{patchlevel}
PATCH=%{tis_patch_ver}
make all VER=${VER} MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH}
find .
find . -name "*.tgz"
%global _buildsubdir %{_builddir}/%{name}-%{version}
%install
VER=%{version}
MAJOR=`echo $VER | awk -F . '{print $1}'`
MINOR=`echo $VER | awk -F . '{print $2}'`
PATCH=%{patchlevel}
PATCH=%{tis_patch_ver}
make install \
DESTDIR=%{buildroot} \
SYSCONFDIR=%{buildroot}%{_sysconfdir} \
UNITDIR=%{buildroot}%{_unitdir} \
LIBDIR=%{buildroot}%{_libdir} \
SDK_DEPLOY_DIR=%{buildroot}%{cgcs_sdk_deploy_dir} \
MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH}
install -m 750 -d %{buildroot}/usr/sbin
install -m 755 -d %{buildroot}/usr/lib64
install -m 755 -d %{buildroot}/usr/include
install -m 755 -d %{buildroot}/usr/include/cgcs
install -m 750 -d %{buildroot}%{_sysconfdir}/init.d
install -m 750 -d %{buildroot}%{_sysconfdir}/pmon.d
install -m 750 -d %{buildroot}%{_unitdir}
install -m 750 -d %{buildroot}/usr
install -m 750 -d %{buildroot}/usr/src
install -m 750 -d %{buildroot}/usr/src/debug
install -m 750 -d %{buildroot}/usr/src/debug/host-guest-comm-%{version}
install -m 644 %{_buildsubdir}/host_guest_msg_type.h %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_guest_msg_type.h
install -m 644 %{_buildsubdir}/server_group_app.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/server_group_app.c
install -m 644 %{_buildsubdir}/server_group.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/server_group.c
install -m 644 %{_buildsubdir}/guest_agent.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/guest_agent.c
install -m 644 %{_buildsubdir}/lib_host_guest_msg.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/lib_host_guest_msg.c
install -m 644 %{_buildsubdir}/host_guest_msg.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_guest_msg.c
install -m 644 %{_buildsubdir}/lib_guest_host_msg.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/lib_guest_host_msg.c
install -m 644 %{_buildsubdir}/host_instance_mgmt.h %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_instance_mgmt.h
install -m 644 %{_buildsubdir}/host_instance_mgmt.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_instance_mgmt.c
install -m 644 %{_buildsubdir}/guest_host_msg.h %{buildroot}/usr/src/debug/host-guest-comm-%{version}/guest_host_msg.h
install -m 644 %{_buildsubdir}/host_guest_msg.h %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_guest_msg.h
install -m 644 %{_buildsubdir}/host_agent.c %{buildroot}/usr/src/debug/host-guest-comm-%{version}/host_agent.c
install -m 644 %{_buildsubdir}/server_group.h %{buildroot}/usr/src/debug/host-guest-comm-%{version}/server_group.h
install -m 750 %{_buildsubdir}/scripts/host_agent %{buildroot}%{_sysconfdir}/init.d/host_agent
install -m 640 %{_buildsubdir}/scripts/host_agent.service %{buildroot}%{_unitdir}/host_agent.service
install -m 644 %{_buildsubdir}/scripts/guest-agent.service %{buildroot}%{_unitdir}/guest-agent.service
install -m 640 %{_buildsubdir}/scripts/host_agent.conf %{buildroot}%{_sysconfdir}/pmon.d/host_agent.conf
install -m 750 %{_buildsubdir}/bin/host_agent %{buildroot}/usr/sbin/host_agent
install -m 750 %{_buildsubdir}/bin/guest_agent %{buildroot}/usr/sbin/guest_agent
install -m 750 %{_buildsubdir}/bin/server_group_app %{buildroot}/usr/sbin/server_group_app
install -m 644 %{_buildsubdir}/guest_host_msg.h %{buildroot}/usr/include/cgcs/guest_host_msg.h
install -m 644 %{_buildsubdir}/host_guest_msg.h %{buildroot}/usr/include/cgcs/host_guest_msg.h
# Deploy to the SDK deployment directory
find .
install -d %{buildroot}%{cgcs_sdk_deploy_dir}
install -m 644 sdk/wrs-server-group-%{version}.%{patchlevel}.tgz %{buildroot}%{cgcs_sdk_deploy_dir}/wrs-server-group-%{version}.%{patchlevel}.tgz
install -m 755 -p -D %{_buildsubdir}/lib/libguesthostmsg.so.${MAJOR}.${MINOR}.${PATCH} %{buildroot}%{_libdir}/libguesthostmsg.so.${MAJOR}.${MINOR}.${PATCH}
cd %{buildroot}%{_libdir} ; ln -s libguesthostmsg.so.$MAJOR.$MINOR.${PATCH} libguesthostmsg.so.$MAJOR.${MINOR}
cd %{buildroot}%{_libdir} ; ln -s libguesthostmsg.so.$MAJOR.$MINOR.${PATCH} libguesthostmsg.so.$MAJOR
cd %{buildroot}%{_libdir} ; ln -s libguesthostmsg.so.$MAJOR.$MINOR.${PATCH} libguesthostmsg.so
install -m 755 -p -D %{_buildsubdir}/lib/libhostguestmsg.so.${MAJOR}.${MINOR}.${PATCH} %{buildroot}%{_libdir}/libhostguestmsg.so.${MAJOR}.${MINOR}.${PATCH}
cd %{buildroot}%{_libdir} ; ln -s libhostguestmsg.so.$MAJOR.$MINOR.${PATCH} libhostguestmsg.so.$MAJOR.${MINOR}
cd %{buildroot}%{_libdir} ; ln -s libhostguestmsg.so.$MAJOR.$MINOR.${PATCH} libhostguestmsg.so.$MAJOR
cd %{buildroot}%{_libdir} ; ln -s libhostguestmsg.so.$MAJOR.$MINOR.${PATCH} libhostguestmsg.so
install -m 755 -p -D %{_buildsubdir}/lib/libservergroup.so.${MAJOR}.${MINOR}.${PATCH} %{buildroot}%{_libdir}/libservergroup.so.${MAJOR}.${MINOR}.${PATCH}
cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libservergroup.so.$MAJOR.${MINOR}
cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libservergroup.so.$MAJOR
cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libservergroup.so
%post
/usr/bin/systemctl enable host_agent.service
@ -159,7 +103,7 @@ cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libse
%files
%defattr(-,root,root,-)
/usr/lib64/libhostguestmsg.so.2.0.%{patchlevel}
/usr/lib64/libhostguestmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libhostguestmsg.so.2.0
/usr/lib64/libhostguestmsg.so.2
/usr/sbin/host_agent
@ -170,10 +114,10 @@ cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libse
%files -n guest-host-comm
%defattr(-,root,root,-)
/usr/lib64/libguesthostmsg.so.2.0.%{patchlevel}
/usr/lib64/libguesthostmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libguesthostmsg.so.2.0
/usr/lib64/libguesthostmsg.so.2
/usr/lib64/libservergroup.so.2.0.%{patchlevel}
/usr/lib64/libservergroup.so.2.0.%{tis_patch_ver}
/usr/lib64/libservergroup.so.2.0
/usr/lib64/libservergroup.so.2
/usr/sbin/server_group_app
@ -191,11 +135,11 @@ cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libse
%defattr(-,root,root,-)
/usr/include/cgcs/guest_host_msg.h
/usr/lib64/libguesthostmsg.so.2.0.%{patchlevel}
/usr/lib64/libguesthostmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libguesthostmsg.so.2.0
/usr/lib64/libguesthostmsg.so.2
/usr/lib64/libguesthostmsg.so
/usr/lib64/libservergroup.so.2.0.%{patchlevel}
/usr/lib64/libservergroup.so.2.0.%{tis_patch_ver}
/usr/lib64/libservergroup.so.2.0
/usr/lib64/libservergroup.so.2
/usr/lib64/libservergroup.so
@ -221,10 +165,10 @@ cd %{buildroot}%{_libdir} ; ln -s libservergroup.so.$MAJOR.$MINOR.${PATCH} libse
%defattr(-,root,root,-)
/usr/include/cgcs/host_guest_msg.h
/usr/lib64/libhostguestmsg.so.2.0.%{patchlevel}
/usr/lib64/libhostguestmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libhostguestmsg.so.2.0
/usr/lib64/libhostguestmsg.so.2
/usr/lib64/libhostguestmsg.so
%files -n %{name}-cgts-sdk
%{cgcs_sdk_deploy_dir}/wrs-server-group-%{version}.%{patchlevel}.tgz
%{cgcs_sdk_deploy_dir}/wrs-server-group-%{version}.%{tis_patch_ver}.tgz

View File

@ -35,6 +35,16 @@
# Import the Makefile that we give to the customer so we eat our own dogfood
include Makefile.sdk
DESTDIR ?= /
SYSCONFDIR ?= /etc
UNITDIR ?= /usr/lib/systemd/system
LIBDIR ?= /usr/lib64
SDK_DEPLOY_DIR ?= /opt/deploy/cgcs_sdk
MAJOR ?= 2
MINOR ?= 0
VERSION ?= $(MAJOR).$(MINOR)
PATCH ?= 0
# This needs to be extended from what the customer will build.
EXECS += host_agent
BINEXECS=$(addprefix $(BINDIR)/, $(EXECS))
@ -54,7 +64,7 @@ LIBDEPS:=$(patsubst %,$(LIBDIR)/lib%.so,$(LIBS))
EXPORT_SDK := wrs-server-group-$(MAJOR).$(MINOR).$(PATCH)
# Add the host build as a dependency to the SDK build
all: host_all
all: host_all
host_all: $(BINEXECS) $(LIBDEPS) sdk/$(EXPORT_SDK).tgz
OBJS = $(HOST_AGENT_OBJ)
@ -101,6 +111,64 @@ $(LIBHOSTGUESTMSG_DEP): $(LIBHOSTGUESTMSG_OBJ)
$(BINDIR)/host_agent: $(HOST_AGENT_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) -lrt -ljson-c
install:
install -m 750 -d $(DESTDIR)/usr/sbin
install -m 755 -d $(DESTDIR)/usr/lib64
install -m 755 -d $(DESTDIR)/usr/include
install -m 755 -d $(DESTDIR)/usr/include/cgcs
install -m 750 -d $(SYSCONFDIR)/init.d
install -m 750 -d $(SYSCONFDIR)/pmon.d
install -m 750 -d $(UNITDIR)
install -m 750 -d $(DESTDIR)/usr
install -m 750 -d $(DESTDIR)/usr/src
install -m 750 -d $(DESTDIR)/usr/src/debug
install -m 750 -d $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)
install -m 644 host_guest_msg_type.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg_type.h
install -m 644 server_group_app.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group_app.c
install -m 644 server_group.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group.c
install -m 644 guest_agent.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/guest_agent.c
install -m 644 lib_host_guest_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/lib_host_guest_msg.c
install -m 644 host_guest_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg.c
install -m 644 lib_guest_host_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/lib_guest_host_msg.c
install -m 644 host_instance_mgmt.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_instance_mgmt.h
install -m 644 host_instance_mgmt.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_instance_mgmt.c
install -m 644 guest_host_msg.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/guest_host_msg.h
install -m 644 host_guest_msg.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg.h
install -m 644 host_agent.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_agent.c
install -m 644 server_group.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group.h
install -m 750 scripts/host_agent $(SYSCONFDIR)/init.d/host_agent
install -m 640 scripts/host_agent.service $(UNITDIR)/host_agent.service
install -m 644 scripts/guest-agent.service $(UNITDIR)/guest-agent.service
install -m 640 scripts/host_agent.conf $(SYSCONFDIR)/pmon.d/host_agent.conf
install -m 750 bin/host_agent $(DESTDIR)/usr/sbin/host_agent
install -m 750 bin/guest_agent $(DESTDIR)/usr/sbin/guest_agent
install -m 750 bin/server_group_app $(DESTDIR)/usr/sbin/server_group_app
install -m 644 guest_host_msg.h $(DESTDIR)/usr/include/cgcs/guest_host_msg.h
install -m 644 host_guest_msg.h $(DESTDIR)/usr/include/cgcs/host_guest_msg.h
# Deploy to the SDK deployment directory
install -d $(SDK_DEPLOY_DIR)
install -m 644 sdk/wrs-server-group-$(VERSION).$(PATCH).tgz $(SDK_DEPLOY_DIR)/wrs-server-group-$(VERSION).$(PATCH).tgz
install -m 755 -p -D lib/libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR).$(MINOR)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so
install -m 755 -p -D lib/libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR).$(MINOR)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so
install -m 755 -p -D lib/libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR).$(MINOR)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so
# Add the host clean as a dependency to the SDK stuff
clean: host_clean
host_clean: