Skip to content

Commit be59f0c

Browse files
gunjjoshikgryte
andauthored
build: add recipes for installing fftpack
PR-URL: #11819 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 5f211ce commit be59f0c

6 files changed

Lines changed: 231 additions & 5 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ea0701a6bc256405b03975908a6a92d0ffecdd18579e8484b8d789c8bd561787

deps/test/fftpack/test_install.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
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+
19+
#include <stdio.h>
20+
#include <stdlib.h>
21+
22+
extern void rffti( int n, double *wsave );
23+
24+
int main( void ) {
25+
double wsave[ 2*8 + 15 ]; // 2*n + 15
26+
int n = 8;
27+
int i;
28+
29+
rffti( n, wsave );
30+
31+
printf( "rffti( %d, wsave )\n", n );
32+
for ( i = n; i < 2*n; i++ ) {
33+
printf( "wsave[%2d] = %f\n", i, wsave[i] );
34+
}
35+
printf( "\n" );
36+
}

tools/make/common.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,3 +688,14 @@ DEPS_CPPCHECK_BUILD_OUT ?= $(DEPS_BUILD_DIR)/cppcheck_$(deps_cppcheck_version_sl
688688

689689
# Host platform:
690690
DEPS_CPPCHECK_PLATFORM := $(shell command -v $(NODE) >/dev/null 2>&1 && $(NODE_HOST_PLATFORM))
691+
692+
# FFTPACK...
693+
694+
# Define the PFFFT version:
695+
DEPS_FFTPACK_VERSION ?= 1.1.0
696+
697+
# Generate a version slug:
698+
deps_fftpack_version_slug := $(subst .,_,$(DEPS_FFTPACK_VERSION))
699+
700+
# Define the output path when building FFTPACK:
701+
DEPS_FFTPACK_BUILD_OUT ?= $(DEPS_BUILD_DIR)/pffft-$(DEPS_FFTPACK_VERSION)

tools/make/lib/install/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ include $(TOOLS_MAKE_LIB_DIR)/install/cephes.mk
3939
include $(TOOLS_MAKE_LIB_DIR)/install/cppcheck.mk
4040
include $(TOOLS_MAKE_LIB_DIR)/install/electron.mk
4141
include $(TOOLS_MAKE_LIB_DIR)/install/emsdk.mk
42+
include $(TOOLS_MAKE_LIB_DIR)/install/fftpack.mk
4243
include $(TOOLS_MAKE_LIB_DIR)/install/llvm.mk
4344
include $(TOOLS_MAKE_LIB_DIR)/install/node.mk
4445
include $(TOOLS_MAKE_LIB_DIR)/install/openblas.mk
@@ -157,7 +158,7 @@ clean-deps-tests: clean-deps-openblas-tests
157158
# @example
158159
# make install-deps-dev
159160
#/
160-
install-deps-dev: install-deps-boost install-deps-cephes install-deps-cppcheck install-deps-python install-deps-r install-deps-shellcheck
161+
install-deps-dev: install-deps-boost install-deps-cephes install-deps-cppcheck install-deps-fftpack install-deps-python install-deps-r install-deps-shellcheck
161162

162163
.PHONY: install-deps-dev
163164

@@ -167,7 +168,7 @@ install-deps-dev: install-deps-boost install-deps-cephes install-deps-cppcheck i
167168
# @example
168169
# make clean-deps-dev
169170
#/
170-
clean-deps-dev: clean-deps-boost clean-deps-cephes clean-deps-cppcheck clean-deps-python clean-deps-r clean-deps-shellcheck
171+
clean-deps-dev: clean-deps-boost clean-deps-cephes clean-deps-cppcheck clean-deps-fftpack clean-deps-python clean-deps-r clean-deps-shellcheck
171172

172173
.PHONY: clean-deps-dev
173174

@@ -177,7 +178,7 @@ clean-deps-dev: clean-deps-boost clean-deps-cephes clean-deps-cppcheck clean-dep
177178
# @example
178179
# make clean-deps-dev-tests
179180
#/
180-
clean-deps-dev-tests: clean-deps-boost-tests clean-deps-cephes-tests clean-deps-cppcheck-tests clean-deps-shellcheck-tests
181+
clean-deps-dev-tests: clean-deps-boost-tests clean-deps-cephes-tests clean-deps-cppcheck-tests clean-deps-fftpack-tests clean-deps-shellcheck-tests
181182

182183
.PHONY: clean-deps-dev-tests
183184

tools/make/lib/install/fftpack.mk

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2026 The Stdlib Authors.
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+
19+
# VARIABLES #
20+
21+
# Define the download URL:
22+
DEPS_FFTPACK_URL ?= https://github.com/marton78/pffft/archive/refs/tags/v$(DEPS_FFTPACK_VERSION).tar.gz
23+
24+
# Determine the basename for the download:
25+
deps_fftpack_basename := pffft-$(DEPS_FFTPACK_VERSION).tar.gz
26+
27+
# Define the path to the file containing a checksum to verify a download:
28+
DEPS_FFTPACK_CHECKSUM ?= $(shell $(CAT) $(DEPS_CHECKSUMS_DIR)/$(subst .,_,$(subst -,_,$(deps_fftpack_basename)))/sha256)
29+
30+
# Define the output path when downloading:
31+
DEPS_FFTPACK_DOWNLOAD_OUT ?= $(DEPS_TMP_DIR)/$(deps_fftpack_basename)
32+
33+
# Define a list of source files:
34+
deps_fftpack_src := \
35+
src/fftpack.c
36+
37+
# Resolve a list of source files to absolute filepaths:
38+
DEPS_FFTPACK_SRC ?= $(addprefix $(DEPS_FFTPACK_BUILD_OUT)/,$(deps_fftpack_src))
39+
40+
# Define the path to the directory containing tests:
41+
DEPS_FFTPACK_TEST_DIR ?= $(DEPS_DIR)/test/fftpack
42+
43+
# Define the output directory path for compiled tests:
44+
DEPS_FFTPACK_TEST_OUT ?= $(DEPS_FFTPACK_TEST_DIR)/build
45+
46+
# Define the path to a test file for checking an installation:
47+
DEPS_FFTPACK_TEST_INSTALL ?= $(DEPS_FFTPACK_TEST_DIR)/test_install.c
48+
49+
# Define the output path for a test file:
50+
DEPS_FFTPACK_TEST_INSTALL_OUT ?= $(DEPS_FFTPACK_TEST_OUT)/test_install
51+
52+
53+
# RULES #
54+
55+
#/
56+
# Downloads an FFTPACK distribution.
57+
#
58+
# @private
59+
#/
60+
$(DEPS_FFTPACK_DOWNLOAD_OUT): | $(DEPS_TMP_DIR)
61+
$(QUIET) echo 'Downloading FFTPACK...' >&2
62+
$(QUIET) $(DEPS_DOWNLOAD_BIN) $(DEPS_FFTPACK_URL) $(DEPS_FFTPACK_DOWNLOAD_OUT)
63+
64+
#/
65+
# Extracts an FFTPACK gzipped tar archive.
66+
#
67+
# @private
68+
#/
69+
$(DEPS_FFTPACK_BUILD_OUT): $(DEPS_FFTPACK_DOWNLOAD_OUT) | $(DEPS_BUILD_DIR)
70+
$(QUIET) echo 'Extracting FFTPACK...' >&2
71+
$(QUIET) $(TAR) -zxf $(DEPS_FFTPACK_DOWNLOAD_OUT) -C $(DEPS_BUILD_DIR)
72+
73+
#/
74+
# Creates a directory for storing compiled tests.
75+
#
76+
# @private
77+
#/
78+
$(DEPS_FFTPACK_TEST_OUT):
79+
$(QUIET) $(MKDIR_RECURSIVE) $(DEPS_FFTPACK_TEST_OUT)
80+
81+
#/
82+
# Compiles a test file for testing an FFTPACK installation.
83+
#
84+
# @private
85+
#/
86+
$(DEPS_FFTPACK_TEST_INSTALL_OUT): $(DEPS_FFTPACK_BUILD_OUT) $(DEPS_FFTPACK_TEST_OUT)
87+
$(QUIET) $(CC) -I $(DEPS_FFTPACK_BUILD_OUT) $(DEPS_FFTPACK_TEST_INSTALL) $(DEPS_FFTPACK_SRC) -o $(DEPS_FFTPACK_TEST_INSTALL_OUT)
88+
89+
#/
90+
# Downloads an FFTPACK distribution.
91+
#
92+
# @private
93+
#
94+
# @example
95+
# make deps-download-fftpack
96+
#/
97+
deps-download-fftpack: $(DEPS_FFTPACK_DOWNLOAD_OUT)
98+
99+
.PHONY: deps-download-fftpack
100+
101+
#/
102+
# Verifies a downloaded FFTPACK distribution.
103+
#
104+
# @private
105+
#
106+
# @example
107+
# make deps-verify-fftpack
108+
#/
109+
deps-verify-fftpack: deps-download-fftpack
110+
$(QUIET) echo 'Verifying download...' >&2
111+
$(QUIET) $(DEPS_CHECKSUM_BIN) $(DEPS_FFTPACK_DOWNLOAD_OUT) $(DEPS_FFTPACK_CHECKSUM) >&2
112+
113+
.PHONY: deps-verify-fftpack
114+
115+
#/
116+
# Extracts a downloaded FFTPACK distribution.
117+
#
118+
# @private
119+
#
120+
# @example
121+
# make deps-extract-fftpack
122+
#/
123+
deps-extract-fftpack: $(DEPS_FFTPACK_BUILD_OUT)
124+
125+
.PHONY: deps-extract-fftpack
126+
127+
#/
128+
# Tests an installed FFTPACK distribution.
129+
#
130+
# @private
131+
#
132+
# @example
133+
# make deps-test-fftpack
134+
#/
135+
deps-test-fftpack: $(DEPS_FFTPACK_TEST_INSTALL_OUT)
136+
$(QUIET) echo 'Running tests...' >&2
137+
$(QUIET) $(DEPS_FFTPACK_TEST_INSTALL_OUT)
138+
$(QUIET) echo '' >&2
139+
$(QUIET) echo 'Success.' >&2
140+
141+
.PHONY: deps-test-fftpack
142+
143+
#/
144+
# Installs FFTPACK.
145+
#
146+
# @example
147+
# make install-deps-fftpack
148+
#/
149+
install-deps-fftpack: deps-download-fftpack deps-verify-fftpack deps-extract-fftpack deps-test-fftpack
150+
151+
.PHONY: install-deps-fftpack
152+
153+
#/
154+
# Removes an installed FFTPACK distribution.
155+
#
156+
# ## Notes
157+
#
158+
# - The rule does **not** remove an FFTPACK download (if one exists).
159+
#
160+
# @example
161+
# make clean-deps-fftpack
162+
#/
163+
clean-deps-fftpack: clean-deps-fftpack-tests
164+
$(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_FFTPACK_BUILD_OUT)
165+
166+
.PHONY: clean-deps-fftpack
167+
168+
#/
169+
# Removes compiled FFTPACK installation tests.
170+
#
171+
# @example
172+
# make clean-deps-fftpack-tests
173+
#/
174+
clean-deps-fftpack-tests:
175+
$(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_FFTPACK_TEST_OUT)
176+
177+
.PHONY: clean-deps-fftpack-tests

tools/make/lib/test-fixtures/c.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test-fixtures-c:
2828
echo "Generating test fixtures: $$file"; \
2929
cd `dirname $$file` && \
3030
$(MAKE) clean && \
31-
CEPHES="$(DEPS_CEPHES_BUILD_OUT)" CEPHES_SRC="$(DEPS_CEPHES_SRC)" $(MAKE) && \
31+
CEPHES="$(DEPS_CEPHES_BUILD_OUT)" CEPHES_SRC="$(DEPS_CEPHES_SRC)" FFTPACK_SRC="$(DEPS_FFTPACK_SRC)" $(MAKE) && \
3232
$(MAKE) run || exit 1; \
3333
done
3434

@@ -45,7 +45,7 @@ test-fixtures-c-files:
4545
echo "Generating test fixtures: $$file"; \
4646
cd `dirname $$file` && \
4747
$(MAKE) clean && \
48-
CEPHES="$(DEPS_CEPHES_BUILD_OUT)" CEPHES_SRC="$(DEPS_CEPHES_SRC)" $(MAKE) && \
48+
CEPHES="$(DEPS_CEPHES_BUILD_OUT)" CEPHES_SRC="$(DEPS_CEPHES_SRC)" FFTPACK_SRC="$(DEPS_FFTPACK_SRC)" $(MAKE) && \
4949
$(MAKE) run || exit 1; \
5050
done
5151

0 commit comments

Comments
 (0)