-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (34 loc) · 988 Bytes
/
Makefile
File metadata and controls
52 lines (34 loc) · 988 Bytes
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
SHELL := /bin/bash
CXX := g++
# set zig compiler
ZIG := zig-14
src := $(wildcard lib/*.c lib/*.cpp main.cpp)
obj := $(src:%.c=%.o)
obj := $(obj:%.cpp=%.o)
zig_obj := $(filter-out main.o, $(obj))
static_lib := libzig_static.a
LIB_STD_CPP := $(shell ldconfig -p | grep -m1 "libstdc++" | grep -o "/.*$$")
ifeq ("$(strip $(LIB_STD_CPP))", "")
$(error "Cannot find 'libstdc++' on your system 😔")
endif
debug:
@echo ${src}
@echo ${obj}
@echo $(zig_obj)
@echo ${LIB_STD_CPP}
@if [ -z "$(LIB_STD_CPP)" ]; then echo "No stdc++ lib"; else echo "Libstdc++ founded"; fi
%.o: %.c
$(CXX) -c $< -o $@
%.o: %.cpp
$(CXX) -c $< -o $@
main-cpp: $(obj)
$(CXX) $^ -o $@
$(static_lib): $(zig_obj)
ar rcs $@ $^
example-1: example_1.zig $(static_lib)
$(ZIG) build-exe $^ $(LIB_STD_CPP) --name $@ -lc++
example-2: example_2.zig $(static_lib)
$(ZIG) build-exe $^ $(LIB_STD_CPP) --name $@ -lc++ -I${PWD}/lib
all: main-cpp example-1 example-2
clean:
@rm $(obj) $(static_lib) *.o