-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uHAL : Move all packages (except for log) to common makefile setup; r…
…efs #47
- Loading branch information
1 parent
ee9db69
commit a94e73b
Showing
45 changed files
with
532 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# | ||
# Written by XDAQ Team (xdaq.cern.ch) | ||
# | ||
# install.sh <source> <destination> <permission> RPM_BUILD_ROOT PACKAGEDIR PACKAGENAME VERSION INCLUDEPREFIX INCLUDEDIRS | ||
# | ||
SRC=$1 | ||
DST=$2 | ||
PERM=$3 | ||
RPM_BUILD_ROOT=$4 | ||
PKGDIR=$5 | ||
NAME=$6 | ||
VERSION=$7 | ||
INCLUDEPREFIX=$8 | ||
INCLUDEDIRS=$9 | ||
|
||
# Symbolic link | ||
if [ -h "$SRC" ]; then | ||
DSTPARENT=`echo $DST | sed -r 's/^(.*\/).*$/\1/'` | ||
#mkdir -p ${DSTPARENT} | ||
cp -d $SRC $RPM_BUILD_ROOT/$DST | ||
else | ||
# Regular file | ||
if [ -f "$SRC" ]; then | ||
install -D -m $PERM $SRC $RPM_BUILD_ROOT/$DST | ||
|
||
MIME=`file -ib $SRC` | ||
REGEX="application/(x-executable|x-sharedlib).*" | ||
if [[ "$MIME" =~ $REGEX ]]; then | ||
# set -x | ||
# If there is already a debug file copy it instead of creating a new one | ||
if [ -e "$SRC.debug" ]; then | ||
install -D -m $PERM $SRC.debug $RPM_BUILD_ROOT/usr/lib/debug$DST.debug | ||
else | ||
install -D -m $PERM $SRC $RPM_BUILD_ROOT/usr/lib/debug$DST.debug | ||
objcopy --only-keep-debug $RPM_BUILD_ROOT/usr/lib/debug${DST}.debug | ||
fi | ||
# strip normal binary | ||
objcopy -g $RPM_BUILD_ROOT/${DST} | ||
|
||
# rewrite source directories | ||
/usr/lib/rpm/debugedit -b ${PKGDIR} -d /usr/src/debug/${NAME}-${VERSION} -l ${PKGDIR}/rpm/debug.source $RPM_BUILD_ROOT/usr/lib/debug$DST.debug | ||
|
||
# relocate all include files to /opt/xdaq/include | ||
for prefix in $INCLUDEDIRS; do | ||
/usr/lib/rpm/debugedit -b $prefix -d ${INCLUDEPREFIX} $RPM_BUILD_ROOT/usr/lib/debug$DST.debug | ||
done | ||
|
||
objcopy --remove-section .gnu_debuglink --add-gnu-debuglink=$RPM_BUILD_ROOT/usr/lib/debug${DST}.debug $RPM_BUILD_ROOT/${DST} | ||
# set +x | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Sanitize BUILD_HOME | ||
BUILD_HOME := $(shell cd $(BUILD_HOME); pwd) | ||
|
||
$(info Using BUILD_HOME=${BUILD_HOME}) | ||
|
||
# Compilers | ||
CPP = g++ | ||
LD = g++ | ||
|
||
# Compiler flags | ||
CXXFLAGS = -g -Wall -pedantic -O3 -MMD -MP -fPIC | ||
# -fprofile-arcs -ftest-coverages | ||
LDFLAGS = -Wall -g -O3 -fPIC | ||
# -lgcov -coverage | ||
|
||
# Tools | ||
MakeDir = mkdir -p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
RPMBUILD_DIR=${PackagePath}/rpm/RPMBUILD | ||
# | ||
ifndef PythonModules | ||
$(error Python module names missing "PythonModules") | ||
endif | ||
PackageScripts ?= [] | ||
|
||
|
||
.PHONY: rpm _rpmall | ||
rpm: _rpmall | ||
_rpmall: _all _setup_update _rpmbuild | ||
|
||
# Copy the package skeleton | ||
# Insure the existence of the module directory | ||
# Copy the libraries into python module | ||
.PHONY: _rpmbuild | ||
_rpmbuild: _setup_update | ||
# Change directory into pkg and copy everything into rpm/pkg | ||
cd pkg && \ | ||
find . -name "*" -exec install -D \{\} ${RPMBUILD_DIR}/\{\} \; | ||
# Add a manifest file | ||
echo "include */*.so" > ${RPMBUILD_DIR}/MANIFEST.in | ||
# Change into rpm/pkg to finally run the customized setup.py | ||
if [ -f setup.cfg ]; then cp setup.cfg ${RPMBUILD_DIR}/ ; fi | ||
cd ${RPMBUILD_DIR} && CACTUS_ROOT=${CACTUS_ROOT} python ${PackageName}.py bdist_rpm \ | ||
--release ${PACKAGE_RELEASE}.${CACTUS_OS}.python${PYTHON_VERSION} \ | ||
--binary-only --force-arch=`uname -m` | ||
# Harvest the crop | ||
find rpm -name "*.rpm" -exec cp -a \{\} rpm/ \; | ||
|
||
|
||
.PHONY: _setup_update | ||
_setup_update: | ||
${MakeDir} ${RPMBUILD_DIR} | ||
cp ${BUILD_HOME}/uhal/config/setupTemplate.py ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__python_packages__#${PythonModules}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__packagename__#${PackageName}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__version__#$(PACKAGE_VER_MAJOR).$(PACKAGE_VER_MINOR).$(PACKAGE_VER_PATCH)#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__author__#${Packager}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__description__#${PackageDescription-None}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__url__#${PackageURL-None}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
sed -i 's#__scripts__#${PackageScripts}#' ${RPMBUILD_DIR}/${PackageName}.py | ||
|
||
|
||
.PHONY: cleanrpm _cleanrpm | ||
cleanrpm: _cleanrpm | ||
_cleanrpm: | ||
-rm -r rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
RPMBUILD_DIR=${PackagePath}/rpm/RPMBUILD | ||
|
||
|
||
BuildDebuginfoRPM ?= 1 | ||
IncludePaths := $(if ${IncludePaths}, ${IncludePaths}, %{nil}) | ||
BUILD_REQUIRES_TAG = $(if ${PackageBuildRequires} ,BuildRequires: ${PackageBuildRequires} ,\# No BuildRequires tag ) | ||
REQUIRES_TAG = $(if ${PackageRequires} ,Requires: ${PackageRequires} ,\# No Requires tag ) | ||
|
||
export BUILD_HOME | ||
|
||
.PHONY: rpm _rpmall | ||
rpm: _rpmall | ||
_rpmall: _all _spec_update _rpmbuild | ||
|
||
.PHONY: _rpmbuild | ||
_rpmbuild: _spec_update | ||
mkdir -p ${RPMBUILD_DIR}/{RPMS/{i386,i586,i686,x86_64},SPECS,BUILD,SOURCES,SRPMS} | ||
rpmbuild --quiet -bb -bl --buildroot=${RPMBUILD_DIR}/BUILD --define "_topdir ${RPMBUILD_DIR}" rpm/${PackageName}.spec | ||
find ${RPMBUILD_DIR} -name "*.rpm" -exec mv {} $(PackagePath)/rpm \; | ||
|
||
.PHONY: _spec_update | ||
_spec_update: | ||
mkdir -p ${PackagePath}/rpm | ||
cp ${BUILD_HOME}/uhal/config/specTemplate.spec ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__package__#${Package}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__packagename__#${PackageName}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__version__#$(PACKAGE_VER_MAJOR).$(PACKAGE_VER_MINOR).$(PACKAGE_VER_PATCH)#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__release__#${PACKAGE_RELEASE}.${CACTUS_OS}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__prefix__#${CACTUS_ROOT}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__sources_dir__#${RPMBUILD_DIR}/SOURCES#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__packagedir__#${PackagePath}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__os__#${CACTUS_OS}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__platform__#None#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__project__#${Project}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__author__#${Packager}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__summary__#None#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__description__#None#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__url__#${PackageURL}#' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's#__includedirs__#${IncludePaths}#' $(PackagePath)/rpm/$(PackageName).spec | ||
sed -i 's|^.*__build_requires__.*|${BUILD_REQUIRES_TAG}|' ${PackagePath}/rpm/${PackageName}.spec | ||
sed -i 's|^.*__requires__.*|${REQUIRES_TAG}|' ${PackagePath}/rpm/${PackageName}.spec | ||
if [ "${BuildDebuginfoRPM}" == "1" ]; then sed -i '1 i\%define _build_debuginfo_package %{nil}' ${PackagePath}/rpm/${PackageName}.spec; fi | ||
|
||
.PHONY: cleanrpm _cleanrpm | ||
cleanrpm: _cleanrpm | ||
_cleanrpm: | ||
-rm -r rpm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Sanitize package path | ||
PackagePath := $(shell cd ${PackagePath}; pwd) | ||
|
||
# Library sources | ||
LibrarySources = $(wildcard src/common/*.cpp) $(wildcard src/common/**/*.cpp) | ||
# Filter undesired files | ||
LibrarySourcesFiltered = $(filter-out ${IgnoreSources}, ${LibrarySources}) | ||
# Turn them into objects | ||
LibraryObjectFiles = $(patsubst src/common/%.cpp,${PackagePath}/obj/%.o,${LibrarySourcesFiltered}) | ||
|
||
ExecutableSources = $(wildcard src/common/*.cxx) | ||
# Filter undesired files | ||
ExecutableSourcesFiltered = $(filter-out ${IgnoreSources}, ${ExecutableSources}) | ||
# Turn them into objects | ||
ExecutableObjectFiles = $(patsubst src/common/%.cxx,${PackagePath}/obj/%.o,${ExecutableSourcesFiltered}) | ||
# And binaries | ||
Executables = $(patsubst src/common/%.cxx,${PackagePath}/bin/%.exe,${ExecutableSourcesFiltered}) | ||
|
||
# $(info LibrarySourcesFiltered = ${LibrarySourcesFiltered}) | ||
# $(info ExecutableSourcesFiltered = ${ExecutableSourcesFiltered}) | ||
# $(info ExecutableObjectFiles = ${ExecutableObjectFiles}) | ||
# $(info Executables = ${Executables}) | ||
|
||
# Compiler Flags | ||
IncludePaths := $(addprefix -I,${IncludePaths}) | ||
|
||
|
||
# Library dependencies | ||
DependentLibraries += $(addprefix -L,${LibraryPaths}) | ||
DependentLibraries += $(addprefix -l,${Libraries}) | ||
|
||
# Executable dependencies | ||
ExecutableDependentLibraries += $(addprefix -L,${LibraryPaths}) | ||
ExecutableDependentLibraries += $(addprefix -l,${ExecutableLibraries}) | ||
|
||
|
||
ifeq ("${Library}","") | ||
LibraryTarget ?= | ||
else | ||
LibraryTarget ?= lib/lib${Library}.so | ||
endif | ||
|
||
.PHONY: default | ||
default: build | ||
|
||
.PHONY: clean _cleanall | ||
clean: _cleanall | ||
_cleanall: | ||
rm -rf obj | ||
rm -rf bin | ||
rm -rf lib | ||
|
||
.PHONY: all _all build buildall | ||
all: _all | ||
build: _all | ||
buildall: _all | ||
_all: ${LibraryTarget} ${Executables} ${ExtraTargets} | ||
|
||
.PHONY: objects | ||
objects: ${LibraryObjectFiles} ${ExecutableObjectFiles} | ||
|
||
|
||
# Implicit rule for .cpp -> .o | ||
${PackagePath}/obj/%.o : ${PackagePath}/src/common/%.cpp | ||
${MakeDir} $(@D) | ||
${CPP} -c ${CXXFLAGS} ${IncludePaths} $< -o $@ | ||
|
||
# Implicit rule for .cxx -> .o | ||
${PackagePath}/obj/%.o : ${PackagePath}/src/common/%.cxx | ||
${MakeDir} $(@D) | ||
${CPP} -c ${CXXFLAGS} ${IncludePaths} $< -o $@ | ||
|
||
# Main target: shared library | ||
${LibraryTarget}: ${LibraryObjectFiles} | ||
${MakeDir} $(@D) | ||
${LD} -shared ${LDFLAGS} ${DependentLibraries} ${LibraryObjectFiles} -o $@ | ||
|
||
# Include automatically generated dependencies | ||
-include $(LibraryObjectFiles:.o=.d) | ||
|
||
# Static Pattern rule for binaries | ||
${Executables} : ${PackagePath}/bin/%.exe : ${PackagePath}/obj/%.o ${LibraryTarget} | ||
${MakeDir} $(@D) | ||
${LD} ${LDFLAGS} ${ExecutableDependentLibraries} $< -o $@ | ||
|
||
# Include automatically generated dependencies | ||
-include $(ExecutableObjectFiles:.o=.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os, sys | ||
from distutils.core import setup | ||
from os.path import join | ||
|
||
_rpmVersion='__version__' | ||
_name='__packagename__' | ||
_author='__author__' | ||
_author_email='' | ||
_description='__description__' | ||
_url='__url__' | ||
_packages=__python_packages__ | ||
_scripts=__scripts__ | ||
|
||
|
||
setup(name=_name, | ||
version = _rpmVersion, | ||
description = _description, | ||
author = _author, | ||
author_email = _author_email, | ||
url = _url, | ||
|
||
packages = _packages, | ||
package_dir = {'' : ''}, | ||
package_data = dict((pkg,['*.so']) for pkg in _packages), | ||
scripts = _scripts | ||
) | ||
|
Oops, something went wrong.