Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for BSD sed compatibility #56

Closed
wants to merge 1 commit into from
Closed

Conversation

hannesm
Copy link
Member

@hannesm hannesm commented May 21, 2019

sorry, I wasn't carefully trying #52 on BSD.

It turns out that the expression sed -e '1i (' (and a) does not work with BSD sed:

sed: 1: "1i (
": command i expects \ followed by text

I found some explanation here, using the proposed sed -e '1 i\'$'\n''('works in a shell, but via the Makefile leads to a leading $ on a Linux (debian) system -- it works fine on FreeBSD :/

Instead, we can use sed replacements (and shell invocation) as done in this PR, and provide the parens in the .in files.

(Another solution I came up with is another conditional in Makefile:

ifeq ($(BUILD_OS),Linux)
SED_POST=
else
SED_POST=\'$$'\n''
endif

and then sed -e '1 i$(SED_POST)(' in the rules, but IMHO that one is less readable than the provided diff).

@mato
Copy link
Contributor

mato commented May 22, 2019

Sorry, chaotic day today, I have to run and no time to open a PR, but how about this:

flags/libs: flags/libs.tmp Makeconf
	env PKG_CONFIG_PATH="$(shell opam config var prefix)/lib/pkgconfig" \
	    pkg-config $(PKG_CONFIG_DEPS) --libs >> $<
	awk -v RS= -- '{ \
	    sub("@@PKG_CONFIG_EXTRA_LIBS@@", "$(PKG_CONFIG_EXTRA_LIBS)", $$0); \
	    print "(", $$0, ")"\
	    }' $< >$@

#...

flags/cflags: flags/cflags.tmp Makeconf
	env PKG_CONFIG_PATH="$(shell opam config var prefix)/lib/pkgconfig" \
	    pkg-config $(PKG_CONFIG_DEPS) --cflags >> $<
	awk -v RS= -- '{ \
	    print "(", $$0, ")"\
	    }' $< >$@

Seems to do the trick for me, and the constructs work with both BSD awk and $RANDOM_LINUX awk. Also has the advantage of cleaning up newlines.

@mato
Copy link
Contributor

mato commented May 23, 2019

See #57

@mato mato closed this May 23, 2019
@hannesm hannesm deleted the bsd-sed branch May 25, 2019 19:29
@hannesm
Copy link
Member Author

hannesm commented May 25, 2019

thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants