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

Library part6 #292

Merged
merged 25 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 00DIST
Original file line number Diff line number Diff line change
Expand Up @@ -5563,6 +5563,11 @@ Supplement Regenerated the 4.04 distribution to correct a non-

[aix] Suppress warnings properly on AIX version greater than
5.0. Closes #187.

Introduce alpha version of liblsof which allows users to use
lsof functionality via C functions instead of spawning a
subprocess and parsing the output. This version may contain BUGs
and memory leaks, and the API may change before it stablizes.

4.9?.? ????????? ??, ????

Expand Down
83 changes: 54 additions & 29 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
bin_PROGRAMS = lsof

# Documentation
EXTRA_DIST = 00.README.FIRST 00CREDITS 00DCACHE 00DIALECTS 00DIST 00FAQ 00LSOF-L 00MANIFEST 00PORTING 00QUICKSTART 00README 00TEST 00XCONFIG
# Testing
EXTRA_DIST += tests/00README tests/TestDB tests/CkTestDB tests/Makefile tests/LsofTest.h check.bash
# liblsof
lib_LTLIBRARIES = liblsof.la

# Dialect neutral sources
lsof_SOURCES = src/arg.c src/main.c lib/node.c src/print.c src/ptti.c src/store.c src/usage.c src/util.c \
lib/ckkv.c lib/cvfs.c lib/dvch.c lib/fino.c lib/lsof.c lib/isfn.c lib/lkud.c lib/misc.c lib/pdvn.c lib/prfp.c lib/print.c lib/proc.c lib/ptti.c lib/rdev.c lib/rnmt.c lib/rmnt.c lib/rnam.c lib/rnch.c lib/rnmh.c
lsof_SOURCES += lib/common.h include/lsof_fields.h lib/proto.h lib/hash.h src/cli.h
liblsof_la_SOURCES = lib/ckkv.c lib/cvfs.c lib/dvch.c lib/fino.c lib/isfn.c lib/lkud.c lib/lsof.c lib/misc.c lib/node.c lib/pdvn.c lib/prfp.c lib/print.c lib/proc.c lib/ptti.c lib/rdev.c lib/rnmt.c lib/rmnt.c lib/rnam.c lib/rnch.c lib/rnmh.c
liblsof_la_SOURCES += lib/common.h lib/proto.h lib/hash.h
include_HEADERS = include/lsof.h include/lsof_fields.h

# Hide internal functions
AM_CFLAGS = -fvisibility=hidden

DIALECT_ROOT = $(top_srcdir)/lib/dialects
DIALECT_PATH = $(DIALECT_ROOT)/$(LSOF_DIALECT_DIR)

# Dialect specific sources
if LINUX
lsof_SOURCES += lib/dialects/linux/dfile.c \
liblsof_la_SOURCES += lib/dialects/linux/dfile.c \
lib/dialects/linux/dmnt.c \
lib/dialects/linux/dnode.c \
lib/dialects/linux/dproc.c \
Expand All @@ -27,7 +25,7 @@ lsof_SOURCES += lib/dialects/linux/dfile.c \
endif

if DARWIN
lsof_SOURCES += lib/dialects/darwin/ddev.c \
liblsof_la_SOURCES += lib/dialects/darwin/ddev.c \
lib/dialects/darwin/dfile.c \
lib/dialects/darwin/dmnt.c \
lib/dialects/darwin/dproc.c \
Expand All @@ -39,7 +37,7 @@ lsof_SOURCES += lib/dialects/darwin/ddev.c \
endif

if FREEBSD
lsof_SOURCES += lib/dialects/freebsd/dmnt.c \
liblsof_la_SOURCES += lib/dialects/freebsd/dmnt.c \
lib/dialects/freebsd/dnode.c \
lib/dialects/freebsd/dproc.c \
lib/dialects/freebsd/dsock.c \
Expand All @@ -50,7 +48,7 @@ lsof_SOURCES += lib/dialects/freebsd/dmnt.c \
endif

if NETBSD
lsof_SOURCES += lib/dialects/netbsd/dmnt.c \
liblsof_la_SOURCES += lib/dialects/netbsd/dmnt.c \
lib/dialects/netbsd/dnode.c \
lib/dialects/netbsd/dproc.c \
lib/dialects/netbsd/dsock.c \
Expand All @@ -61,7 +59,7 @@ lsof_SOURCES += lib/dialects/netbsd/dmnt.c \
endif

if OPENBSD
lsof_SOURCES += lib/dialects/openbsd/dfile.c \
liblsof_la_SOURCES += lib/dialects/openbsd/dfile.c \
lib/dialects/openbsd/dmnt.c \
lib/dialects/openbsd/dnode.c \
lib/dialects/openbsd/dproc.c \
Expand All @@ -73,7 +71,7 @@ lsof_SOURCES += lib/dialects/openbsd/dfile.c \
endif

if SOLARIS
lsof_SOURCES += lib/dialects/sun/ddev.c \
liblsof_la_SOURCES += lib/dialects/sun/ddev.c \
lib/dialects/sun/dfile.c \
lib/dialects/sun/dmnt.c \
lib/dialects/sun/dnode.c \
Expand All @@ -86,7 +84,7 @@ lsof_SOURCES += lib/dialects/sun/ddev.c \
endif

if AIX
lsof_SOURCES += lib/dialects/aix/ddev.c \
liblsof_la_SOURCES += lib/dialects/aix/ddev.c \
lib/dialects/aix/dfile.c \
lib/dialects/aix/dmnt.c \
lib/dialects/aix/dnode.c \
Expand All @@ -99,22 +97,28 @@ lsof_SOURCES += lib/dialects/aix/ddev.c \
lib/dialects/aix/machine.h
endif

lsof_CPPFLAGS = -I$(DIALECT_PATH) -Iautotools -I$(top_srcdir)/lib -I$(top_srcdir)/include
lsof_CPPFLAGS += -DAUTOTOOLS
# Binary
bin_PROGRAMS = lsof

# Manpages
lsof.man: Lsof.8 version 00DIALECTS
soelim < Lsof.8 > $@
man8_MANS = lsof.man
EXTRA_DIST += Lsof.8
# Fix distcheck error
clean-local:
rm -rf lsof.man
distclean-local:
rm -rf lockf_owner.h lockf.h
lsof_SOURCES = src/arg.c src/main.c src/print.c src/ptti.c src/store.c src/usage.c src/util.c
lsof_SOURCES += src/cli.h

if LINUX
lsof_SOURCES += src/dialects/linux/dprint.c
endif
if DARWIN
lsof_SOURCES += src/dialects/darwin/dprint.c
endif
# TODO: link to dynamic library instead after internal functions are no longer used
lsof_SOURCES += $(liblsof_la_SOURCES)
#lsof_LDADD = liblsof.la

liblsof_la_CPPFLAGS = -I$(DIALECT_PATH) -Iautotools -DAUTOTOOLS -I$(top_srcdir)/lib -I$(top_srcdir)/include
lsof_CPPFLAGS = -I$(DIALECT_PATH) -Iautotools -DAUTOTOOLS -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir)/src

# Testing scripts
AM_TESTS_ENVIRONMENT = export LSOF_DIALECT_DIR=$(LSOF_DIALECT_DIR); export LSOF_DIALECT=$(LSOF_DIALECT);
EXTRA_DIST =
# Dialect neutral
DIALECT_NEUTRAL_TESTS = tests/case-00-hello.bash \
tests/case-01-version.bash \
Expand Down Expand Up @@ -193,3 +197,24 @@ tests_LTszoff_SOURCES = tests/LTszoff.c tests/LTlib.c
tests_LTszoff_CFLAGS = @LSOF_TEST_CFLAGS@ -I$(top_srcdir)/include
tests_LTunix_SOURCES = tests/LTunix.c tests/LTlib.c
tests_LTunix_CFLAGS = @LSOF_TEST_CFLAGS@ -I$(top_srcdir)/include

TESTS += tests/LTbasic2
check_PROGRAMS += tests/LTbasic2
tests_LTbasic2_CFLAGS = -I$(top_srcdir)/include
tests_LTbasic2_LDADD = liblsof.la

# Documentation
EXTRA_DIST += 00.README.FIRST 00CREDITS 00DCACHE 00DIALECTS 00DIST 00FAQ 00LSOF-L 00MANIFEST 00PORTING 00QUICKSTART 00README 00TEST 00XCONFIG
# Testing
EXTRA_DIST += tests/00README tests/TestDB tests/CkTestDB tests/Makefile tests/LsofTest.h check.bash

# Manpages
lsof.man: Lsof.8 version 00DIALECTS
soelim < Lsof.8 > $@
man8_MANS = lsof.man
EXTRA_DIST += Lsof.8
# Fix distcheck error
clean-local:
rm -rf lsof.man
distclean-local:
rm -rf lockf_owner.h lockf.h
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AC_INIT([lsof],[4.98.0])
AM_INIT_AUTOMAKE([subdir-objects])
LT_INIT([disable-fast-install]) # avoid lt-lsof naming
# Locate custom m4 macros
AC_CONFIG_MACRO_DIR([m4])

Expand Down Expand Up @@ -247,6 +248,10 @@ CFLAGS="$CFLAGS -DLSOF_VSTR=\\\"$LSOF_TMP\\\""
AC_SUBST([LSOF_DIALECT])
AC_SUBST([LSOF_DIALECT_DIR])

# Export public function with default visibility
AC_DEFINE([API_EXPORT], [__attribute__ ((visibility ("default")))],
[Set visibility to default for exported API functions.])

# --enable-security to define HASSECURITY
AC_ARG_ENABLE(security, AS_HELP_STRING([--enable-security],
[allow only the root user to list all open files @<:@default=no@:>@]), [], [enable_security=no])
Expand Down
Loading