Skip to content

Commit

Permalink
wsputil.c packaged as a shared libary
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Dec 14, 2013
1 parent ec989d4 commit b94767f
Show file tree
Hide file tree
Showing 12 changed files with 1,835 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
*~
build
debian/*.log
debian/*substvars
debian/libwspcodec-dev
debian/files
debian/tmp
154 changes: 154 additions & 0 deletions Makefile
@@ -0,0 +1,154 @@
# -*- Mode: makefile -*-

.PHONY: clean all debug release pkgconfig install install-dev

# Required packages
PKGS = glib-2.0

#
# Default target
#

all: debug release pkgconfig

#
# Library version
#

VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_MICRO = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)

LIB_SHORTCUT = libwspcodec.so
LIB_SONAME = $(LIB_SHORTCUT).$(VERSION_MAJOR)
LIB = $(LIB_SHORTCUT).$(VERSION)

#
# Sources
#

SRC = wsputil.c

#
# Directories
#

SRC_DIR = src
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release

#
# Tools and flags
#

CC = $(CROSS_COMPILE)gcc
LD = $(CC)
WARNINGS = -Wall
INCLUDES = -I$(SRC_DIR)
CFLAGS = -fPIC $(WARNINGS) $(INCLUDES) $(shell pkg-config --cflags $(PKGS))
LDFLAGS = -fPIC -shared -Wl,-soname -Wl,$(LIB_SONAME)
DEBUG_CFLAGS = -g -DDEBUG $(CFLAGS) -MMD -MP
DEBUG_LDFLAGS = -g $(LDFLAGS)
RELEASE_CFLAGS = -O2 $(CFLAGS) -MMD -MP
RELEASE_LDFLAGS = $(LDFLAGS)
ARFLAGS = rc

#
# Files
#

PKGCONFIG = $(BUILD_DIR)/libwspcodec.pc
SRC_FILES = $(SRC:%=$(SRC_DIR)/%)
DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)

#
# Dependencies
#

DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif

#
# Rules
#
DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)

debug: $(DEBUG_LIB)

release: $(RELEASE_LIB)

pkgconfig: $(PKGCONFIG)

clean:
rm -fr $(BUILD_DIR) *~ $(SRC_DIR)/*~

$(BUILD_DIR):
mkdir -p $@

$(DEBUG_BUILD_DIR):
mkdir -p $@

$(RELEASE_BUILD_DIR):
mkdir -p $@

$(DEBUG_LIB): $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
$(LD) -o $@ $(DEBUG_LDFLAGS) $(DEBUG_OBJS)

$(RELEASE_LIB): $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
$(LD) -o $@ $(RELEASE_LDFLAGS) $(RELEASE_OBJS)
strip $@

$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(DEBUG_CFLAGS) -MF"$(@:%.o=%.d)" $< -o $@

$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MF"$(@:%.o=%.d)" $< -o $@

$(PKGCONFIG): libwspcodec.pc.in
sed -e 's/\[version\]/'$(VERSION)/g $< >> $@

#
# Install
#

INSTALL_PERM = 644
INSTALL_OWNER = $(shell id -u)
INSTALL_GROUP = $(shell id -g)

INSTALL = install
INSTALL_DIRS = $(INSTALL) -d
INSTALL_FILES = $(INSTALL) -m $(INSTALL_PERM)

INSTALL_LIB_DIR = $(DESTDIR)/usr/lib
INSTALL_INCLUDE_DIR = $(DESTDIR)/usr/include/libwspcodec/wspcodec
INSTALL_PKGCONFIG_DIR = $(DESTDIR)/usr/lib/pkgconfig

INSTALL_ALIAS1 = $(INSTALL_LIB_DIR)/$(LIB_SONAME)
INSTALL_ALIAS2 = $(INSTALL_LIB_DIR)/$(LIB_SHORTCUT)

install: $(INSTALL_LIB_DIR)
$(INSTALL_FILES) $(RELEASE_LIB) $(INSTALL_LIB_DIR)
ln -sf $(LIB) $(INSTALL_ALIAS1)
ln -sf $(LIB) $(INSTALL_ALIAS2)

install-dev: install $(INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
$(INSTALL_FILES) $(SRC_DIR)/wsputil.h $(INSTALL_INCLUDE_DIR)
$(INSTALL_FILES) $(SRC_DIR)/wspcodec.h $(INSTALL_INCLUDE_DIR)
$(INSTALL_FILES) $(PKGCONFIG) $(INSTALL_PKGCONFIG_DIR)

$(INSTALL_LIB_DIR):
$(INSTALL_DIRS) $@

$(INSTALL_INCLUDE_DIR):
$(INSTALL_DIRS) $@

$(INSTALL_PKGCONFIG_DIR):
$(INSTALL_DIRS) $@
5 changes: 5 additions & 0 deletions debian/changelog
@@ -0,0 +1,5 @@
libwspcodec (1.0.0-1) unstable; urgency=low

* Initial release

-- Slava Monich <s;ava.monich@jolla.com> Sat, 14 Dec 2013 13:20:14 +0200
18 changes: 18 additions & 0 deletions debian/control
@@ -0,0 +1,18 @@
Source: libwspcodec
Section: libs
Priority: optional
Maintainer: Slava Monich <slava.monich@jolla.com>
Build-Depends: debhelper (>= 7), libglib2.0-dev (>= 2.0)
Standards-Version: 3.8.4

Package: libwspcodec
Section: libs
Architecture: any
Depends: libglib2.0-bin (>= 2.0)
Description: WSP encoder and decoder library

Package: libwspcodec-dev
Section: libdevel
Architecture: any
Depends: libwspcodec (= ${binary:Version})
Description: Development files for libwspcodec
28 changes: 28 additions & 0 deletions debian/copyright
@@ -0,0 +1,28 @@
Copyright (C) 2013 Jolla Ltd.

You may use this file under the terms of the BSD license as follows:

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Nemo Mobile nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 3 additions & 0 deletions debian/libwspcodec-dev.install
@@ -0,0 +1,3 @@
src/wspcodec.h usr/include/libwspcodec/wspcodec
src/wsputil.h usr/include/libwspcodec/wspcodec
build/libwspcodec.pc usr/lib/pkgconfig
8 changes: 8 additions & 0 deletions debian/rules
@@ -0,0 +1,8 @@
#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
dh $@
9 changes: 9 additions & 0 deletions libwspcodec.pc.in
@@ -0,0 +1,9 @@
libdir=/usr/lib
includedir=/usr/include/libwspcodec

Name: libwspcodec
Description: WSP encoder and decoder library
Version: [version]
Requires: glib-2.0
Libs: -L${libdir} -lwspcodec
Cflags: -I${includedir} -I${includedir}/wspcodec
48 changes: 48 additions & 0 deletions rpm/libwspcodec.spec
@@ -0,0 +1,48 @@
Name: libwspcodec
Version: 1.0.0
Release: 1
Summary: WSP encoder and decoder library
Group: Development/Libraries
License: LGPL
URL: http://github.com/nemomobile
Source: %{name}-%{version}.tar.bz2
Requires: glib2 >= 2.0
BuildRequires: glib2-devel >= 2.0
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig

%description
Provides utilities to encode and decode WSP PDUs.

%package devel
Summary: Development library for %{name}
Requires: %{name} = %{version}
Requires: pkgconfig

%description devel
This package contains the development library for %{name}.

%prep
%setup -q

%build
make release pkgconfig

%install
rm -rf %{buildroot}
make install-dev DESTDIR=%{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%{_libdir}/%{name}.so*

%files devel
%defattr(-,root,root,-)
%{_libdir}/%{name}.so*
%{_libdir}/pkgconfig/libwspcodec.pc
%{_includedir}/libwspcodec/wspcodec/wsputil.h
%{_includedir}/libwspcodec/wspcodec/wspcodec.h
37 changes: 37 additions & 0 deletions src/wspcodec.h
@@ -0,0 +1,37 @@
/* Copyright (C) 2013 Jolla Ltd.
*
* You may use this file under the terms of the BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WSPCODEC_H
#define WSPCODEC_H

#include <glib.h>
#include "wsputil.h"

#endif /* WSPCODEC_H */

0 comments on commit b94767f

Please sign in to comment.