-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
90 lines (70 loc) · 2.38 KB
/
makefile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
###############################################################################
# #
# MAKEFILE for wctl2 #
# #
# (c) Guy Wilson 2023 #
# #
###############################################################################
# Version number for CCALC
MAJOR_VERSION = 2
MINOR_VERSION = 1
# Directories
SOURCE = src
BUILD = build
DEP = dep
# What is our target
TARGET = ccalc
# Tools
VBUILD = vbuild
C = gcc
CPP = g++
LINKER = g++
# postcompile step
PRECOMPILE = @ mkdir -p $(BUILD) $(DEP)
# postcompile step
POSTCOMPILE = @ mv -f $(DEP)/$*.Td $(DEP)/$*.d
CFLAGS_BASE=-c -Wall -pedantic
CFLAGS_REL=$(CFLAGS_BASE) -O2
CFLAGS_DBG=$(CFLAGS_BASE) -g
CPPFLAGS_BASE = -c -Wall -pedantic -std=c++17
CPPFLAGS_REL=$(CPPFLAGS_BASE) -O2
CPPFLAGS_DBG=$(CPPFLAGS_BASE) -g
CPPFLAGS=$(CPPFLAGS_REL)
CFLAGS=$(CFLAGS_REL)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEP)/$*.Td
# Libraries
STDLIBS =
EXTLIBS = -lreadline -lmpfr -lgmp
COMPILE.cpp = $(CPP) $(CPPFLAGS) $(DEPFLAGS) -o $@
COMPILE.c = $(C) $(CFLAGS) $(DEPFLAGS) -o $@
LINK.o = $(LINKER) $(STDLIBS) -o $@
CSRCFILES = $(wildcard $(SOURCE)/*.c)
CPPSRCFILES = $(wildcard $(SOURCE)/*.cpp)
OBJFILES = $(patsubst $(SOURCE)/%.c, $(BUILD)/%.o, $(CSRCFILES)) $(patsubst $(SOURCE)/%.cpp, $(BUILD)/%.o, $(CPPSRCFILES))
DEPFILES = $(patsubst $(SOURCE)/%.c, $(DEP)/%.d, $(CSRCFILES)) $(patsubst $(SOURCE)/%.cpp, $(DEP)/%.d, $(CPPSRCFILES))
all: $(TARGET)
# Compile C/C++ source files
#
$(TARGET): $(OBJFILES)
$(LINK.o) $^ $(EXTLIBS)
$(BUILD)/%.o: $(SOURCE)/%.c
$(BUILD)/%.o: $(SOURCE)/%.c $(DEP)/%.d
$(PRECOMPILE)
$(COMPILE.c) $<
$(POSTCOMPILE)
$(BUILD)/%.o: $(SOURCE)/%.cpp
$(BUILD)/%.o: $(SOURCE)/%.cpp $(DEP)/%.d
$(PRECOMPILE)
$(COMPILE.cpp) $<
$(POSTCOMPILE)
.PRECIOUS = $(DEP)/%.d
$(DEP)/%.d: ;
-include $(DEPFILES)
install: $(TARGET)
cp $(TARGET) /usr/local/bin
version:
$(VBUILD) -incfile ccalc.ver -template version.c.template -out $(SOURCE)/version.c -major $(MAJOR_VERSION) -minor $(MINOR_VERSION)
clean:
rm -r $(BUILD)
rm -r $(DEP)
rm $(TARGET)