blob: 086c124789a4e41899c3be2de91c05db937876ba [file] [log] [blame]
Harald Welte20a58c62017-12-13 01:04:42 +01001#!/bin/sh
2
Harald Welte0cdf0712019-06-19 18:15:38 +02003# Copyright 2017-2019 Harald Welte
4# Copyright 2018 sysmocom - s.f.m.c. GmbH
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18
Harald Welte20a58c62017-12-13 01:04:42 +010019# Wrapper around the TITAN make file generator to work in Debian.
20#
21# TITAN has a makefile generator, but somehow Debian seems to install
22# the binaries to different paths without patching the make file
23# generator, leading in inconsistent non-working Makefiles.
24#
Max00fcc492018-12-11 12:33:37 +010025# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884303 for details.
26#
Harald Welte20a58c62017-12-13 01:04:42 +010027# The regexes below patch the generated Makefile to work on Debian 9 and
28# unstable, so far tested with TITAN 6.1.0, 6.2.0 and 6.3.0
Maxdbf15f82017-12-13 11:34:44 +010029#
Harald Welte20a58c62017-12-13 01:04:42 +010030
Pau Espin Pedrolef85dfa2018-01-29 11:48:38 +010031test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: ttcn3_makefilegen not in PATH"; exit 1; }
32
Stefan Sperling526895e2018-03-31 16:19:40 +020033# Enable ccache if it can be found in path.
34# This speeds up repeated builds of the TTCN3 tests by an order of magnitude
35# since most of the generated C++ source files don't change very often.
36# Roughly, for an initial build which takes N minutes, a complete rebuild
37# after 'make clean' will only take N seconds with ccache.
38# Note that ccache cannot speed up compilation of .o files to .so files.
39if [ -z "$USE_CCACHE" ] && which ccache 2>/dev/null; then
40 USE_CCACHE=1
41fi
42
Harald Welte9d09c4d2020-03-01 22:44:55 +010043ttcn3_makefilegen -g -p -l -U 5 -f $*
Daniel Willmannf6c5da92019-02-13 17:58:25 +010044
45TITAN_VERSION=$(ttcn3_makefilegen -v 2>&1 |grep "Product number" |cut --delimiter="/" -f 2-| sed -e "s/[A-Z ]//g")
46
Harald Welte20a58c62017-12-13 01:04:42 +010047sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
Harald Welte18ed23c2020-10-04 21:06:24 +020048sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan/' Makefile
49sed -i -e 's/LINUX_LIBS = -lxml2/LINUX_LIBS = -lxml2 -lsctp/' Makefile
Harald Welte20a58c62017-12-13 01:04:42 +010050#sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
Maxdbf15f82017-12-13 11:34:44 +010051
52# The -DMAKEDEPEND_RUN is a workaround for Debian packaging issue,
53# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879816 for details
Daniel Willmannf6c5da92019-02-13 17:58:25 +010054if [ $(($TITAN_VERSION >= 65)) = 1 ]; then
Pau Espin Pedrol1f2da162020-08-21 12:28:50 +020055 sed -i -e 's/CPPFLAGS = -D$(PLATFORM)/CPPFLAGS = -D$(PLATFORM) -DMAKEDEPEND_RUN -DUSE_SCTP -DLKSCTP_MULTIHOMING_ENABLED/' Makefile
Daniel Willmannf6c5da92019-02-13 17:58:25 +010056else
57 sed -i -e 's/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -DMAKEDEPEND_RUN -DUSE_SCTP -I$(TTCN3_DIR)\/include -I\/usr\/include\/titan/' Makefile
58fi
Harald Welte20a58c62017-12-13 01:04:42 +010059
Max8b9e69f2018-12-11 14:02:49 +010060#remove -Wall from CXXFLAGS: we're not interested in generic warnings for autogenerated code cluttering the logs
61sed -i -e 's/-Wall//' Makefile
62
Harald Weltedf277252018-02-20 15:49:30 +010063if [ "x$CPPFLAGS_TTCN3" != "x" ]; then
64 sed -i -e 's/CPPFLAGS_TTCN3 =/CPPFLAGS_TTCN3 = '"$CPPFLAGS_TTCN3"'/' Makefile
65fi
66
Harald Welte20a58c62017-12-13 01:04:42 +010067# for TITAN 6.3.0
Pau Espin Pedrol5c9d99f2018-01-29 11:37:25 +010068if cat /etc/issue | grep "Arch Linux" >/dev/null 2>&1; then
69 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr\/ttcn3/' Makefile
70else
71 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile
72fi
Harald Welte20a58c62017-12-13 01:04:42 +010073sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile
Stefan Sperling526895e2018-03-31 16:19:40 +020074
75if [ "x$USE_CCACHE" = "x1" ]; then
76 # enable ccache
77 sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros ccache g++/' Makefile
78 # Append the -D option to compiler flags. This option disables timestamps
79 # inside comments in the generated C++ code which interfere with ccache.
Harald Welte01e72d52019-04-30 18:38:31 +020080 sed -i -e 's/^COMPILER_FLAGS = \(.*\)/& -D/' Makefile
Stefan Sperling526895e2018-03-31 16:19:40 +020081fi