Skip to content

Commit 68dfbdf

Browse files
authored
Merge pull request #23 from martin-g/better-makefile
Make use of `make`s implicit variables
2 parents 0347639 + 6feeeb3 commit 68dfbdf

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

.github/workflows/make.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
name: Seqfu-Make-Build
3+
4+
# Controls when the action will run.
5+
on:
6+
# Triggers the workflow on push or pull request events but only for the "main" branch
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
gcc-version: [10, 12]
22+
name: Build with make
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup nim
26+
uses: jiro4989/setup-nim-action@v1
27+
with:
28+
nim-version: 2.0.x
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Install dependencies
32+
run: sudo apt install -y zlib1g-dev gcc-${{ matrix.gcc-version }} g++-${{ matrix.gcc-version }}
33+
34+
# Build and demo overwriting some variables
35+
- name: Build
36+
run: make CC=gcc-${{ matrix.gcc-version }} CXX=g++-${{ matrix.gcc-version }} CFLAGS="-O2 -Wall" CXXFLAGS="-std=c++11 -O2 -Wall"
37+
38+
- name: Test
39+
run: make test
40+

Makefile

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ BIN=./bin
66
SCRIPTS=./scripts
77
SOURCE=./src
88
DATA=./data
9+
CC=gcc
10+
CFLAGS=-O3
11+
CXX=g++
12+
CXXFLAGS=-std=c++11 -O3
13+
LDLIBS=-lz
914
VERSION := $(shell grep version seqfu.nimble | grep -o "[0-9]\\+\.[0-9]\\+\.[0-9]\\+")
1015
NIMPARAM := --gc:orc -d:NimblePkgVersion=$(VERSION) -d:release --opt:speed
1116
TARGETS=$(BIN)/seqfu $(BIN)/fu-msa $(BIN)/fu-primers $(BIN)/dadaist2-mergeseqs $(BIN)/fu-shred $(BIN)/fu-homocomp $(BIN)/fu-multirelabel $(BIN)/fu-index $(BIN)/fu-cov $(BIN)/fu-16Sregion $(BIN)/fu-nanotags $(BIN)/fu-orf $(BIN)/fu-sw $(BIN)/fu-virfilter $(BIN)/fu-tabcheck $(BIN)/byteshift $(BIN)/SeqCountHelper $(BIN)/fu-secheck
@@ -15,7 +20,7 @@ all: $(TARGETS) $(PYTARGETS)
1520

1621
sources/: src/sfu.nim s
1722
mkdir -p sources
18-
nim c --cc:gcc $(NIMPARAM) --nimcache:sources/ --genScript ./src/sfu.nim
23+
nim c --cc:$(CC) $(NIMPARAM) --nimcache:sources/ --genScript ./src/sfu.nim
1924
bash test/convert.sh sources/compile_sfu.sh
2025

2126
src/deps.txt:
@@ -26,13 +31,13 @@ src/sfu.nim: ./src/fast*.nim ./src/*utils*.nim src/deps.txt seqfu.nimble
2631
touch $@
2732

2833
$(BIN)/byteshift: test/byte/shifter.c
29-
gcc -O3 -o $@ $<
34+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
3035

3136
$(BIN)/fu-secheck: test/byte/validate.c
32-
gcc -O3 -o $@ $< -lz
37+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
3338

3439
$(BIN)/SeqCountHelper: test/byte/count.cpp
35-
g++ -std=c++11 -O3 -o $@ $< -lz
40+
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
3641

3742
$(BIN)/fu-split: $(SCRIPTS)/fu-split
3843
chmod +x $(SCRIPTS)/fu-split

0 commit comments

Comments
 (0)