-
Notifications
You must be signed in to change notification settings - Fork 8
/
makefile
136 lines (98 loc) · 3.37 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#####
# Copyright (c) 2018 Y Paritcher
#####
PREFIX=$$HOME/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-
PREFIXKT4=arm-kindlepw2-linux-gnueabi-
CC=gcc
AR=ar
RANLIB=ranlib
CFLAGS=-Wall -Wextra -Wno-format-truncation -O2 -flto -pedantic $(INC_DIR:%=-I%)
LDLIBS=-lm
INC_DIR = include
STATICDIR=build/static
SHAREDDIR=build/shared
LIBDIR=lib
SRCDIR=src/
EXTRADIR=extra/
FFIDIR=ffi-cdecl/
LUADIR=lua/
PYTHONDIR=python/
sharedobjects := $(patsubst $(SRCDIR)%.c,$(SHAREDDIR)/%.o,$(wildcard $(SRCDIR)*.c))
staticobjects := $(patsubst $(SRCDIR)%.c,$(STATICDIR)/%.o,$(wildcard $(SRCDIR)*.c))
extraexecs := $(patsubst %.c, %, $(wildcard $(EXTRADIR)*.c))
fficdefs := $(LUADIR)libzmanim.lua $(PYTHONDIR)libzmanim_cdef.py
TESTDIR=test/
TESTLDFLAGS=-L$(LIBDIR)
TESTLDLIBS=-lzmanim
TESTLDLIB=-l:libzmanim.a
testobjects := $(patsubst %.c,%.o,$(wildcard $(TESTDIR)*.c))
VPATH = src $(INC_DIR)
.PHONY: clean cleaner all shared static test directories teststatic testshared teststandard kindle KT4 fresh extra wasm rock ffi
all:
$(MAKE) directories
$(MAKE) shared static
$(MAKE) test extra
kindle: CC = $(PREFIX)gcc
kindle: AR = $(PREFIX)ar
kindle: RANLIB = $(PREFIX)ranlib
kindle: directories shared static test
KT4: CC = $(PREFIXKT4)gcc
KT4: AR = $(PREFIXKT4)gcc-ar
KT4: RANLIB = $(PREFIXKT4)gcc-ranlib
KT4: directories shared static test
rock: cleaner directories shared
wasm: CC = clang
wasm: CFLAGS= -DNOSTDLIB -Wall -Wextra --target=wasm32 -nostdlib -mmultivalue -Xclang -target-abi -Xclang experimental-mv -Wl,--no-entry -Wl,--export-all $(INC_DIR:%=-I%)
wasm: $(LIBDIR)/libzmanim.wasm
directories: | $(SHAREDDIR) $(STATICDIR) $(LIBDIR)
shared: $(LIBDIR)/libzmanim.so
static: $(LIBDIR)/libzmanim.a
test: teststatic testshared teststandard
teststatic: static $(TESTDIR)teststatic
testshared: shared $(TESTDIR)testshared
teststandard: static $(TESTDIR)test
$(LIBDIR):
mkdir -p $(LIBDIR)
$(STATICDIR):
mkdir -p $(STATICDIR)
$(SHAREDDIR):
mkdir -p $(SHAREDDIR)
$(LIBDIR)/libzmanim.so: $(sharedobjects)
$(CC) -shared $(LDFLAGS) $^ $(LDLIBS) -o $@
$(LIBDIR)/libzmanim.a: $(staticobjects)
$(AR) rc $@ $^
$(RANLIB) $@
$(LIBDIR)/libzmanim.wasm: $(wildcard $(SRCDIR)hebrewcalendar.c)
$(CC) $(CFLAGS) -o $@ $^
$(SHAREDDIR)/%.o: $(SRCDIR)%.c
$(CC) -fPIC -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(STATICDIR)/%.o: $(SRCDIR)%.c
$(CC) -static -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(TESTDIR)%.o: $(TESTDIR)%.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(TESTDIR)teststatic: $(testobjects)
$(CC) -static $(TESTLDFLAGS) $^ $(TESTLDLIBS) -lm -o $@
$(TESTDIR)testshared: $(testobjects)
$(CC) $(TESTLDFLAGS) $^ $(TESTLDLIBS) -o $@
$(TESTDIR)test: $(testobjects)
$(CC) $(TESTLDFLAGS) $^ $(TESTLDLIB) $(LDLIBS) -o $@
testobjects: shared static
extra: static $(extraexecs)
$(extraexecs): %: %.c
$(CC) $(CFLAGS) $(TESTLDFLAGS) $^ $(TESTLDLIB) $(LDLIBS) -o $@
install:
mkdir -p $(INST_LIBDIR)
cp lib/libzmanim.so $(INST_LIBDIR)
mkdir -p $(INST_LUADIR)
cp $(LUADIR)libzmanim.lua $(INST_LUADIR)
cp $(LUADIR)libzmanim_load.lua $(INST_LUADIR)
$(fficdefs): $(FFIDIR)libzmanim.c
CPPFLAGS="$(INC_DIR:%=-I%)" ffi-cdecl $(CC) $^ $@
ffi: $(fficdefs)
clean:
rm -f $(SHAREDDIR)/*.o $(STATICDIR)/*.o $(TESTDIR)test.o
cleaner: clean
rm -f $(LIBDIR)/libzmanim.so $(LIBDIR)/libzmanim.a $(TESTDIR)testshared $(TESTDIR)teststatic $(TESTDIR)test $(extraexecs) $(LIBDIR)/libzmanim.wasm $(fficdefs)
fresh:
$(MAKE) cleaner
$(MAKE) all