summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d21651d30dd88923964a5e482615f84b5fc84498 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Maintainer: Mirko Scholz <srtlg>
pkgname=gmat
pkgver=R2022a
pkgrel=2
pkgdesc="General Mission Analysis Tool: An open-source space mission analysis tool"
arch=('x86_64')
url="https://sourceforge.net/projects/gmat/"
license=('Apache')
conflicts=('gmat-bin')
makedepends=('cspice' 'cmake' 'swig' 'patchelf' 'f2c')
depends=('xerces-c' 'wxwidgets-gtk3-3.0>=3.0.5.1-2' 'glu')
source=("GMAT.in"
	"010-fix-f2c-typedefs.patch"
	"https://sourceforge.net/projects/gmat/files/GMAT/GMAT-${pkgver}/gmat-src_and_data-${pkgver}.zip")
sha256sums=('3d98cc2892c5b29cdf84a6d027842debfdb1a8472b0e67c7682c2ee24d4938ec'
            'd6971947454142b12ec8d4d237c6f33b348be424f758c2e5351b1a92d9e779dc'
            'b83cd0f052c74531c629be00404499fd003a4d3bca09b034f941ed6d55eae9dd')
options=(!strip)

prepare() {
	patch -d "GMAT-${pkgver}" -Np1 -i "${srcdir}/010-fix-f2c-typedefs.patch"
}

build() {
	env WX_CONFIG=/opt/wxgtk-3.0/bin/wx-config-gtk3 \
	    WXRC_CMD=/opt/wxgtk-3.0/bin/wxrc-3.0 \
	cmake -B build -S "GMAT-$pkgver" \
		-D CSPICE_DIR:PATH=/usr \
		-D F2C_DIR:PATH=/usr/include \
		-D CMAKE_THREAD_LIBS_INIT="-lpthread" \
		-D CMAKE_HAVE_THREADS_LIBRARY=1 \
		-D CMAKE_USE_PTHREADS_INIT=1 \
		-D CMAKE_INSTALL_PREFIX:PATH=/usr \
		-Wno-dev
	make -C build
}

package() {
	install -d -m755 "${pkgdir}/opt"
	cp -dr --no-preserve='ownership' "GMAT-${pkgver}/application" "${pkgdir}/opt/GMAT-${pkgver}"
	rm "${pkgdir}/opt/GMAT-${pkgver}/License.txt"
	rm "${pkgdir}/opt/GMAT-${pkgver}/README.txt"
	rm -rf "${pkgdir}/opt/GMAT-${pkgver}/matlab"
	find "${pkgdir}/opt/GMAT-${pkgver}" -name '*.m' -delete
	find "${pkgdir}/opt/GMAT-${pkgver}" -name '.git*' -delete

	install -d -m755 "${pkgdir}/usr/bin"
	<"${srcdir}/GMAT.in" sed -e "s|ROOT_PATH|/opt/GMAT-${pkgver}|g" -e "s|PKGVER|${pkgver}|g" > "${pkgdir}/usr/bin/GMAT"
	chmod 755 "${pkgdir}/usr/bin/GMAT"
	ln -s "/opt/GMAT-${pkgver}/bin/GmatConsole-${pkgver}" "${pkgdir}/usr/bin/GmatConsole"

	# startup file
	for i in gmat_startup_file.txt gmat_startup_file.public.txt gmat_startup_file_mac_linux.public.txt gmat_startup_file_mac_linux.txt
	do
		rm "${pkgdir}/opt/GMAT-${pkgver}/bin/$i"
	done
	<"GMAT-${pkgver}/application/bin/gmat_startup_file.public.txt" \
		  sed -e 's/^.*MATLAB_MODE\s*=\s*NO_MATLAB/MATLAB_MODE = NO_MATLAB/' \
		| sed -e 's/^.*WRITE_PERSONALIZATION_FILE.*/WRITE_PERSONALIZATION_FILE = OFF/' \
		| sed -e "s|ROOT_PATH\s*=.*|ROOT_PATH = /opt/GMAT-${pkgver}/|" \
		| sed -e "s|#\s*PLUGIN\s*=\s*../plugins/lib|PLUGIN = ../plugins/lib|" \
		| sed -e "/libMatlabInterface/ d" -e "/libFminconOptimizer/ d" \
		| sed -e "/libOpenFramesInterface/ d" \
		| sed -e "/libPythonInterface/ d" \
		| sed -e "/libExternalForceModel/ d" \
		| sed -e "s|../plugins/|/opt/GMAT-${pkgver}/plugins/|" \
		| sed -e "s|OUTPUT_PATH\s*=.*|OUTPUT_PATH = /tmp/|" \
	>"${pkgdir}/opt/GMAT-${pkgver}/bin/gmat_startup_file.txt"

	<"GMAT-${pkgver}/application/bin/GMAT.ini" \
		  sed -e "s|Sample Missions=../samples|Sample Missions=/opt/GMAT-${pkgver}/samples|" \
		| sed -e "s|http://gmat.sourceforge.net/docs/R2020a/|/opt/GMAT-R2020a/docs/help/|" \
	>"${pkgdir}/opt/GMAT-${pkgver}/bin/GMAT.ini"

	# RUNPATH
	patchelf --remove-rpath "${pkgdir}/opt/GMAT-${pkgver}/bin/libGmatUtil.so.${pkgver}"
	patchelf --set-rpath "/opt/GMAT-${pkgver}/bin" "${pkgdir}/opt/GMAT-${pkgver}/bin/GMAT-${pkgver}"
	patchelf --set-rpath "/opt/GMAT-${pkgver}/bin" "${pkgdir}/opt/GMAT-${pkgver}/bin/GmatConsole-${pkgver}"
	patchelf --set-rpath "/opt/GMAT-${pkgver}/bin" "${pkgdir}/opt/GMAT-${pkgver}/bin/libGmatBase.so.${pkgver}"
	for lib in ScriptTools ProductionPropagators Formation SaveCommand Station GmatFunction PolyhedronGravity \
	           DataInterface YukonOptimizer EphemPropagator EventLocator NewParameters GmatEstimation \
                   ExtraPropagators
	do
		patchelf --set-rpath "/opt/GMAT-${pkgver}/bin" "${pkgdir}/opt/GMAT-${pkgver}/plugins/lib${lib}.so.${pkgver}"
	done
	for lib in EKF ThrustFile
	do
		patchelf --set-rpath "/opt/GMAT-${pkgver}/bin:/opt/GMAT-${pkgver}/plugins" "${pkgdir}/opt/GMAT-${pkgver}/plugins/lib${lib}.so.${pkgver}"
	done
	for lib in TLEPropagator 
	do
		patchelf --set-rpath "/opt/GMAT-${pkgver}/bin:/opt/GMAT-${pkgver}/plugins" "${pkgdir}/opt/GMAT-${pkgver}/plugins/thinksys/lib${lib}.so.${pkgver}"
	done
}