Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 1 | #!/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 | # |
Max | 00fcc49 | 2018-12-11 12:33:37 +0100 | [diff] [blame] | 9 | # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884303 for details. |
| 10 | # |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 11 | # The regexes below patch the generated Makefile to work on Debian 9 and |
| 12 | # unstable, so far tested with TITAN 6.1.0, 6.2.0 and 6.3.0 |
Max | dbf15f8 | 2017-12-13 11:34:44 +0100 | [diff] [blame] | 13 | # |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 14 | |
Pau Espin Pedrol | ef85dfa | 2018-01-29 11:48:38 +0100 | [diff] [blame] | 15 | test -x "$(which ttcn3_makefilegen 2>/dev/null)" || { echo "ERROR: ttcn3_makefilegen not in PATH"; exit 1; } |
| 16 | |
Stefan Sperling | 526895e | 2018-03-31 16:19:40 +0200 | [diff] [blame] | 17 | # Enable ccache if it can be found in path. |
| 18 | # This speeds up repeated builds of the TTCN3 tests by an order of magnitude |
| 19 | # since most of the generated C++ source files don't change very often. |
| 20 | # Roughly, for an initial build which takes N minutes, a complete rebuild |
| 21 | # after 'make clean' will only take N seconds with ccache. |
| 22 | # Note that ccache cannot speed up compilation of .o files to .so files. |
| 23 | if [ -z "$USE_CCACHE" ] && which ccache 2>/dev/null; then |
| 24 | USE_CCACHE=1 |
| 25 | fi |
| 26 | |
Harald Welte | df27725 | 2018-02-20 15:49:30 +0100 | [diff] [blame] | 27 | ttcn3_makefilegen -p -l -f $* |
Daniel Willmann | f6c5da9 | 2019-02-13 17:58:25 +0100 | [diff] [blame] | 28 | |
| 29 | TITAN_VERSION=$(ttcn3_makefilegen -v 2>&1 |grep "Product number" |cut --delimiter="/" -f 2-| sed -e "s/[A-Z ]//g") |
| 30 | |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 31 | sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile |
| 32 | sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile |
| 33 | #sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile |
Max | dbf15f8 | 2017-12-13 11:34:44 +0100 | [diff] [blame] | 34 | |
| 35 | # The -DMAKEDEPEND_RUN is a workaround for Debian packaging issue, |
| 36 | # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879816 for details |
Daniel Willmann | f6c5da9 | 2019-02-13 17:58:25 +0100 | [diff] [blame] | 37 | if [ $(($TITAN_VERSION >= 65)) = 1 ]; then |
| 38 | sed -i -e 's/CPPFLAGS = -D$(PLATFORM)/CPPFLAGS = -D$(PLATFORM) -DMAKEDEPEND_RUN -DUSE_SCTP/' Makefile |
| 39 | else |
| 40 | 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 |
| 41 | fi |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 42 | |
Max | 8b9e69f | 2018-12-11 14:02:49 +0100 | [diff] [blame] | 43 | #remove -Wall from CXXFLAGS: we're not interested in generic warnings for autogenerated code cluttering the logs |
| 44 | sed -i -e 's/-Wall//' Makefile |
| 45 | |
Harald Welte | df27725 | 2018-02-20 15:49:30 +0100 | [diff] [blame] | 46 | if [ "x$CPPFLAGS_TTCN3" != "x" ]; then |
| 47 | sed -i -e 's/CPPFLAGS_TTCN3 =/CPPFLAGS_TTCN3 = '"$CPPFLAGS_TTCN3"'/' Makefile |
| 48 | fi |
| 49 | |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 50 | # for TITAN 6.3.0 |
Pau Espin Pedrol | 5c9d99f | 2018-01-29 11:37:25 +0100 | [diff] [blame] | 51 | if cat /etc/issue | grep "Arch Linux" >/dev/null 2>&1; then |
| 52 | sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr\/ttcn3/' Makefile |
| 53 | else |
| 54 | sed -i -e 's/TTCN3_DIR = $/TTCN3_DIR = \/usr/' Makefile |
| 55 | fi |
Harald Welte | 20a58c6 | 2017-12-13 01:04:42 +0100 | [diff] [blame] | 56 | sed -i -e 's/\/bin\/compiler/\/bin\/ttcn3_compiler/' Makefile |
Stefan Sperling | 526895e | 2018-03-31 16:19:40 +0200 | [diff] [blame] | 57 | |
| 58 | if [ "x$USE_CCACHE" = "x1" ]; then |
| 59 | # enable ccache |
| 60 | sed -i -e 's/^CXX = g++ $/CXX = env CCACHE_SLOPPINESS=time_macros ccache g++/' Makefile |
| 61 | # Append the -D option to compiler flags. This option disables timestamps |
| 62 | # inside comments in the generated C++ code which interfere with ccache. |
| 63 | sed -i -e 's/^COMPILER_FLAGS = \(.*\)/&-D/' Makefile |
| 64 | fi |