Debian Codegraph @

nall/Makefile

raw symbols SCIP
1 # Makefile
2 # author: byuu
3 # license: public domain
4
5 [A-Z] = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
6 [a-z] = a b c d e f g h i j k l m n o p q r s t u v w x y z
7 [0-9] = 0 1 2 3 4 5 6 7 8 9
8 [markup] = ` ~ ! @ \# $$ % ^ & * ( ) - _ = + [ { ] } \ | ; : ' " , < . > / ?
9 # Some editors need this for proper syntax highlighting: '
10 [all] = $([A-Z]) $([a-z]) $([0-9]) $([markup])
11 [space] :=
12 [space] +=
13
14 # platform detection
15 ifeq ($(platform),)
16 uname := $(shell uname -s)
17 ifeq ($(uname),)
18 platform := windows
19 else ifneq ($(findstring Windows,$(uname)),)
20 platform := windows
21 else ifneq ($(findstring CYGWIN,$(uname)),)
22 platform := windows
23 else ifneq ($(findstring MINGW,$(uname)),)
24 platform := windows
25 else ifneq ($(findstring Darwin,$(uname)),)
26 platform := macosx
27 else ifneq ($(findstring BSD,$(uname)),)
28 platform := bsd
29 else ifneq ($(findstring Haiku,$(uname)),)
30 platform := haiku
31 else
32 platform := linux
33 endif
34 endif
35
36 ifeq ($(platform),windows)
37 delete = del /F /Q $(subst /,\,$1)
38 else
39 delete = rm -f $1
40 endif
41
42 # compiler detection
43 ifeq ($(compiler),)
44 ifneq ($(CXX),)
45 compiler := $(CXX)
46 flags :=
47 link := $(LDFLAGS)
48 else ifeq ($(platform),windows)
49 compiler := g++
50 flags :=
51 link :=
52 else ifeq ($(platform),macosx)
53 compiler := clang++
54 flags := -w -stdlib=libc++
55 link := -lc++ -lobjc
56 else ifeq ($(platform),bsd)
57 compiler := clang++
58 flags := -w -I/usr/local/include
59 else
60 compiler := g++
61 flags :=
62 link := $(LDFLAGS)
63 endif
64
65 cflags := -x c -std=c99
66 objcflags := -x objective-c -std=c99
67 cppflags := -x c++ -std=c++11
68 objcppflags := -x objective-c++ -std=c++11
69 endif
70
71 # cross-compilation support
72 ifeq ($(arch),x86)
73 flags := -m32 $(flags)
74 link := -m32 $(link)
75 endif
76
77 ifeq ($(prefix),)
78 prefix := /usr/local
79 endif
80
81 # function rwildcard(directory, pattern)
82 rwildcard = \
83 $(strip \
84 $(filter $(if $2,$2,%), \
85 $(foreach f, \
86 $(wildcard $1*), \
87 $(eval t = $(call rwildcard,$f/)) \
88 $(if $t,$t,$f) \
89 ) \
90 ) \
91 )
92
93 # function strtr(source, from, to)
94 strtr = \
95 $(eval __temp := $1) \
96 $(strip \
97 $(foreach c, \
98 $(join $(addsuffix :,$2),$3), \
99 $(eval __temp := \
100 $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$(__temp)) \
101 ) \
102 ) \
103 $(__temp) \
104 )
105
106 # function strupper(source)
107 strupper = $(call strtr,$1,$([a-z]),$([A-Z]))
108
109 # function strlower(source)
110 strlower = $(call strtr,$1,$([A-Z]),$([a-z]))
111
112 # function strlen(source)
113 strlen = \
114 $(eval __temp := $(subst $([space]),_,$1)) \
115 $(words \
116 $(strip \
117 $(foreach c, \
118 $([all]), \
119 $(eval __temp := \
120 $(subst $c,$c ,$(__temp)) \
121 ) \
122 ) \
123 $(__temp) \
124 ) \
125 )
126
127 # function streq(source)
128 streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),,1)
129
130 # function strne(source)
131 strne = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),1,)