lsof-org / lsof

LiSt Open Files
https://lsof.readthedocs.io
Other
432 stars 107 forks source link

[BUG] It doesn't build from a cloned repo under Alpine Linux #283

Open x-yuri opened 1 year ago

x-yuri commented 1 year ago

Describe the bug It doesn't build, see below.

To Reproduce

$ docker run --rm -it alpine:3.17 sh
/ # apk add build-base git
/ # git clone https://github.com/lsof-org/lsof
/ # cd lsof

/lsof # ./Configure -n linux
./Configure: line 256: perl: not found
Testing C library type with cc ... done
The C library type is not glibc.
rm -f ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c dstore.c dzfs.h kernelbase.h machine.h machine.h.old new_machine.h __lseek.s Makefile Makefile.zfs ./tests/config.cflags
rm -f ./tests/config.cc ./tests/config.xobj ./tests/config.ldflags
Testing C library for localtime() and strftime(), using cc ... present
./Configure: line 4963: ./lib/dialects/linux/Mksrc: not found
Makefile and lib/Makefile created.
./tests/config.cc created
./tests/config.cflags created
./tests/config.ldflags created
./tests/config.xobj created

/lsof # make
(cd lib; make DEBUG="" CFGF="-DLINUXV=61012 -DHASIPv6 -DHASNORPC_H -DNEEDS_NETINET_TCPH -DHAS_DUP2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DHAS_STRFTIME -DLSOF_VSTR=\"6.1.12-arch1-1\"")
make[1]: Entering directory '/lsof/lib'
cc  -DLINUXV=61012 -DHASIPv6 -DHASNORPC_H -DNEEDS_NETINET_TCPH -DHAS_DUP2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DHAS_STRFTIME -DLSOF_VSTR="6.1.12-arch1-1"  -I.. -I../include -Idialects/linux    -c -o ckkv.o ckkv.c
cc  -DLINUXV=61012 -DHASIPv6 -DHASNORPC_H -DNEEDS_NETINET_TCPH -DHAS_DUP2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DHAS_STRFTIME -DLSOF_VSTR="6.1.12-arch1-1"  -I.. -I../include -Idialects/linux    -c -o cvfs.o cvfs.c
cvfs.c:42:10: fatal error: ../machine.h: No such file or directory
   42 | #include "../machine.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [<builtin>: cvfs.o] Error 1
make[1]: Leaving directory '/lsof/lib'
make: *** [Makefile:96: lib/liblsof.a] Error 2

Expected behavior It builds.

Program output See above.

Environment (please complete the following information):

Additional context The culprit. Was there a reason to switch to bash? Aside from switching back, you can use #!/usr/bin/env sh.

The workaround: install bash before building.

jiegec commented 1 year ago

sh might not support function in some places. I also suggest you to use the new build system based on autotools.