GCC 14 has enabled various warnings as errors by default, e.g.
-Wimplicit-function-declaration. This causes the current feature
detection code for `open_memstream(3)` and `fmemopen(3)` to fail
with GCC 14.
This commit restores compatibility with GCC 14 in this regard.
Note that it may also be beneficial to pass a feature test macro
such as -D_POSIX_C_SOURCE. See the feature test macro requirements
for open_memstream(3)` and `fmemopen(3)`.
This is a follow up to https://github.com/justinethier/cyclone/pull/482#discussion_r758902860
The -I$(PREFIX)/include needs to be moved away from BASE_CFLAGS since,
otherwise, it will be added *before* ~cc-extra~ and thus (partially)
circumvent the changes from #482. Compare the following two Cyclone
invocations with/without this commit.
Without this commit:
$ ./cyclone -d -A . -A libs -COPT '-Iinclude' -CLNK '-L.' scheme/complex.sld
gcc scheme/complex.c […] -I/usr/include -Wl,--export-dynamic -Iinclude -L/usr/lib -c
With this commit applied:
$ ./cyclone -d -A . -A libs -COPT '-Iinclude' -CLNK '-L.' scheme/complex.sld
gcc scheme/complex.c […] -Wl,--export-dynamic -Iinclude -I/usr/include -c
In #482, I originally removed the -I$(PREFIX)/include from BASE_CFLAGS
entirely. However, back then I forgot to add $(COMP_INCDIRS) to CC_LIB
to account for that. By doing that, this should fix the error from
https://github.com/justinethier/cyclone/pull/482#discussion_r758902860
and align CC_LIB nicely with CC_PROG.
While at it, I also removed $(COMP_LIBDIRS) from CC_LIB, it shouldn't be
needed since the CC_LIB command compiles object files and doesn't do any
linking.
This commit separates include/library search directory options from
"normal" compiler/linker options and places options passed via the
`-COPT`/`-CLNK` command-line flags in-between. This allows overwriting
the default search paths, since contrary to all other options, the
search paths must be prepend for an -I/-L option to take precedence over
an existing one.
This should (hopefully) make it entirely unnecessary to ever build
Cyclone twice in order to have all changes in the current source tree
take effect.
Fixes#476
The conditional variable assignment operator in Makefiles (`?=`) will
only assign a value if its not defined yet. However, CFLAGS/LDFLAGS are
commonly defined as environment variables to pass custom compiler/linker
flags (e.g. `-Os`). Unfortunately, Cyclone adds mandatory compiler flags
(without which it doesn't compile) via the conditional variable
assignment operator which is incorrect as these flags will not be added
if CFLAGS/LDFLAGS is defined in the environment. This commit fixes this
issue by appending flags to CFLAGS/LDFLAGS instead of using the
conditional assignment operator.