-
Notifications
You must be signed in to change notification settings - Fork 629
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
Fixed build script for BSD systems #1554
Conversation
In autogen.sh, don't assume that the correct Makefile interpreter is `make`. The syntax of the Makefile generated by autotools is not compatible with BSD Make, and must be built with GNU Make (gmake) instead. In addition to detecting BSD platforms (via uname) and using gmake instead of make, autogen.sh also generates a BSDmakefile in the top-level directory. In its presence, BSD Make will use it instead of a generic Makefile, and BSD users will be informed that they should use gmake instead of make to buil the project. Tested on FreeBSD.
There are no other issues building on FreeBSD. With this patch, I'm able to build it simply by executing |
Thank you. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax of the Makefile generated by autotools is not compatible with BSD Make
Actually the Makefiles generated by Autotools are portable, but the custom rules we have (especially for the tests) are not, and use quite a few GNU Make extensions indeed.
else | ||
#return false | ||
return 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be simplified a lot with
is_bsd() {
uname | grep -i bsd >/dev/null
}
ctags_files=`make -f makefiles/list-translator-input.mak --no-print-directory` | ||
gen_bsdmakefile() { | ||
set +xe | ||
echo -e '.DONE:\n\t@echo "Please use GNU Make (gmake) to build this project"\n.DEFAULT:\n\t@echo "Please use GNU Make (gmake) to build this project"' > BSDmakefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you generate the 2 rules at once? like
.DONE .DEFAULT:
@echo "Please use GNU Make (gmake) to build this project"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, would it be handy to forward the call to GNU Make automatically? If
.DONE .DEFAULT:
@echo "Please use GNU Make (gmake) to build this project"
make $@
is enough it seems handy. OK, maybe it's trickier because we'd like to forward some of the MAKEFLAGS
but they are not all compatible between GNU and BSD make (e.g. I know NetBSD make adds a -J
option GNU make doesn't understand to MAKEFLAGS
when the user uses -j
). Just a suggestion in case it wasn't already considered.
@@ -5,7 +5,31 @@ set -xe | |||
type autoreconf || exit 1 | |||
type pkg-config || exit 1 | |||
|
|||
ctags_files=`make -f makefiles/list-translator-input.mak --no-print-directory` | |||
gen_bsdmakefile() { | |||
set +xe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why changing those shell options? What is supposed to be the problem with e
here, and why disabling x
?
This is a BSD Makefile that will I think call GNU Make successfully for most cases: JARG=
.if "$(.MAKE.JOBS)" != ""
JARG = -j$(.MAKE.JOBS)
.endif
.DONE .DEFAULT:
gmake $(.TARGETS:S,.DONE,,) $(JARG) I was trying to avoid being too smart in my original PR. |
Why not fix the build system to not rely on GNU-make-isms? Doesn't it sort of defeat the purpose of Automake? |
Is there any CI service like travis to for testing ctags on FreeBSD? |
@codebrainz I suppose it depends on how much time one has on their hands for such an undertaking. The differences between posix Make and GNU Make are many, and sticking to the former means having to give up a lot of the things that make GNU Make easy to code in. At the end of the day, it's quite easy to say how ctags should build on all platforms in theory, but it's another to pull it off in practice. This PR was just to introduce a quick and painless fix; if someone wants to reject this 24-line patch that improves the build experience on FreeBSD in favor of a potentially massive undertaking in overhauling the existing build scripts to be properly platform agnostic, honestly, more power to them. Keep in mind that autotools, like every other GNU project, doesn't really treat non-GUN platforms and toolchains as first-class citizens and can't be guaranteed to "just work." See the OpenBSD documentation on autotools:
|
It should "just work" if there aren't any GNU Make-isms in the Makefile.am files. It even has options which will effectively guarantee this ( |
Ah, I didn't realize it doesn't use Automake, I only looked at the |
It used not to, but now it does, and the makefile in question is a remainder from those earlier times. We probably should replace these sub-makefiles with just Anyway, the issue at hand: yes, Autotools generate portable makefiles, but we have quite a lot of rules that are written in GNU Make. I'm not sure how easy it'd be to make them portable, but it doesn't look totally straightforward.
If it risks too much not working perfectly, you original mere warning seems good enough to me as well. |
The |
I found "bmake", As @codebrainz, spotted, bamek reports an error at setting TIMEOUT in makefiles/testing.mak when I run "bmake all". TIMEOUT is set to 10 when make command finds that timeout command is available. It is obvious this existence checking is done in configure. The change will not be so big. @mqudsi, on your FreeBSD environment, doen "make all" fail? I'm thinking about using bmake for doing CI on circleci where Fedora runs. |
@mqudsi, could you try the latest code? I removed lines depending on GNU make. |
|
Removing The only error from that output is this warning:
but that occurs with After |
This fixes the remaining BSD build issues after the recent bmake fixes were merged into master. Discussed in universal-ctags#1554. Closes universal-ctags#1554.
I believe that's because Automake ships with builtin rules/targets called |
@mqudsi, I have a question about bmake. I would like to use code-generators in ctags build-process as I have worked on #1847. I wrote in Makefile.am as follows.
GNU make works well with Makefile derrived from above Makefile.am. Do you have any idea for working around it? |
@masatake the .SUFFIXES: .c .ctags .peg
.ctags.c: $(OPTLIB2C) Makefile
$(optlib2c_verbose)$(OPTLIB2C) $< > $@
.peg.c: $(PACKCC) Makefile
$(packcc_verbose)$(PACKCC) $< (excuse any typos above) I have zero experience with automake syntax, but I imagine there's some sort of provision for conditionally emitting Makefile code, which you can predicate on the version of Make (or fall back to the OS you are compiling under) to choose between two blocks, one containing GMake-specific code and the other containing bmake-specific code. Alternatively, if you have access to the names of the files ahead of time then you can replace the suffix/pattern transformation with a (somehow dialect-agnostic) for loop, which I imagine is well-supported by automake. |
Suggested by @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@mqudsi, thank you very much. I already tried the same.
I think I cannot ask you to debug my code. So I would like to add GNU make as build-requirement of Universal-ctags. |
You swapped the order of the suffixes: it should be Also, it's not possible to add prerequisites to a suffix rule; for that @mqudsi's example is incorrect. You should have: SUFFIXES += .ctags
.ctags.c:
$(optlib2c_verbose)$(OPTLIB2C) $< > $@
$(OPTLIB2C_INPUT): $(OPTLIB2C) Makefile
SUFFIXES += .peg
.peg.c:
$(packcc_verbose)$(PACKCC) $<
$(PEG_INPUT): $(PACKCC) Makefile |
Suggested by @b4n and @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Suggested by @b4n and @mqudsi on universal-ctags#1554.
Suggested by @b4n and @mqudsi on universal-ctags#1554.
@b4n, it works! |
Suggested by @b4n and @mqudsi on universal-ctags#1554.
Suggested by @b4n and @mqudsi on universal-ctags#1554.
Suggested by @b4n and @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Suggested by @b4n and @mqudsi on universal-ctags#1554.
Suggested by @b4n and @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Packcc is a compiler-compiler; it translates .peg grammar file to .c file. packcc was originally written by Arihiro Yoshida. Its source repository is at sourceforge. It seems that packcc at sourceforge is not actively maintained. Some derived repositories are at github. Currently, our choice is https://github.com/enechaev/packcc. It is extended to support unicode. The source tree of packcc is grafted at misc/packcc directory. Building packcc and ctags are integrated in the build-scripts of Universal-ctags. If misc/packcc directory is empty, run following command to get source code before building ctags: ``` $ git submodule init misc/packcc $ git submodule update misc/packcc ``` About the suffix rule about .c and .peg, @b4n and @mqudsi help me on universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Suggested by @b4n and @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Suggested by @b4n and @mqudsi in universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Packcc is a compiler-compiler; it translates .peg grammar file to .c file. packcc was originally written by Arihiro Yoshida. Its source repository is at sourceforge. It seems that packcc at sourceforge is not actively maintained. Some derived repositories are at github. Currently, our choice is https://github.com/enechaev/packcc. It is extended to support unicode. The source tree of packcc is grafted at misc/packcc directory. Building packcc and ctags are integrated in the build-scripts of Universal-ctags. If misc/packcc directory is empty, run following command to get source code before building ctags: ``` $ git submodule init misc/packcc $ git submodule update misc/packcc ``` About the suffix rule about .c and .peg, @b4n and @mqudsi help me on universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Packcc is a compiler-compiler; it translates .peg grammar file to .c file. packcc was originally written by Arihiro Yoshida. Its source repository is at sourceforge. It seems that packcc at sourceforge is not actively maintained. Some derived repositories are at github. Currently, our choice is https://github.com/enechaev/packcc. It is extended to support unicode. The source tree of packcc is grafted at misc/packcc directory. Building packcc and ctags are integrated in the build-scripts of Universal-ctags. If misc/packcc directory is empty, run following command to get source code before building ctags: ``` $ git submodule init misc/packcc $ git submodule update misc/packcc ``` About the suffix rule about .c and .peg, @b4n and @mqudsi help me on universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Packcc is a compiler-compiler; it translates .peg grammar file to .c file. packcc was originally written by Arihiro Yoshida. Its source repository is at sourceforge. It seems that packcc at sourceforge is not actively maintained. Some derived repositories are at github. I put our version to https://github.com/universal-ctags/packcc, wihch was forked from https://github.com/enechaev/packcc. The reason I chose enechaev's repo is that the one was extended to support unicode. The source tree of packcc is grafted at misc/packcc directory. Building packcc and ctags are integrated in the build-scripts of Universal-ctags. If misc/packcc directory is empty, run following command to get source code before building ctags: ``` $ git submodule init misc/packcc $ git submodule update misc/packcc ``` About the suffix rule about .c and .peg, @b4n and @mqudsi help me on universal-ctags#1554. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
In autogen.sh, don't assume that the correct Makefile interpreter is
make
. The syntax of the Makefile generated by autotools is notcompatible with BSD Make, and must be built with GNU Make (gmake)
instead.
In addition to detecting BSD platforms (via uname) and using gmake
instead of make, autogen.sh also generates a BSDmakefile in the
top-level directory. In its presence, BSD Make will use it instead of a
generic Makefile, and BSD users will be informed that they should use
gmake instead of make to buil the project.
Tested on FreeBSD.