forked from sharow/libconcurrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
133 lines (104 loc) · 2.25 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
#
# libconcurrent
# Copyright (C) 2010-2014 MIURA Shirow (sharow)
#
CC=$(PREFIX)gcc
LD=$(PREFIX)ld
NASM=nasm
UNAME=uname
.SUFFIXES: .c .a .o .h .asm
.PHONY: clean help
.PHONY: examples test
.PHONY: install
.VPATH: ./ ./src ./src/arch/i386 ./src/arch/x86_64
VERSION=0.4.0
ifeq ($(ARCH),)
ARCH=$(shell $(UNAME) -m)
endif
ifeq ($(SYSTEM),)
SYSTEM=$(shell $(UNAME) -o)
endif
NASM_FLAGS=
ifeq ($(SYSTEM),Cygwin)
NASM_FLAGS+=-f win$(ARCH_BITS)
ifeq ($(ARCH),i686)
NASM_FLAGS+=--prefix _
endif
else ifeq ($(SYSTEM),Msys)
NASM_FLAGS+=-f win$(ARCH_BITS)
ifeq ($(ARCH),i686)
NASM_FLAGS+=--prefix _
endif
else ifeq ($(SYSTEM),GNU/Linux)
NASM_FLAGS+=-f elf$(ARCH_BITS)
else
NASM_FLAGS+=-f elf$(ARCH_BITS)
endif
AS=$(NASM)
ASFLAGS=$(NASM_FLAGS)
ifeq ($(ARCH),i686)
ARCH_BITS=32
else ifeq ($(ARCH),x86_64)
ARCH_BITS=64
else ifeq ($(ARCH),armv6l)
ARCH=arm
ARCH_BITS=32
AS=as
ASFLAGS=
else ifeq ($(ARCH),armv7l)
ARCH=arm
ARCH_BITS=32
AS=as
ASFLAGS=
else
ARCH_BITS=32
endif
CFLAGS+=-Wall
CFLAGS+=-std=c11
CFLAGS+=-Wstrict-aliasing
CFLAGS+=-fno-stack-protector # for Ubuntu gcc patch
ifeq ($(DEBUG),yes)
CFLAGS+=-DCONCURRENT_DEBUG
CFLAGS+=-g -ggdb
else
CFLAGS+=-O2
endif
LDFLAGS+=--version-exports-section="$(VERSION)"
TARGET=libconcurrent.a
INCDIR+=-I.
INCDIR+=-I./include
INCDIR+=-I./src
SOURCE_ARCH=src/arch/$(ARCH)/concurrent_arch.asm
OBJECT_ARCH=src/arch/$(ARCH)/concurrent_arch.o
SOURCE+=src/concurrent.c
OBJECT+=$(subst .c,.o, $(SOURCE))
OBJECT+=$(OBJECT_ARCH)
all: $(TARGET)
examples: $(TARGET)
make -C examples
test: $(TARGET)
make -C test
$(TARGET): $(OBJECT)
$(AR) crv $(TARGET) $(OBJECT)
help:
@echo "clean help examples test"
install: $(TARGET)
install -Dm644 libconcurrent.a $(DESTDIR)/usr/lib/libconcurrent.a
install -Dm644 include/concurrent/concurrent.h $(DESTDIR)/usr/include/concurrent/concurrent.h
install -Dm644 include/concurrent/shortname.h $(DESTDIR)/usr/include/concurrent/shortname.h
clean:
@make -C examples clean
@make -C test clean
@rm -f $(OBJECT)
@rm -f $(TARGET)
# suffix rule
.c.o:
$(CC) $(CFLAGS) $(DEFS) $(INCDIR) -c $< -o $@
.asm.o:
$(AS) $(ASFLAGS) $< -o $@
#depend
depend:
$(RM) -f depend.inc
$(CC) $(CFLAGS) $(INCDIR) -MM $(SOURCE) > depend.inc
concurrent_arch.o: concurrent_arch.asm
include depend.inc