-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (74 loc) · 2.67 KB
/
Makefile
File metadata and controls
87 lines (74 loc) · 2.67 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
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
DMD ?= ldmd2
VERSION ?= Linux_Musl
OS = linux
ARCH ?= X86_64
# Installation settings
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
DESTDIR ?=
# Cross-compiler tools (automatically set for AArch64)
.if ${ARCH} == aarch64
AS := aarch64-linux-gnu-as
CC := aarch64-linux-gnu-gcc
LD := aarch64-linux-gnu-ld
.else
AS ?= as
CC ?= gcc
LD ?= ld
.endif
# Set DMD flags based on architecture
.if ${ARCH} == aarch64
DMD_FLAGS = -mtriple=aarch64-linux-gnu
.elif ${ARCH} == X86_64
DMD_FLAGS ?= -m64
.endif
# Compiler-specific flags
.if ${DMD} == "dmd"
# DMD compiler - avoid standard library imports with -betterC and disable bounds checking
DMD_FLAGS += -noboundscheck
.else
# LDC compiler (default)
# DMD_FLAGS is set above based on ARCH
.endif
default: crt0.o
$(DMD) -fPIC -betterC -c -defaultlib= -conf= -version=$(VERSION) *.d -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -version=$(VERSION) exit/*.d -unittest -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -defaultlib= -conf= -version=$(VERSION) posix/*.d -unittest -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -defaultlib= -conf= -version=$(VERSION) posix/sys/*.d -unittest -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -version=$(VERSION) stdlib/abs.d -unittest -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -version=$(VERSION) prng/rand.d -unittest -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -defaultlib= -conf= -version=$(VERSION) stdio/*.d -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -defaultlib= -conf= -version=$(VERSION) sys/linux/*.d -op -debug $(DMD_FLAGS)
$(DMD) -fPIC -betterC -c -version=$(VERSION) string/*.d -op -debug $(DMD_FLAGS)
crt0.o: crt/$(OS)/$(ARCH)/crt0.s
${AS} -o crt0.o crt/$(OS)/$(ARCH)/crt0.s
libbutterc.so: default crt0.o
${LD} -o libbutterc.so \
*.o \
exit/*.o \
posix/*.o posix/sys/*.o \
prng/*.o \
stdio/*.o \
stdlib/*.o \
string/*.o \
sys/linux/*.o \
-shared
test: default crt0.o
$(DMD) -betterC -c -version=$(VERSION) tests/tests.d -op -debug $(DMD_FLAGS)
$(LD) -o tests.exe -static crt0.o stdio/printf.o string.o prng/rand.o stdarg.o exit/assert.o string/memcpy.o object.o posix/sys/writev.o tests/*.o #-macosx_version_min 10.7.0
./tests.exe
.PHONY: all test clean install uninstall
all: libbutterc.so
clean:
rm tests.exe || true
rm *.o */*.o */*/*.o || true
rm *.dylib || true
rm libbutterc.so || true
install: libbutterc.so
install -d "$(DESTDIR)$(LIBDIR)"
install -m 644 libbutterc.so "$(DESTDIR)$(LIBDIR)/"
@echo "Installed libbutterc.so to $(DESTDIR)$(LIBDIR)/"
@echo "Note: System-wide installation to /usr/local may require sudo"
uninstall:
rm -f "$(DESTDIR)$(LIBDIR)/libbutterc.so"
@echo "Uninstalled libbutterc.so from $(DESTDIR)$(LIBDIR)/"