File: Makefile

package info (click to toggle)
dynare 6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,796 kB
  • sloc: cpp: 79,110; ansic: 28,917; objc: 12,445; yacc: 4,537; pascal: 1,993; lex: 1,441; sh: 1,132; python: 634; makefile: 628; lisp: 163; xml: 18
file content (125 lines) | stat: -rw-r--r-- 4,357 bytes parent folder | download
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright © 2019-2025 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare.  If not, see <https://www.gnu.org/licenses/>.

include versions.mk

# settings for different architectures
DEPS_ARCH ?= x86_64 # use x86_64 by default

BREWDIR := $(if $(filter arm64,$(DEPS_ARCH)),/opt/homebrew,/usr/local)

GCC_VERSION = $(shell sed -En "/^c[[:space:]]*=/s/c[[:space:]]*=[[:space:]]*'.*gcc-([0-9]+)'/\1/p" ../homebrew-native-$(DEPS_ARCH).ini)

ROOT_PATH = $(realpath .)

WGET_OPTIONS := --no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error

NTHREADS=$(shell sysctl -n hw.perflevel0.physicalcpu)

.PHONY: all build build-slicot build-x13as \
	clean-lib clean-libslicot clean-x13as-bin \
	clean-src clean-slicot-src clean-x13as-src \
	clean-tar clean-slicot-tar clean-x13as-tar \
	clean-all clean-lib clean-src clean-tar

all: build

build: build-slicot build-x13as

clean-lib: clean-libslicot clean-x13as-bin

clean-src: clean-slicot-src clean-x13as-src

clean-tar: clean-slicot-tar clean-x13as-tar

clean-all: clean-lib clean-src clean-tar

#
# slicot
#
tarballs/slicot-$(SLICOT_VERSION).tar.gz:
	mkdir -p tarballs
	wget $(WGET_OPTIONS) -O $@ https://deb.debian.org/debian/pool/main/s/slicot/slicot_$(SLICOT_VERSION).orig.tar.gz

$(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION): tarballs/slicot-$(SLICOT_VERSION).tar.gz
	rm -rf $(DEPS_ARCH)/sources64/slicot-*
	mkdir -p $@
	tar xf $< --directory $@ --strip-components=1
	touch $@

$(DEPS_ARCH)/lib64/slicot/libslicot64_pic.a: $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)
	gmake -C $< FORTRAN=$(BREWDIR)/bin/gfortran LOADER=$(BREWDIR)/bin/gfortran SLICOTLIB=../libslicot64_pic.a OPTS="-O3 -fdefault-integer-8" lib -j$(NTHREADS)
	strip -S $</libslicot64_pic.a
	mkdir -p $(dir $@)
	cp $</libslicot64_pic.a $@

build-slicot: $(DEPS_ARCH)/lib64/slicot/libslicot64_pic.a

clean-slicot-tar:
	rm -f tarballs/slicot-$(SLICOT_VERSION).tar.gz

clean-slicot-src:
	rm -rf $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)

clean-libslicot:
	rm -rf $(DEPS_ARCH)/lib64/slicot

clean-slicot-all: clean-slicot-src clean-slicot-tar clean-libslicot



#
# X13AS
#
tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz:
	mkdir -p tarballs
	wget $(WGET_OPTIONS) -O $@ https://www.dynare.org/pkg-build/x13as/source/x13as_asciisrc-v$(X13AS_VERSION).tar.gz

$(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION): tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz
	rm -rf $(DEPS_ARCH)/sources64/x13as-*
	mkdir -p $@
	tar xf $< --directory $@

$(DEPS_ARCH)/lib64/x13as/x13as: $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION)
	# Statically link x13as (see #1865).
	# Using -static is not possible, it does not work under Darwin.
	# Implement an ugly workaround in the absence of -static-libquadmath flag.
	# In particular, gcc must be used as the linker, because gfortran does not
	# honour static linking of libquadmath.
	# Once the -static-libquadmath flag is added (GCC 13? ; see
	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539), go back to using
	# gfortran as the linker with -static-libgfortran and
	# -static-libquadmath flags, and drop the GCC_VERSION variable.
	cd $< && sed -i '' 's/-static//g' makefile.gf
	gmake -C $< -f makefile.gf FC=$(BREWDIR)/bin/gfortran LINKER=$(BREWDIR)/bin/gcc-$(GCC_VERSION) FFLAGS="-O3 -std=legacy" LDFLAGS=-static-libgcc LIBS="$(BREWDIR)/lib/gcc/$(GCC_VERSION)/libgfortran.a $(BREWDIR)/lib/gcc/$(GCC_VERSION)/libquadmath.a" PROGRAM=x13as -j$(NTHREADS)

	strip $</x13as
	mkdir -p $(dir $@)
	cp $</x13as $@

build-x13as: $(DEPS_ARCH)/lib64/x13as/x13as

clean-x13as-tar:
	rm -f tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz

clean-x13as-src:
	rm -rf $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION)

clean-x13as-bin:
	rm -rf $(DEPS_ARCH)/lib64/x13as

clean-x13as-all: clean-x13as-tar clean-x13as-src clean-x13as-bin