blob: 6b32f75fbff22d8ad40c23c6db1851707db1d259 [file] [log] [blame]
Harald Welte20a58c62017-12-13 01:04:42 +01001#!/bin/sh
2
3# Wrapper around the TITAN make file generator to work in Debian.
4#
5# TITAN has a makefile generator, but somehow Debian seems to install
6# the binaries to different paths without patching the make file
7# generator, leading in inconsistent non-working Makefiles.
8#
9# The regexes below patch the generated Makefile to work on Debian 9 and
10# unstable, so far tested with TITAN 6.1.0, 6.2.0 and 6.3.0
Maxdbf15f82017-12-13 11:34:44 +010011#
Harald Welte20a58c62017-12-13 01:04:42 +010012
Pau Espin Pedrolef85dfa2018-01-29 11:48:38 +010013test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: ttcn3_makefilegen not in PATH"; exit 1; }
14
Stefan Sperling526895e2018-03-31 16:19:40 +020015# Enable ccache if it can be found in path.
16# This speeds up repeated builds of the TTCN3 tests by an order of magnitude
17# since most of the generated C++ source files don't change very often.
18# Roughly, for an initial build which takes N minutes, a complete rebuild
19# after 'make clean' will only take N seconds with ccache.
20# Note that ccache cannot speed up compilation of .o files to .so files.
21if [ -z "$USE_CCACHE" ] && which ccache 2>/dev/null; then
22 USE_CCACHE=1
23fi
24
Harald Weltedf277252018-02-20 15:49:30 +010025ttcn3_makefilegen -p -l -f $*
Harald Welte20a58c62017-12-13 01:04:42 +010026sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
27sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile
28#sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
Maxdbf15f82017-12-13 11:34:44 +010029
30# The -DMAKEDEPEND_RUN is a workaround for Debian packaging issue,
31# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879816 for details
32sed -i -e 's/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -DMAKEDEPEND_RUN -I$(TTCN3_DIR)\/include -I\/usr\/include\/titan/' Makefile
Harald Welte20a58c62017-12-13 01:04:42 +010033
Harald Weltedf277252018-02-20 15:49:30 +010034if [ "x$CPPFLAGS_TTCN3" != "x" ]; then
35 sed -i -e 's/CPPFLAGS_TTCN3 =/CPPFLAGS_TTCN3 = '"$CPPFLAGS_TTCN3"'/' Makefile
36fi
37
Harald Welte20a58c62017-12-13 01:04:42 +010038# for TITAN 6.3.0
Pau Espin Pedrol5c9d99f2018-01-29 11:37:25 +010039if cat /etc/issue | grep "Arch Linux" >/dev/null 2>&1; then
40 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr\/ttcn3/' Makefile
41else
42 sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile
43fi
Harald Welte20a58c62017-12-13 01:04:42 +010044sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile
Stefan Sperling526895e2018-03-31 16:19:40 +020045
46if [ "x$USE_CCACHE" = "x1" ]; then
47 # enable ccache
48 sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros ccache g++/' Makefile
49 # Append the -D option to compiler flags. This option disables timestamps
50 # inside comments in the generated C++ code which interfere with ccache.
51 sed -i -e 's/^COMPILER_FLAGS = \(.*\)/&-D/' Makefile
52fi