blob: 448a31af6e7544df9492615e0e3bc7231fc9020e [file] [log] [blame]
Liam McLoughlin4f268f42013-03-04 18:09:53 -05001#!/bin/bash
2
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7set -e
8
9OUT=$1
10shift
11for v; do
Alex Vakulenkofed60b02015-10-27 09:53:05 -070012 # Extract all the libbrillo sublibs from 'dependencies' section of
13 # 'libbrillo-<(libbase_ver)' target in libbrillo.gypi and convert them
14 # into an array of "-lbrillo-<sublib>-<v>" flags.
Alex Vakulenko02a06c42014-08-26 09:56:46 -070015 sublibs=($(sed -n "
Alex Vakulenkofed60b02015-10-27 09:53:05 -070016 /'target_name': 'libbrillo-<(libbase_ver)'/,/target_name/ {
Alex Vakulenko02a06c42014-08-26 09:56:46 -070017 /dependencies/,/],/ {
Alex Vakulenkofed60b02015-10-27 09:53:05 -070018 /libbrillo/ {
Alex Vakulenko02a06c42014-08-26 09:56:46 -070019 s:[',]::g
20 s:<(libbase_ver):${v}:g
Alex Vakulenkofed60b02015-10-27 09:53:05 -070021 s:libbrillo:-lbrillo:
Alex Vakulenko02a06c42014-08-26 09:56:46 -070022 p
23 }
24 }
Alex Vakulenkofed60b02015-10-27 09:53:05 -070025 }" libbrillo.gypi))
Alex Vakulenko02a06c42014-08-26 09:56:46 -070026
Alex Vakulenkofed60b02015-10-27 09:53:05 -070027 echo "GROUP ( AS_NEEDED ( ${sublibs[@]} ) )" > "${OUT}"/lib/libbrillo-${v}.so
Liam McLoughlin4f268f42013-03-04 18:09:53 -050028
Alex Vakulenkofed60b02015-10-27 09:53:05 -070029 deps=$(<"${OUT}"/gen/libbrillo-${v}-deps.txt)
30 pc="${OUT}"/lib/libbrillo-${v}.pc
Liam McLoughlin4f268f42013-03-04 18:09:53 -050031
32 sed \
33 -e "s/@BSLOT@/${v}/g" \
34 -e "s/@PRIVATE_PC@/${deps}/g" \
Alex Vakulenkofed60b02015-10-27 09:53:05 -070035 "libbrillo.pc.in" > "${pc}"
Alex Vakulenkof788c952014-08-20 17:35:12 -070036
Alex Vakulenkofed60b02015-10-27 09:53:05 -070037 deps_test=$(<"${OUT}"/gen/libbrillo-test-${v}-deps.txt)
38 deps_test+=" libbrillo-${v}"
Alex Vakulenkof788c952014-08-20 17:35:12 -070039 sed \
40 -e "s/@BSLOT@/${v}/g" \
Alex Vakulenko678d9802014-09-12 14:01:45 -070041 -e "s/@PRIVATE_PC@/${deps_test}/g" \
Alex Vakulenkofed60b02015-10-27 09:53:05 -070042 "libbrillo-test.pc.in" > "${OUT}/lib/libbrillo-test-${v}.pc"
Christopher Wiley8065d312015-07-08 13:11:21 -070043
44
Alex Vakulenkofed60b02015-10-27 09:53:05 -070045 deps_glib=$(<"${OUT}"/gen/libbrillo-glib-${v}-deps.txt)
46 pc_glib="${OUT}"/lib/libbrillo-glib-${v}.pc
Christopher Wiley8065d312015-07-08 13:11:21 -070047
48 sed \
49 -e "s/@BSLOT@/${v}/g" \
50 -e "s/@PRIVATE_PC@/${deps_glib}/g" \
Alex Vakulenkofed60b02015-10-27 09:53:05 -070051 "libbrillo-glib.pc.in" > "${pc_glib}"
Liam McLoughlin4f268f42013-03-04 18:09:53 -050052done