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