diff --git a/.github/workflows/exe.yml b/.github/workflows/exe.yml new file mode 100644 index 0000000..d1b1f88 --- /dev/null +++ b/.github/workflows/exe.yml @@ -0,0 +1,46 @@ +name: Build exe and so + +on: + workflow_call: + inputs: + upload-artifact: + type: boolean + required: false + default: true + +jobs: + build_exe: + name: Build the executable file and shared library for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + + - name: Install X11 dependencies (macOS) + if: runner.os == 'macOS' + run: brew install libxpm # libx11 + + - name: install X11 dependencies (Linux) + if: ${{ runner.os == 'Linux' }} + run: | + sudo apt-get update + sudo apt install -y libx11-dev libxpm-dev x11proto-dev + + - uses: actions/checkout@v6 + with: + persist-credentials: false + + - run: make v v.so + + - name: Upload wheels + if: ${{ inputs.upload-artifact }} + uses: actions/upload-artifact@v6 + with: + path: | + ./v + ./v.so + name: v.${{ matrix.os }}.exe + if-no-files-found: error diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index da016eb..b32fbbc 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -6,3 +6,5 @@ on: jobs: wheels: uses: ./.github/workflows/wheels.yml + exe: + uses: ./.github/workflows/exe.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8c9808..d13935f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,38 +19,8 @@ jobs: ################################################################################################################################ build_exe: - name: Build the executable file and shared library for ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] + uses: ./.github/workflows/exe.yml - steps: - - - name: Install X11 dependencies (macOS) - if: runner.os == 'macOS' - run: brew install libx11 libxpm pkg-config - - - name: install X11 dependencies - if: ${{ runner.os == 'Linux' }} - run: | - sudo apt-get update - sudo apt install -y libx11-dev libxpm-dev x11proto-dev - - - uses: actions/checkout@v6 - with: - persist-credentials: false - - - run: make v v.so - - - uses: actions/upload-artifact@v6 - with: - path: | - ./v - ./v.so - name: v.${{ matrix.os }}.exe - if-no-files-found: error ################################################################################################################################ diff --git a/makefile b/makefile index 1578e53..e134b76 100644 --- a/makefile +++ b/makefile @@ -37,8 +37,16 @@ export VERSION_FLAGS=-DGIT_HASH="\"$(shell git rev-parse HEAD 2> /dev/null || ec -DBUILD_USER="\"$(USER)@$(HOSTNAME)\""\ -DBUILD_DIRECTORY="\"$(PWD)\"" +OS := $(shell uname) +ifeq ($(OS),Darwin) + SONAME := install_name,@rpath/ +else + SONAME := soname, +endif + +X11DIR= $(shell pkg-config --libs-only-L x11 xpm) # for macOS CFLAGS= -c -std=gnu11 $(OPT) $(GPROF) $(W) $(GDB) -OFLAGS= -lm $(GPROF) -lX11 -lXpm +OFLAGS= -lm $(GPROF) -lX11 -lXpm $(X11DIR) SRCDIR=src OBJDIR=obj @@ -46,6 +54,7 @@ PICDIR=obj-pic SRCDIRS=$(shell find $(SRCDIR) -type d) INCL=$(SRCDIRS:%=-I./%) +INCL+=$(shell pkg-config --cflags-only-I x11 xpm) # for macOS allsrc=$(shell find $(SRCDIR) -type f -name '*.c') allobj=$(allsrc:$(SRCDIR)/%.c=$(OBJDIR)/%.o) @@ -64,7 +73,7 @@ v : $(allobj) $(CC) $^ -o $@ $(OFLAGS) v.so: $(allpic) - $(CC) $^ -shared -Wl,-soname,$@ $(OFLAGS) -o $@ + $(CC) $^ -shared -Wl,-$(SONAME)$@ $(OFLAGS) -o $@ $(OBJDIR)/%.o : $(SRCDIR)/%.c $(CC) $(CFLAGS) $< -o $@ $(INCL) $(VERSION_FLAGS) -MMD -MT "$@ $(patsubst $(OBJDIR)%,$(PICDIR)%,$@)"