Commit 562af6ed authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Source rpm creation added

parent 5ac07364
*~
*.o
build/
\ No newline at end of file
build/
*.tar.gz
moberg-*.spec
LIBRARIES=libmoberg.so
MOBERG_VERSION=$(shell git describe --tags | sed -e 's/^v//;s/-/_/g' )
CCFLAGS+=-Wall -Werror -I$(shell pwd) -g
LDFLAGS+=-L$(shell pwd)/build/ -lmoberg
PLUGINS:=$(wildcard plugins/*)
......@@ -27,19 +28,37 @@ build/%.o: %.c Makefile
build/lib/%.o: %.c Makefile | build/lib
$(CC) $(CCFLAGS) -c -fPIC -o $@ $<
.PHONY: $(PLUGINS) $(ADAPTORS)
$(ADAPTORS) $(PLUGINS):
$(MAKE) -C $@
.PHONY: TAR
TAR:
git archive \
--prefix moberg-$(MOBERG_VERSION)/ \
--output moberg-$(MOBERG_VERSION).tar.gz -- HEAD
.PHONY: moberg-$(MOBERG_VERSION).spec
moberg-$(MOBERG_VERSION).spec: moberg.spec.template Makefile
sed -e 's/__MOBERG_VERSION__/$(MOBERG_VERSION)/' $< > $@
.PHONY: SRPM
SRPM: moberg-$(MOBERG_VERSION).spec TAR
rpmbuild --define "_sourcedir $$(pwd)" \
-bs $<
.PHONY: test
test: all
$(MAKE) -C test test
clean:
rm -f build/*.so build/*.mex*
rm -f build/*.so
rm -f build/*.mex*
rm -f *~
rm -f moberg-*.spec
rm -f moberg-*.tar.gz
make -C test clean
build/libmoberg.so: build/lib/moberg.o
......
......@@ -7,8 +7,10 @@ MEX_SUFFIX=$(shell $(MEX) -v -n analogin.c \
CCFLAGS+=-Wall -Werror -I. -I../.. -g
all: $(LIBRARIES:%=../../build/%) $(SFUNC:%=../../build/%.$(MEX_SUFFIX))
echo $(SUFFIX)
all: $(LIBRARIES:%=../../build/%)
.PHONY: SFUNC
SFUNC: $(SFUNC:%=../../build/%.$(MEX_SUFFIX))
../../build/libmoberg4simulink.so: moberg4simulink.c Makefile
$(CC) -o $@ $(CCFLAGS) -L../../build -shared -fPIC -lmoberg $<
......
......@@ -220,8 +220,7 @@ static int install_config(struct moberg *moberg)
}
}
struct moberg *moberg_new(
struct moberg_config *config)
struct moberg *moberg_new()
{
struct moberg *result = malloc(sizeof(*result));
if (! result) {
......@@ -239,32 +238,28 @@ struct moberg *moberg_new(
result->encoder_in.capacity = 0;
result->encoder_in.value = NULL;
result->deferred_action = NULL;
if (config) {
result->config = config;
} else {
result->config = NULL;
result->config = NULL;
/* Parse default configuration(s) */
const char * const *config_paths = xdgSearchableConfigDirectories(NULL);
const char * const *path;
for (path = config_paths ; *path ; path++) {
int dirfd1 = open(*path, O_DIRECTORY);
if (dirfd >= 0) {
parse_config_at(result, dirfd1, "moberg.conf");
int dirfd2 = openat(dirfd1, "moberg.d", O_DIRECTORY);
if (dirfd2 >= 0) {
parse_config_dir_at(result, dirfd2);
close(dirfd2);
}
close(dirfd1);
/* Parse default configuration(s) */
const char * const *config_paths = xdgSearchableConfigDirectories(NULL);
const char * const *path;
for (path = config_paths ; *path ; path++) {
int dirfd1 = open(*path, O_DIRECTORY);
if (dirfd >= 0) {
parse_config_at(result, dirfd1, "moberg.conf");
int dirfd2 = openat(dirfd1, "moberg.d", O_DIRECTORY);
if (dirfd2 >= 0) {
parse_config_dir_at(result, dirfd2);
close(dirfd2);
}
free((char*)*path);
close(dirfd1);
}
free((const char **)config_paths);
/* Read environment default */
/* Parse environment overrides */
free((char*)*path);
}
free((const char **)config_paths);
/* TODO: Read & parse environment overrides */
install_config(result);
run_deferred_actions(result);
......
......@@ -4,11 +4,10 @@
#include <stdio.h>
struct moberg;
struct moberg_config;
/* Creation & free */
struct moberg *moberg_new(struct moberg_config *config);
struct moberg *moberg_new();
void moberg_free(struct moberg *moberg);
......
Name: moberg
Version: __MOBERG_VERSION__
Release: 1
Summary: Library for abstracting physical I/O
License: GPLv3
Source0: https://gitlab.control.lth.se/anders_blomdell/moberg/-/archive/master/moberg-__MOBERG_VERSION__.tar.gz
BuildRequires: gcc
BuildRequires: comedilib-devel
BuildRequires: valgrind
%description
Shared library for abstracting physical process I/O (analog, digital
and encoders)
%package comedi
Summary: Comedi support for %{name}
Requires: %{name} = %{version}-%{release}
Requires: comedilib
%description comedi
Comedi support for for %{name}
%package devel
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
%description devel
Development files for %{name}
%package matlab
Summary: Matlab development files for %{name}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}
%description matlab
Matlab development files for %{name}
%prep
%setup -q -n %{name}-__MOBERG_VERSION__
%build
make MOBERG_VERSION=__MOBERG_VERSION__
%check
make test
%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
cp build/libmoberg*.so ${RPM_BUILD_ROOT}%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}
cp moberg.h ${RPM_BUILD_ROOT}%{_includedir}
mkdir -p ${RPM_BUILD_ROOT}/opt/matlab/src/moberg
cp adaptors/matlab/*.h ${RPM_BUILD_ROOT}/opt/matlab/src/moberg
cp adaptors/matlab/*in.c ${RPM_BUILD_ROOT}/opt/matlab/src/moberg
cp adaptors/matlab/*out.c ${RPM_BUILD_ROOT}/opt/matlab/src/moberg
cp adaptors/matlab/Makefile ${RPM_BUILD_ROOT}/opt/matlab/src/moberg
%files
%defattr(-,root,root,-)
%attr(04755,root,root) %{_libdir}/libmoberg.so
%attr(04755,root,root) %{_libdir}/libmoberg_serial2002.so
%files comedi
%defattr(-,root,root,-)
%attr(04755,root,root) %{_libdir}/libmoberg_comedi.so
%files devel
%defattr(-,root,root,-)
%attr(04755,root,root) %{_includedir}/moberg.h
%files matlab
%defattr(-,root,root,-)
%attr(04755,root,root) %{_libdir}/libmoberg4simulink.so
%attr(04755,root,root) /opt/matlab/src/moberg/*
......@@ -5,7 +5,7 @@ ENV_TEST = LD_LIBRARY_PATH=../build HOME=.
LDFLAGS_test_moberg4simulink = -lmoberg4simulink
CCFLAGS_test_moberg4simulink = -I../adaptors/matlab -Wall -Werror -I$(shell pwd) -g
all:
all:
.PHONY: test
test: $(TEST:%=run_%)
......
#include <moberg4simulink.h>
int main(int argc, char *argv[])
{
struct moberg_analog_in *ain = moberg4simulink_analog_in_open(0);
moberg4simulink_analog_in_close(0, ain);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment