summaryrefslogtreecommitdiff
path: root/zap/GNUmakefile
blob: c8993ff50f13a19b4ad4e942b1ac033fd2d3c957 (plain) (blame)
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
91
92
93
94
95
96
97
# Copyright 2022-2023 Gabriel Jensen.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.

ifeq "$(arch)" ""
arch := $(shell ../getarch.sh)
ifeq "$(arch)" "unknown"
$(error Unable to detect architecture!)
endif
$(info Detected architecture $(arch) !)
endif

OBJ_BS_TRAP        := source/any/bs/trap.o
OBJ_MATH_ABS       := source/any/math/abs.o
OBJ_MATH_DIV0      := source/any/math/div0.o
OBJ_MATH_DIVMOD    := source/any/math/divmod.o
OBJ_MATH_EXP       := source/any/math/exp.o
OBJ_MEM_CP         := source/any/mem/cp.o
OBJ_MEM_EQ         := source/any/mem/eq.o
OBJ_MEM_FILL       := source/any/mem/fill.o
OBJ_MEM_SRCH       := source/any/mem/srch.o
OBJ_MEM_UTF8DEC    := source/any/mem/utf8dec.o
OBJ_MEM_UTF8DECLEN := source/any/mem/utf8declen.o
OBJ_MEM_UTF8ENC    := source/any/mem/utf8enc.o
OBJ_MEM_UTF8ENCLEN := source/any/mem/utf8enclen.o
OBJ_MEM_WIN1252DEC := source/any/mem/win1252dec.o
OBJ_MEM_WIN1252ENC := source/any/mem/win1252enc.o

ifeq "$(arch)" "amd64"
OBJ_MATH_ABS       := source/$(arch)/math/abs.o
OBJ_MEM_CP         := source/$(arch)/mem/cp.o
else ifeq "$(arch)" "arm64"
OBJ_MATH_ABS       := source/$(arch)/math/abs
OBJ_MEM_CP         := source/$(arch)/mem/cp.o
endif

OBJS := \
	$(OBJ_BS_TRAP)        \
	$(OBJ_MATH_ABS)       \
	$(OBJ_MATH_DIV0)      \
	$(OBJ_MATH_DIVMOD)    \
	$(OBJ_MATH_EXP)       \
	$(OBJ_MEM_CP)         \
	$(OBJ_MEM_EQ)         \
	$(OBJ_MEM_FILL)       \
	$(OBJ_MEM_SRCH)       \
	$(OBJ_MEM_UTF8DEC)    \
	$(OBJ_MEM_UTF8DECLEN) \
	$(OBJ_MEM_UTF8ENC)    \
	$(OBJ_MEM_UTF8ENCLEN) \
	$(OBJ_MEM_WIN1252DEC) \
	$(OBJ_MEM_WIN1252ENC)

LIB := libzap.a

HDRS := \
	include/zap/bs.h   \
	include/zap/math.h \
	include/zap/mem.h

CFLAGS := \
	-Iinclude            \
	-Oz                  \
	-Wall                \
	-Wextra              \
	-Wpadded             \
	-Wpedantic           \
	-ffreestanding       \
	-fno-strict-aliasing \
	-fshort-enums        \
	-nostdlib            \
	-pipe                \
	-std=c99

ifeq "$(signaldiv0)" "true"
$(info signaldiv0 has been enabled! Remember to link with csys!)
CFLAGS := \
	$(CFLAGS) \
	-Dzap_priv_signaldiv0
endif

.PHONY: clean install purge

$(LIB): $(OBJS)
	$(AR) r $(@) $(^)

install: $(LIB)
	mkdir -pm755 "$(HDRDIR)/zap"
	mkdir -pm755 "$(LIBDIR)"
	install -m644 "include/zap/"*".h" "$(HDRDIR)/zap"
	install -m755 "$(LIB)" "$(LIBDIR)"

clean:
	$(RM) $(OBJS)

purge: clean
	$(RM) $(LIB)