summaryrefslogtreecommitdiffstats
path: root/njs.spec
blob: 8afb2b4a1e4b785fb3ebc6e6bc6086adef8ae75b (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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# remirepo/fedora spec file for njs
#
# SPDX-FileCopyrightText:  Copyright 2023-2025 Remi Collet
# SPDX-License-Identifier: CECILL-2.1
# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
#
# Please, preserve the changelog entries
#

# to disable upstream test suite
%bcond_without      tests

# to disable QuickJS engine
%bcond_without      quickjs

# to enable WASM, require ONLINE build for sources download
%bcond_with         wasm

# See https://github.com/nginx/njs/tags
%global gh_owner    nginx
%global project     njs
%global gh_commit   fcb99b68f86a72c96e21b81b3b78251174dbd3bf
%global gh_short    %(c=%{gh_commit}; echo ${c:0:7})

# See https://github.com/bellard/quickjs/commits/master/
%global qjs_owner    bellard
%global qjs_project  quickjs
%global qjs_commit   19abf1888db5884a5758036ff6e7fa2b340acedc
%global qjs_short    %(c=%{qjs_commit}; echo ${c:0:7})
%global qjs_version  2025.04.26


Name:              %{project}
Summary:           NGINX JavaScript
Version:           0.9.0
Release:           1%{?dist}
License:           BSD-2-Clause AND MIT
URL:               https://github.com/%{gh_owner}/%{project}

Source0:           https://github.com/%{gh_owner}/%{project}/archive/%{gh_commit}/%{project}-%{version}-%{gh_short}.tar.gz
Source1:           https://github.com/%{qjs_owner}/%{qjs_project}/archive/%{qjs_commit}/%{qjs_project}-%{qjs_short}.tar.gz

BuildRequires:     make
BuildRequires:     gcc
BuildRequires:     openssl-devel
BuildRequires:     pcre2-devel
BuildRequires:     libxml2-devel
BuildRequires:     zlib-devel
# Only for command
BuildRequires:     libedit-devel
# For tests
BuildRequires:     expect

%if %{with quickjs}
Provides:          bundled(libquickjs) = %{qjs_version}
%endif


%description
NGINX JavaScript (njs).

njs is a subset of the JavaScript language that allows extending nginx
functionality. njs is created in compliance with ECMAScript 5.1 (strict mode)
with some ECMAScript 6 and later extensions. The compliance is still evolving.


%package -n libnjs-devel
Summary: libnjs development files
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: openssl-devel
Requires: pcre2-devel
Requires: libxml2-devel
Requires: zlib-devel

%description -n libnjs-devel
Library and include files required for libnjs.


%prep
%if %{with quickjs}
: RPM build with QuickJS
%setup -qn %{project}-%{gh_commit} -a1
mv %{qjs_project}-%{qjs_commit} quickjs

%else
: RPM build without QuickJS
%setup -qn %{project}-%{gh_commit}
%endif


%build
%if %{with quickjs}
pushd quickjs
CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" %make_build libquickjs.a
popd

./configure \
  --with-quickjs \
  --cc-opt="$RPM_OPT_FLAGS -Iquickjs" \
  --ld-opt="$RPM_LD_FLAGS -Lquickjs"

%else

./configure \
  --no-quickjs \
  --cc-opt="$RPM_OPT_FLAGS" \
  --ld-opt="$RPM_LD_FLAGS"

%endif

%make_build
make pc

# Fix pkgconfig
sed -e '/^prefix/s|=.*$|=%{_prefix}|' \
    -e '/^libdir/s|=.*$|=%{_libdir}|' \
    -e '/^Cflags/s|:.*$|: -I%{_includedir}/njs|' \
    build/njs.pc | tee build/njs.pcx


%install
: Library
install -dm 0755                %{buildroot}%{_includedir}/njs/
install -pm 0644 */njs*.h       %{buildroot}%{_includedir}/njs/
install -dm 0755                %{buildroot}%{_libdir}/pkgconfig
install -pm 0755 build/libnjs.a %{buildroot}%{_libdir}
install -pm 0755 build/njs.pcx  %{buildroot}%{_libdir}/pkgconfig/njs.pc

: Command
install -dm 0755                %{buildroot}%{_bindir}
install -pm 0755 build/njs      %{buildroot}%{_bindir}

%if %{with quickjs}
: QuickJS
install -pm 0755 quickjs/libquickjs.a %{buildroot}%{_libdir}
install -pm 0755 build/libqjs.a       %{buildroot}%{_libdir}
%endif


%if %{with tests}
%check
make test %{?_smp_mflags}
%endif


%files
%license LICENSE
%{_bindir}/njs

%files -n libnjs-devel
%license LICENSE
%doc CHANGES
%{_libdir}/libnjs.a
%{_includedir}/njs
%{_libdir}/pkgconfig/njs.pc
%if %{with quickjs}
%{_libdir}/libqjs.a
%{_libdir}/libquickjs.a
%endif


%changelog
* Tue May  6 2025 Remi Collet <remi@remirepo.net> - 0.9.0-1
- update to 0.9.0
- update bundled quickjs to 2025-04-26 release

* Tue Apr  8 2025 Remi Collet <remi@remirepo.net> - 0.8.10-1
- update to 0.8.10

* Fri Feb 14 2025 Remi Collet <remi@remirepo.net> - 0.8.9-2
- workaround build failure with GCC 15 reported as
  https://github.com/nginx/njs/issues/857

* Tue Jan 14 2025 Remi Collet <remi@remirepo.net> - 0.8.9-1
- update to 0.8.9

* Tue Dec 10 2024 Remi Collet <remi@remirepo.net> - 0.8.8-1
- update to 0.8.8
- re-license spec file to CECILL-2.1

* Tue Oct 22 2024 Remi Collet <remi@remirepo.net> - 0.8.7-1
- update to 0.8.7

* Wed Oct  2 2024 Remi Collet <remi@remirepo.net> - 0.8.6-2
- update to 0.8.6
- enable QuickJS engine

* Wed Jul  3 2024 Remi Collet <remi@remirepo.net> - 0.8.5-1
- update to 0.8.5

* Tue Apr 16 2024 Remi Collet <remi@remirepo.net> - 0.8.4-1
- update to 0.8.4
- report test failure with zlib-ng
  https://github.com/nginx/njs/issues/704

* Thu Feb  8 2024 Remi Collet <remi@remirepo.net> - 0.8.3-1
- update to 0.8.3

* Tue Dec 19 2023 Remi Collet <remi@remirepo.net> - 0.8.2-1
- initial package