Skip to content

Commit

Permalink
[libwspcodec] Respect arch specific lib dir. JB#49681
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed May 25, 2020
1 parent 7742eb8 commit e768cbb
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .gitignore
@@ -1,12 +1,12 @@
*~
build
debian/*.log
debian/*substvars
debian/files
debian/libwspcodec
debian/libwspcodec-dev
debian/libwspcodec.postinst.debhelper
debian/libwspcodec.postrm.debhelper
debian/files
debian/*.debhelper.log
debian/*.debhelper
debian/*.install
debian/*.substvars
debian/tmp
documentation.list
installroot
Expand Down
73 changes: 43 additions & 30 deletions Makefile
Expand Up @@ -18,9 +18,13 @@ all: debug release pkgconfig
VERSION_MAJOR = 2
VERSION_MINOR = 2
VERSION_RELEASE = 1

VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)

LIB_SHORTCUT = libwspcodec-$(VERSION).so
NAME = wspcodec
LIB_NAME = lib$(NAME)
LIB_SHORTCUT = $(LIB_NAME)-$(VERSION).so
LIB_SONAME = $(LIB_SHORTCUT)
LIB = $(LIB_SONAME).$(VERSION_RELEASE)

Expand Down Expand Up @@ -48,31 +52,29 @@ LD = $(CC)
WARNINGS = -Wall
INCLUDES = -I$(SRC_DIR)
BASE_FLAGS = -fPIC
CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
$(shell pkg-config --cflags $(PKGS))
LDFLAGS = $(BASE_FLAGS) -shared -Wl,-soname,$(LIB_SONAME) \
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
-MMD -MP $(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname=$(LIB_SONAME) \
$(shell pkg-config --libs $(PKGS))
DEBUG_FLAGS = -g
RELEASE_FLAGS =

ifndef KEEP_SYMBOLS
KEEP_SYMBOLS = 0
endif

KEEP_SYMBOLS ?= 0
ifneq ($(KEEP_SYMBOLS),0)
RELEASE_FLAGS += -g
endif

DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)

DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2

#
# Files
#

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

Expand All @@ -87,6 +89,10 @@ ifneq ($(strip $(DEPS)),)
endif
endif

$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
$(PKGCONFIG): | $(BUILD_DIR)

#
# Rules
#
Expand All @@ -98,14 +104,13 @@ debug: $(DEBUG_LIB)

release: $(RELEASE_LIB)

pkgconfig: $(PKGCONFIG)

clean:
rm -f *~ $(SRC_DIR)/*~
rm -fr $(BUILD_DIR) RPMS installroot
rm -fr debian/tmp debian/libwspcodec debian/libwspcodec-dev
rm -fr debian/tmp debian/$(LIB_NAME) debian/$(LIB_NAME)-dev
rm -f documentation.list debian/files debian/*.substvars
rm -f debian/*.debhelper.log debian/*.debhelper
rm -f debian/*.install debian/*~

$(BUILD_DIR):
mkdir -p $@
Expand All @@ -116,39 +121,47 @@ $(DEBUG_BUILD_DIR):
$(RELEASE_BUILD_DIR):
mkdir -p $@

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

$(RELEASE_LIB): $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
$(RELEASE_LIB): $(RELEASE_OBJS)
$(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) -o $@
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif

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

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

$(PKGCONFIG): libwspcodec.pc.in
sed -e 's/\[version\]/'$(VERSION)/g $< > $@
#
# LIBDIR usually gets substituted with arch specific dir
# It's relative in deb build and can be whatever in rpm build.
#

LIBDIR ?= /usr/lib
ABS_LIBDIR := $(shell echo /$(LIBDIR) | sed -r 's|/+|/|g')

pkgconfig: $(PKGCONFIG)

$(PKGCONFIG): $(LIB_NAME).pc.in Makefile
sed -e 's|@version@|$(PCVERSION)|g' -e 's|@libdir@|$(ABS_LIBDIR)|g' $< > $@

debian/%.install: debian/%.install.in
sed 's|@LIBDIR@|$(LIBDIR)|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_FILES = $(INSTALL) -m 644

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

INSTALL_ALIAS = $(INSTALL_LIB_DIR)/$(LIB_SHORTCUT)

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Expand Up @@ -2,7 +2,7 @@ Source: libwspcodec
Section: libs
Priority: optional
Maintainer: Slava Monich <slava.monich@jolla.com>
Build-Depends: debhelper (>= 7), libglib2.0-dev (>= 2.0)
Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0)
Standards-Version: 3.8.4

Package: libwspcodec
Expand Down
3 changes: 0 additions & 3 deletions debian/libwspcodec-dev.install

This file was deleted.

2 changes: 2 additions & 0 deletions debian/libwspcodec-dev.install.in
@@ -0,0 +1,2 @@
debian/tmp/@LIBDIR@/pkgconfig/libwspcodec.pc @LIBDIR@/pkgconfig
debian/tmp/usr/include/* usr/include
1 change: 0 additions & 1 deletion debian/libwspcodec.install

This file was deleted.

1 change: 1 addition & 0 deletions debian/libwspcodec.install.in
@@ -0,0 +1 @@
debian/tmp/@LIBDIR@/libwspcodec*.so* @LIBDIR@
8 changes: 8 additions & 0 deletions debian/rules
Expand Up @@ -4,5 +4,13 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

LIBDIR=usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

override_dh_auto_build:
dh_auto_build -- LIBDIR=$(LIBDIR) release pkgconfig debian/libwspcodec.install debian/libwspcodec-dev.install

override_dh_auto_install:
dh_auto_install -- LIBDIR=$(LIBDIR) install-dev

%:
dh $@
13 changes: 7 additions & 6 deletions libwspcodec.pc.in
@@ -1,9 +1,10 @@
libdir=/usr/lib
includedir=/usr/include/libwspcodec
name=wspcodec
libdir=@libdir@
includedir=/usr/include

Name: libwspcodec
Description: WSP encoder and decoder library
Version: [version]
Requires: glib-2.0
Libs: -L${libdir} -lwspcodec-[version]
Cflags: -I${includedir} -I${includedir}/wspcodec
Version: @version@
Requires.private: glib-2.0
Libs: -L${libdir} -l${name}-2.2
Cflags: -I${includedir} -I${includedir}/${name}
14 changes: 6 additions & 8 deletions rpm/libwspcodec.spec
Expand Up @@ -4,7 +4,7 @@ Release: 0
Summary: WSP encoder and decoder library
Group: Development/Libraries
License: GPLv2
URL: https://git.merproject.org/mer-core/libwspcodec
URL: https://git.sailfishos.org/mer-core/libwspcodec
Source: %{name}-%{version}.tar.bz2
BuildRequires: glib2-devel >= 2.0
Requires(post): /sbin/ldconfig
Expand All @@ -25,23 +25,21 @@ This package contains the development library for %{name}.
%setup -q

%build
make KEEP_SYMBOLS=1 release pkgconfig
make LIBDIR=%{_libdir} KEEP_SYMBOLS=1 release pkgconfig

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

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

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

%files devel
%defattr(-,root,root,-)
%{_libdir}/%{name}-2.2.so
%{_libdir}/pkgconfig/libwspcodec.pc
%{_includedir}/libwspcodec/wspcodec/wsputil.h
%{_includedir}/libwspcodec/wspcodec/wspcodec.h
%{_libdir}/pkgconfig/*.pc
%{_includedir}/wspcodec

0 comments on commit e768cbb

Please sign in to comment.