Skip to content

Commit

Permalink
Makefile: make sed -i work on macOS
Browse files Browse the repository at this point in the history
As per https://stackoverflow.com/questions/17534840/sed-throws-bad-flag-in-substitute-command.

I hope this does not break sed -i use on other operating systems. I will revert the patch if it does and a separate logic will be needed to invoke sed -i differently on macOS.
  • Loading branch information
mmikaitis committed May 1, 2024
1 parent 5e4dc5a commit d5aba1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $(BUILDDIR)cpfloat.tmp: $(SRCDIR)cpfloat_binary32.h $(SRCDIR)cpfloat_binary64.h
$(SRCDIR)cpfloat_binary32.h > $(BUILDDIR)cpfloat.tmp
sed '/CPFLOAT_BINARY\|^#include "cpfloat_\(doc\|def\)/d' \
$(SRCDIR)cpfloat_binary64.h >> $(BUILDDIR)cpfloat.tmp
sed -i 's/static inline //g' $(BUILDDIR)cpfloat.tmp
sed -i '' 's/static inline //g' $(BUILDDIR)cpfloat.tmp

$(BUILDDIR)cpfloat_template.c: $(SRCDIR)cpfloat_template.h
sed 's/static inline//g' $< > $@
Expand All @@ -117,7 +117,7 @@ $(BUILDDIR)cpfloat.c: $(BUILDDIR)cpfloat.tmp $(BUILDDIR)cpfloat_template.c

$(INCDIR)cpfloat.h: $(BUILDDIR)cpfloat.tmp $(BUILDDIR) $(INCDIR)
sed '/^\/\*\* @/,/^\/\*\* @/d' $< > $(BUILDDIR)cpfloat-h.tmp
sed -i '/^ \*\|\/\*/d' $(BUILDDIR)cpfloat-h.tmp
sed -i '' '/^ \*\|\/\*/d' $(BUILDDIR)cpfloat-h.tmp
printf "/* SPDX-FileCopyrightText: 2020 Massimiliano Fasi and Mantas Mikaitis */\n\
/* SPDX-License-Identifier: LGPL-2.1-or-later */\n\
\n\
Expand Down Expand Up @@ -215,7 +215,7 @@ ctest: $(BINDIR)cpfloat_test

$(TESTDIR)libcpfloat_test.c: $(TESTDIR)cpfloat_test.c
sed '/#include "cpfloat_binary32.h"/d' $< > $@
sed -i 's/#include "cpfloat_binary64.h"/#include "cpfloat.h"/g' $@
sed -i '' 's/#include "cpfloat_binary64.h"/#include "cpfloat.h"/g' $@

$(BINDIR)libcpfloat_static_test: $(TESTDIR)libcpfloat_test.c lib
$(CC) $(CFLAGS) $(COPTIM) -fsanitize=undefined -static -o $@ $< \
Expand Down

0 comments on commit d5aba1b

Please sign in to comment.