-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
65 lines (46 loc) · 1.31 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
CC := gcc
RM := rm
CD := cd
MAKE := make
CFLAGS += -Wall -Wextra -fpic -O2 -fno-strict-aliasing -Wno-unused-parameter
SYS := $(shell gcc -dumpmachine)
LIBFFI_PATH := ./libs/libffi
ifeq ($(SYS), x86_64-w64-mingw32)
BUILDSYS := $(SYS)
else
BUILDSYS := $(shell bash $(LIBFFI_PATH)/config.guess)
endif
LIBFFI_PATH := $(LIBFFI_PATH)/$(BUILDSYS)
INCLUDES :=-I$(LIBFFI_PATH)/include
LIBS := -L$(LIBFFI_PATH)/.libs -lffi
ifneq (, $(findstring linux, $(SYS)))
SUFFIX := so
LDFLAGS := -shared
LIBS += -ldl
else ifneq (, $(findstring mingw, $(SYS)))
SUFFIX := dll
LDFLAGS := -mdll
else
$(error Unsupported build platform)
endif
ifndef GLOBALS_HOME
$(error Couldn't find GLOBALS_HOME)
endif
INCLUDES += -I${GLOBALS_HOME}/dev/cpp/include
CFLAGS += $(INCLUDES)
TESTSDIR := tests
.PHONY: all clean libffi libffi-clean
all: libcna.$(SUFFIX) $(TESTSDIR)/libtest.$(SUFFIX)
libffi:
cd libs/libffi && ./configure --build=$(BUILDSYS) --enable-shared=no && $(MAKE)
cna.o: cna.c storage.h
storage.o: storage.c storage.h
libcna.$(SUFFIX): cna.o storage.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(TESTSDIR)/teslib.o: $(TESTSDIR)/testlib.c
$(TESTSDIR)/libtest.$(SUFFIX): $(TESTSDIR)/testlib.o
$(CC) $(LDFLAGS) -o $@ $^
libffi-clean:
$(CD) libs/libffi && $(MAKE) clean
clean:
$(RM) *.$(SUFFIX) *.o $(TESTSDIR)/*.$(SUFFIX) $(TESTSDIR)/*.o