-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (40 loc) · 1.01 KB
/
Makefile
File metadata and controls
52 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Root Makefile for dev-handbook
CC := gcc
CFLAGS := -Wall -Wextra -Werror -g
# Typescript
TS := $(shell find . -type f -name '*.ts' ! -path './node_modules/*')
JS := $(TS:.ts=.js)
# C
SRC := $(shell find . -type f -name '*.c')
OUT := $(SRC:.c=.out)
.PHONY: all clean check ts c
# Default build target
all: c ts
# C Compilation
c: $(OUT)
# Pattern rule: build file.c into file.out
%.out: %.c
@echo "Compiling $< -> $@"
$(CC) $(CFLAGS) $< -o $@
# TypeScript Compilation
ts: $(JS)
%.js: %.ts
@echo "Transpiling $< -> $@"
tsc $<
check: all
@echo "Running compiled C examples..."
@for bin in $(OUT); do \
echo ">> $$bin"; \
./$$bin || echo "Error in $$bin"; \
done
@echo "Running compiled TypeScript examples..."
@for js in $(JS); do \
echo ">> $$js"; \
node $$js || echo "Error in $$js"; \
done
clean:
@echo "Cleaning up compiled files..."
find . -path ./node_modules -prune -o -type f \( -name '*.out' -o -name '*.js' \) -exec rm -f {} +
lint:
@echo "Linting TypeScript files..."
npx eslint '**/*.ts'