Skip to content

Commit

Permalink
Fix compilation on FreeBSD, OpenBSD and NetBSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
jweyrich committed Jan 31, 2017
1 parent e948f87 commit ccef80d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/libpe
Submodule libpe updated 1 files
+17 −15 Makefile
5 changes: 4 additions & 1 deletion src/Makefile
Expand Up @@ -151,7 +151,7 @@ $(pev_BUILDDIR)/%.o: %.c

install: installdirs
for prog in $(PROGS); do \
$(INSTALL_PROGRAM) $(pev_BUILDDIR)/$$prog $(DESTDIR)$(bindir); \
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) $(pev_BUILDDIR)/$$prog $(DESTDIR)$(bindir); \
$(CHK_FILE_EXISTS) $(MANDIR)/$$prog$(man1ext) && \
gzip -c -9 $(MANDIR)/$$prog$(man1ext) > $(DESTDIR)$(man1dir)/$$prog$(man1ext).gz || \
echo -n; \
Expand All @@ -160,6 +160,9 @@ install: installdirs
$(INSTALL_DATA) $(srcdir)/userdb.txt $(DESTDIR)$(SHAREDIR)
cd $(PLUGINS_DIR) && $(MAKE) $@

install-strip: INSTALL_FLAGS += -s
install-strip: install

installdirs:
@$(CHK_DIR_EXISTS) $(DESTDIR) || $(MKDIR) $(DESTDIR)
@$(CHK_DIR_EXISTS) $(DESTDIR)$(bindir) || $(MKDIR) $(DESTDIR)$(bindir)
Expand Down
6 changes: 1 addition & 5 deletions src/config.c
Expand Up @@ -40,11 +40,7 @@
#include <string.h>
#if defined(__linux__)
#include <linux/limits.h>
#elif defined(__NetBSD__)
#include <limits.h>
#elif defined(__APPLE__)
#include <sys/syslimits.h>
#elif defined(__CYGWIN__)
#elif defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
#include <limits.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/plugins.c
Expand Up @@ -167,7 +167,7 @@ int plugins_load_all_from_directory(const char *path) {
const char *filename = dir_entry->d_name;

// TODO(jweyrich): Use macro conditions for each system: .so, .dylib, .dll
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
const bool possible_plugin = utils_str_ends_with(filename, ".so") != 0;
#elif defined(__APPLE__)
const bool possible_plugin = utils_str_ends_with(filename, ".dylib") != 0;
Expand Down
19 changes: 14 additions & 5 deletions src/plugins/Makefile
Expand Up @@ -57,6 +57,12 @@ json: $(json_OBJS)
$(PLUGINS):
ifeq ($(PLATFORM_OS), Linux)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), NetBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), FreeBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), OpenBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), Darwin)
$(LINK) -headerpad_max_install_names -dynamiclib \
-undefined dynamic_lookup -fno-common \
Expand All @@ -77,11 +83,14 @@ clean:
###

install: installdirs
$(INSTALL_PROGRAM) -m 755 $(plugins_BUILDDIR)/$(csv_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) -m 755 $(plugins_BUILDDIR)/$(html_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) -m 755 $(plugins_BUILDDIR)/$(text_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) -m 755 $(plugins_BUILDDIR)/$(xml_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) -m 755 $(plugins_BUILDDIR)/$(json_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(csv_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(html_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(text_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(xml_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(json_LIBNAME).* $(DESTDIR)$(pluginsdir)

install-strip: INSTALL_FLAGS += -s
install-strip: install

installdirs:
@$(CHK_DIR_EXISTS) $(DESTDIR)$(pluginsdir) || $(MKDIR) $(DESTDIR)$(pluginsdir)
Expand Down

0 comments on commit ccef80d

Please sign in to comment.