From 72cc4d516b3ee2b5f9bcae67e0eaea3b794d88f9 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 27 Aug 2022 17:37:24 +0300 Subject: [PATCH] PORT: detect linux vs macOS shared object extension in Makefile --- .build.yml | 38 ++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + Makefile | 23 ++++++++++++++++++----- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .build.yml diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..c52b2d3 --- /dev/null +++ b/.build.yml @@ -0,0 +1,38 @@ +image: debian/stable +packages: + - build-essential + - cmake + - ninja-build + - pkg-config + - ncurses-dev + - libreadline-dev + - libedit-dev + - libgoogle-perftools-dev + - libgmp-dev + - libssl-dev + - unixodbc-dev + - zlib1g-dev + - libarchive-dev + - libossp-uuid-dev + - libxext-dev + - libice-dev + - libjpeg-dev + - libxinerama-dev + - libxft-dev + - libxpm-dev + - libxt-dev + - libdb-dev + - libpcre2-dev + - libyaml-dev + - zip + - git +secrets: + - 750079bb-9735-473b-bebf-db897c9f0c6b + - 72d5c3dc-f83f-4cc2-96e3-b2b08f6ee8a0 +sources: + - git@git.sr.ht:~eshel/sweep +tasks: + - build: | + cd sweep + make + make info diff --git a/.gitignore b/.gitignore index 4cd36b4..9f56ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /sweep.info /sweep.info~ /sweep.texi +/sweep.o diff --git a/Makefile b/Makefile index e8d6113..6704c7d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ CURRENT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) BASENAME = sweep + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SOEXT = so +endif +ifeq ($(UNAME_S),Darwin) + SOEXT = dylib +endif + SOEXT = dylib TARGET = $(BASENAME)-module.$(SOEXT) +OBJECT = $(BASENAME).o SOURCE = $(BASENAME).c LDFLAGS += -shared @@ -28,14 +38,17 @@ CMAKE_OPTIONS += -DSWIPL_INSTALL_IN_LIB=ON all: $(TARGET) -$(TARGET): $(SOURCE) swipl - $(CC) $(CFLAGS) -o $@ $(SOURCE) $(LDFLAGS) +$(OBJECT): $(SOURCE) lib/libswipl.$(SOEXT) + $(CC) $(CFLAGS) -o $@ -c $(SOURCE) + +$(TARGET): $(OBJECT) + $(CC) -o $@ $(OBJECT) $(LDFLAGS) clean: rm -rf bin lib share swipl/build - rm -f $(TARGET) $(BASENAME).info + rm -f $(TARGET) $(OBJECT) $(BASENAME).info -swipl: +lib/libswipl.$(SOEXT): cd swipl; \ rm -rf build; \ mkdir build; \ @@ -44,5 +57,5 @@ swipl: ninja; \ ninja install -$(BASENAME).info: +$(BASENAME).info:: README.org emacs -Q --batch --eval '(require (quote ox-texinfo))' --eval "(with-current-buffer (find-file \"README.org\") (org-export-to-file (quote texinfo) \"$@\" nil nil nil nil nil (quote org-texinfo-compile)))" -- 2.39.2