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

How to make build work on IBM i #1051

Closed
chrjorgensen opened this issue Nov 20, 2020 · 6 comments
Closed

How to make build work on IBM i #1051

chrjorgensen opened this issue Nov 20, 2020 · 6 comments

Comments

@chrjorgensen
Copy link
Contributor

chrjorgensen commented Nov 20, 2020

Hi.

I found this excellent tool and wanted to port it to IBM i. I'm a newbie in the make tools, but proceeded anyway...

I cloned this repository and followed the build instructions. There was a problem during the linking phase - the linker could not find "libutil_flock".

I could solve this problem by adding " -lutil" to the LDLIBS variable in config.make:

LDLIBS =  -lreadline -lncursesw -liconv -lncursesw -lutil

Now the compile worked and the tig utility was build and running.

I wanted to make the build work directly from the git repository, so I made a new file config.make-OS400 ("OS400" is reported by the uname command):

# Example configuration for IBM i ('uname -s' = OS400)
#
# Use libutil to find flock..

UTIL_LIB = $(shell test -e "/QOpenSys/pkgs/lib/libutil.so.2" && echo true)
HAS_UTIL = $(shell test -e "/QOpenSys/pkgs/lib/libutil.so" && echo true)

ifneq ($(UTIL_LIB),true)
$(error Please install the libutil2 package)
endif

ifneq ($(HAS_UTIL),true)
$(error Please install the libutil-devel package)
endif

TIG_LDLIBS += -lutil

# vim: ft=make:

It was my understanding, that the value of TIG_LDLIBS would be included in the final LDLIBS value for the linker - but it does not work...

My config.make-OS400 is definitely being called - it reports error messages if I remove the libraries tested for - but it does not set the final LDLIBS value.

What am I doing wrong? Please help - when I make it work, I will make a PR so tig can be build on IBM i directly from this repository.

Best regards,
Christian

@krobelus
Copy link
Contributor

That should work.. make sure the file is at contrib/config.make-OS400.

@chrjorgensen
Copy link
Contributor Author

The file was indeed at contrib/config.make-OS400 - but no the expected output.

Could be me doing something wrong - this is not my strongest field - so I started from scratch:

Clone the repository into new directory
Copy my file into contrib/config.make-OS400
Make new configuration:

make configure
./configure

I still do not see the expexted value in LDLIBS - "-lutil" is still missing in config.make:

LDLIBS =  -lreadline -lncursesw -liconv -lncursesw

The files config.make, config.log and config.status is attached if any help...

config.make
config.log
config.status

@krobelus
Copy link
Contributor

Turns out the problem is that config.make sets LDLIBS.
The Makefile sources that file, and subsequently the line
LDLIBS ?= $(TIG_NCURSES) $(TIG_LDLIBS) has no effect because LDBLIBS is already set.

It worked for me because i didn't run ./configure.
I'm pretty sure it will work for you if you just remove config.make and run make.

I don't see an obvious way to fix the autotools build, but it seems easier to not use it.

@chrjorgensen
Copy link
Contributor Author

chrjorgensen commented Nov 21, 2020

So the build system is apparently broken - no longer using values set by the config.make-$kernel files?

Omitting ./configure does not work on IBM i - IBM i can run AIX (UNIX) binaries due to its PASE environment, but PASE is only a runtime, not a full AIX with libraries for development. ./configure must be run after cloning this repository for the build to find the includes and libraries.

I fixed it by changing my contrib/config.make-OS400 to set its own TIG_variable

TIG_LDLIBS_IBMI = -lutil

and adding the following lines to Makefile

# Use additional libraries on IBM i
LDLIBS += $(TIG_LDLIBS_IBMI)

after calling the two make.config files.

Now I can run ./configure and still have the correct LDLIBS set. And then run the normal make and make install commands.

Any comments on this approach?

Best regards,
Christian

@koutcher
Copy link
Collaborator

You're supposed to choose between the original build system and autoconf. For example, config.make-Darwin defines everything you need to build Tig on macOS without having to run configure. If you don't want to add everything to config.make-OS400 (or just can't because of systems variability), then it would be best to teach autoconf to add -lutil when needed rather than adding config.make-OS400:

--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,13 @@ AX_LIB_READLINE(6.3)
 
 AM_ICONV
 
+dnl OS-specific
+case $(uname -s 2>/dev/null || echo unknown) in
+OS400)
+    AC_CHECK_LIB(util, main, [LIBS="$LIBS -lutil"], AC_MSG_ERROR([Please install the libutil-devel package]))
+    ;;
+esac
+
 AC_CHECK_PROGS(SED, [gsed], [sed])
 AC_TDD_GCOV
 AC_SUBST(COVERAGE_CFLAGS)

@chrjorgensen
Copy link
Contributor Author

Ah, thanks for the tip, @koutcher - seems I have a lot to learn about build tools...!
Your solution is much more elegant, and I have incorporated it in configure.ac and will make a PR.

Thank you all for the help!

Best regards,
Christian

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

No branches or pull requests

3 participants