public
Description: Io programming language
Homepage: http://iolanguage.com
Clone URL: git://github.com/stevedekorte/io.git
commit  c7b4b4f67ec7938749c08c496d93ad96a11269ce
tree    268a7d8ffb394fdc0ec07370396fcfac78947656
parent  fc7f575b7b3915e0858f12eb2cf131140d5424ef
io / Makefile.lib
100755 189 lines (153 sloc) 4.535 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
ifeq ($(shell [ -f Makefile.local ] && echo true),true)
ALL_BEGIN := $(MAKE) -f Makefile.local all_begin
ALL_END := $(MAKE) -f Makefile.local all_end
MAKE_LOCAL_CLEAN := $(MAKE) -f Makefile.local clean
else
ALL_BEGIN :=
ALL_END :=
MAKE_LOCAL_CLEAN :=
endif
 
#CC ?= g++
 
RANLIB ?= ranlib
AR ?= ar
ARFLAGS := rcu
AROUTFLAG :=
CCOUTFLAG := -o
LINKDLL := $(CC)
LINKDLLOUTFLAG := -o
LINKDIRFLAG := -L
LINKLIBFLAG := -l
 
# may need to remove --param max-inline-insns-single=500 for older versions of gccs
WARN :=-Wstrict-prototypes
#-Winline
#--param max-inline-insns-single=500
 
#-ansi -pedantic
OPTIMIZE :=-O3 -g
#-msse2 -msse -mmmx
#OPTIMIZE :=-O3 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=4
DLL_SUFFIX := so
DLL_COMMAND := -shared
FLAT_NAMESPACE :=
dependson := $(shell cat depends)
 
HEADERS :=-I. -I./source
others := $(dependson)
others := $(addprefix -I../,$(others))
others := $(addsuffix /_build/headers,$(others))
HEADERS += $(others)
 
DLL_L := $(dependson)
DLL_L := $(addprefix -L../,$(DLL_L))
DLL_L := $(addsuffix /_build/dll,$(DLL_L))
 
DLL_l := $(dependson)
DLL_l := $(addprefix -l,$(DLL_l))
 
CFLAGS = $(OPTIMIZE) $(WARN) $(HEADERS) #--param max-inline-insns-single=500
 
# Uncommment for Coros to register their stack with Valgrind
#CFLAGS += -DUSE_VALGRIND
 
### PLATFORM #####################################################
 
SYS ?= $(shell uname -s)
 
ifeq ($(SYS),Darwin)
CFLAGS += -falign-loops=16
CFLAGS += -fPIC
DLL_SUFFIX := dylib
DLL_COMMAND := -dynamiclib
FLAT_NAMESPACE := -flat_namespace
endif
 
ifeq ($(SYS),DragonFly)
LFLAGS += -lm
endif
 
ifeq ($(SYS),Linux)
CFLAGS += -falign-loops=16
CFLAGS += -fPIC
endif
 
ifeq ($(SYS),IRIX)
RANLIB ?= touch
endif
 
ifneq (,$(findstring CYGW,$(SYS)))
DLL_SUFFIX := dll
endif
 
ifneq (,$(findstring MINGW,$(SYS)))
DLL_SUFFIX := dll
endif
 
ifneq (,$(findstring Windows,$(SYS)))
CC := cl -nologo
CCOUTFLAG :=-Fo
WARN :=
#OPTIMIZE :=-Zi -MDd -D_USE_MATH_DEFINES -DWIN32 -D_DEBUG -D_CRT_SECURE_NO_DEPRECATE
OPTIMIZE :=-Zi -MD -D_USE_MATH_DEFINES -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE
AR := link -lib
AROUTFLAG :=-out:
ARFLAGS :=
LINKDLL := link
LINKDLLOUTFLAG :=-out:
LINKDIRFLAG := -libpath:
LINKLIBFLAG := lib
DLL_LIB_SUFFIX := .lib
DLL_COMMAND := -link /INCREMENTAL:NO -subsystem:WINDOWS -machine:X86 -DLL $(DEF_FILE)
DLL_SUFFIX := dll
DLL_EXTRAS := ws2_32.lib shell32.lib
FLAT_NAMESPACE :=
RANLIB := echo no ranlib
endif
 
### FILES #########################################################
 
NAME := $(notdir $(subst $() ,_,$(shell pwd)))
LIBR := _build/lib/lib$(NAME).a
DLL := _build/dll/lib$(NAME).$(DLL_SUFFIX)
infiles := $(wildcard source/*.c)
#infiles += $(wildcard *.S)
asmfiles := $(wildcard source/*.S)
hfiles := $(wildcard source/*.h)
objects := $(notdir $(infiles))
objects := $(basename $(objects))
objects := $(addsuffix .o,$(objects))
objects := $(addprefix _build/objs/,$(objects))
 
vmall_objects := $(notdir $(infiles))
vmall_objects := $(basename $(vmall_objects))
vmall_objects := $(addsuffix .o,$(vmall_objects))
vmall_objects := $(addprefix _build/vmall_objs/,$(vmall_objects))
 
 
DLL_L := $(dependson)
DLL_L := $(addprefix $(LINKDIRFLAG)../,$(DLL_L))
DLL_L := $(addsuffix /_build/dll,$(DLL_L))
 
DLL_l := $(dependson)
DLL_l := $(addprefix $(LINKLIBFLAG),$(DLL_l))
DLL_l := $(addsuffix $(DLL_LIB_SUFFIX),$(DLL_l))
 
DEF_FILE :=
 
### RULES ###########################################################
 
all:
  $(ALL_BEGIN)
  mkdir -p _build
  mkdir -p _build/objs
  mkdir -p _build/headers
  mkdir -p _build/lib
  mkdir -p _build/dll
  $(MAKE) $(LIBR)
  $(MAKE) $(DLL)
ifneq (,$(findstring Windows,$(SYS)))
  mkdir -p _build/vmall_objs
  $(MAKE) vmall_objs
endif
ifneq (,$(hfiles))
  cp $(hfiles) _build/headers
endif
  $(ALL_END)
 
_build/objs/%.o: source/%.c
  $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) -c $< $(CCOUTFLAG)$@
 
_build/vmall_objs/%.o: source/%.c
  $(CC) -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" $(CFLAGS) \
        -DBUILDING_IOVMALL_DLL -c $< $(CCOUTFLAG)$@
 
 
_build/vmall_objs:
  mkdir -p $@
 
vmall_objs: _build/vmall_objs $(vmall_objects)
 
$(LIBR): $(objects)
ifneq ($(asmfiles),)
  $(CC) $(CFLAGS) -c $(asmfiles) $(CCOUTFLAG)_build/objs/asm.o || true
endif
  $(AR) $(ARFLAGS) $(AROUTFLAG)$@ _build/objs/*.o
  $(RANLIB) $@
 
$(DLL): $(objects)
  $(LINKDLL) $(DLL_COMMAND) $(FLAT_NAMESPACE) $(DLL_L) _build/objs/*.o $(LINKDLLOUTFLAG)$(DLL) $(DLL_l) $(DLL_EXTRAS)
ifneq (,$(findstring Windows,$(SYS)))
  mt.exe -manifest $@.manifest -outputresource:$@
  rm $@.manifest
endif
 
clean:
  rm -rf _build
  $(MAKE_LOCAL_CLEAN)