Makefile
8.27 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
OS ?= $(shell uname -s)
CC ?= gcc
CXX ?= g++
RM ?= rm -f
CP ?= cp -a
MKDIR ?= mkdir
RMDIR ?= rmdir
WINDRES ?= windres
# Solaris/Illumos flavors
# ginstall from coreutils
ifeq ($(OS),SunOS)
INSTALL ?= ginstall
endif
INSTALL ?= install
CFLAGS ?= -Wall
CXXFLAGS ?= -Wall
LDFLAGS ?= -Wall
ifeq "x$(COVERAGE)" "x"
CFLAGS += -O2
CXXFLAGS += -O2
LDFLAGS += -O2
else
CFLAGS += -O1 -fno-omit-frame-pointer
CXXFLAGS += -O1 -fno-omit-frame-pointer
LDFLAGS += -O1 -fno-omit-frame-pointer
endif
LDFLAGS += -Wl,-undefined,error
CAT ?= $(if $(filter $(OS),Windows_NT),type,cat)
ifneq (,$(findstring /cygdrive/,$(PATH)))
UNAME := Cygwin
else
ifneq (,$(findstring Windows_NT,$(OS)))
UNAME := Windows
else
ifneq (,$(findstring mingw32,$(MAKE)))
UNAME := Windows
else
ifneq (,$(findstring MINGW32,$(shell uname -s)))
UNAME = Windows
else
UNAME := $(shell uname -s)
endif
endif
endif
endif
ifeq ($(SASS_LIBSASS_PATH),)
SASS_LIBSASS_PATH = $(abspath $(CURDIR))
endif
ifeq ($(LIBSASS_VERSION),)
ifneq ($(wildcard ./.git/ ),)
LIBSASS_VERSION ?= $(shell git describe --abbrev=4 --dirty --always --tags)
endif
endif
ifeq ($(LIBSASS_VERSION),)
ifneq ($(wildcard VERSION),)
LIBSASS_VERSION ?= $(shell $(CAT) VERSION)
endif
endif
ifneq ($(LIBSASS_VERSION),)
CFLAGS += -DLIBSASS_VERSION="\"$(LIBSASS_VERSION)\""
CXXFLAGS += -DLIBSASS_VERSION="\"$(LIBSASS_VERSION)\""
endif
# enable mandatory flag
ifeq (Windows,$(UNAME))
ifneq ($(BUILD),shared)
STATIC_ALL ?= 1
endif
STATIC_LIBGCC ?= 1
STATIC_LIBSTDCPP ?= 1
CXXFLAGS += -std=gnu++0x
LDFLAGS += -std=gnu++0x
else
STATIC_ALL ?= 0
STATIC_LIBGCC ?= 0
STATIC_LIBSTDCPP ?= 0
CXXFLAGS += -std=c++0x
LDFLAGS += -std=c++0x
endif
ifneq ($(SASS_LIBSASS_PATH),)
CFLAGS += -I $(SASS_LIBSASS_PATH)/include
CXXFLAGS += -I $(SASS_LIBSASS_PATH)/include
else
# this is needed for mingw
CFLAGS += -I include
CXXFLAGS += -I include
endif
ifneq ($(EXTRA_CFLAGS),)
CFLAGS += $(EXTRA_CFLAGS)
endif
ifneq ($(EXTRA_CXXFLAGS),)
CXXFLAGS += $(EXTRA_CXXFLAGS)
endif
ifneq ($(EXTRA_LDFLAGS),)
LDFLAGS += $(EXTRA_LDFLAGS)
endif
LDLIBS = -lm
ifneq ($(BUILD),shared)
LDLIBS += -lstdc++
endif
# link statically into lib
# makes it a lot more portable
# increases size by about 50KB
ifeq ($(STATIC_ALL),1)
LDFLAGS += -static
endif
ifeq ($(STATIC_LIBGCC),1)
LDFLAGS += -static-libgcc
endif
ifeq ($(STATIC_LIBSTDCPP),1)
LDFLAGS += -static-libstdc++
endif
ifeq ($(UNAME),Darwin)
CFLAGS += -stdlib=libc++
CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif
ifneq (Windows,$(UNAME))
ifneq (FreeBSD,$(UNAME))
ifneq (OpenBSD,$(UNAME))
LDFLAGS += -ldl
LDLIBS += -ldl
endif
endif
endif
ifneq ($(BUILD),shared)
BUILD := static
endif
ifeq ($(DEBUG),1)
BUILD := debug-$(BUILD)
endif
ifeq (,$(TRAVIS_BUILD_DIR))
ifeq ($(OS),SunOS)
PREFIX ?= /opt/local
else
PREFIX ?= /usr/local
endif
else
PREFIX ?= $(TRAVIS_BUILD_DIR)
endif
SASS_SASSC_PATH ?= sassc
SASS_SPEC_PATH ?= sass-spec
SASS_SPEC_SPEC_DIR ?= spec
SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc
RUBY_BIN = ruby
LIB_STATIC = $(SASS_LIBSASS_PATH)/lib/libsass.a
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.so
ifeq (Windows,$(UNAME))
ifeq (shared,$(BUILD))
CFLAGS += -D ADD_EXPORTS
CXXFLAGS += -D ADD_EXPORTS
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.dll
endif
else
ifneq (Cygwin,$(UNAME))
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
endif
endif
ifeq (Windows,$(UNAME))
SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe
endif
include Makefile.conf
RESOURCES =
STATICLIB = lib/libsass.a
SHAREDLIB = lib/libsass.so
ifeq (Windows,$(UNAME))
RESOURCES += res/resource.rc
SHAREDLIB = lib/libsass.dll
ifeq (shared,$(BUILD))
CFLAGS += -D ADD_EXPORTS
CXXFLAGS += -D ADD_EXPORTS
endif
else
ifneq (Cygwin,$(UNAME))
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
endif
endif
OBJECTS = $(addprefix src/,$(SOURCES:.cpp=.o))
COBJECTS = $(addprefix src/,$(CSOURCES:.c=.o))
RCOBJECTS = $(RESOURCES:.rc=.o)
DEBUG_LVL ?= NONE
CLEANUPS ?=
CLEANUPS += $(RCOBJECTS)
CLEANUPS += $(COBJECTS)
CLEANUPS += $(OBJECTS)
CLEANUPS += $(LIBSASS_LIB)
all: $(BUILD)
debug: $(BUILD)
debug-static: LDFLAGS := -g $(filter-out -O2,$(LDFLAGS))
debug-static: CFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CFLAGS))
debug-static: CXXFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CXXFLAGS))
debug-static: static
debug-shared: LDFLAGS := -g $(filter-out -O2,$(LDFLAGS))
debug-shared: CFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CFLAGS))
debug-shared: CXXFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CXXFLAGS))
debug-shared: shared
lib:
$(MKDIR) lib
lib/libsass.a: lib $(COBJECTS) $(OBJECTS)
$(AR) rcvs $@ $(COBJECTS) $(OBJECTS)
lib/libsass.so: lib $(COBJECTS) $(OBJECTS)
$(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(LDLIBS)
lib/libsass.dll: lib $(COBJECTS) $(OBJECTS) $(RCOBJECTS)
$(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(RCOBJECTS) $(LDLIBS) -s -Wl,--subsystem,windows,--out-implib,lib/libsass.a
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.rc
$(WINDRES) -i $< -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
%: %.o static
$(CXX) $(CXXFLAGS) -o $@ $+ $(LDFLAGS) $(LDLIBS)
install: install-$(BUILD)
static: $(STATICLIB)
shared: $(SHAREDLIB)
$(DESTDIR)$(PREFIX):
$(MKDIR) $(DESTDIR)$(PREFIX)
$(DESTDIR)$(PREFIX)/lib: $(DESTDIR)$(PREFIX)
$(MKDIR) $(DESTDIR)$(PREFIX)/lib
$(DESTDIR)$(PREFIX)/include: $(DESTDIR)$(PREFIX)
$(MKDIR) $(DESTDIR)$(PREFIX)/include
$(DESTDIR)$(PREFIX)/include/sass: $(DESTDIR)$(PREFIX)/include
$(MKDIR) $(DESTDIR)$(PREFIX)/include/sass
$(DESTDIR)$(PREFIX)/include/%.h: include/%.h \
$(DESTDIR)$(PREFIX)/include \
$(DESTDIR)$(PREFIX)/include/sass
$(INSTALL) -v -m0644 "$<" "$@"
install-headers: $(DESTDIR)$(PREFIX)/include/sass.h \
$(DESTDIR)$(PREFIX)/include/sass2scss.h \
$(DESTDIR)$(PREFIX)/include/sass/base.h \
$(DESTDIR)$(PREFIX)/include/sass/version.h \
$(DESTDIR)$(PREFIX)/include/sass/values.h \
$(DESTDIR)$(PREFIX)/include/sass/context.h \
$(DESTDIR)$(PREFIX)/include/sass/functions.h
$(DESTDIR)$(PREFIX)/lib/%.a: lib/%.a \
$(DESTDIR)$(PREFIX)/lib
@$(INSTALL) -v -m0755 "$<" "$@"
$(DESTDIR)$(PREFIX)/lib/%.so: lib/%.so \
$(DESTDIR)$(PREFIX)/lib
@$(INSTALL) -v -m0755 "$<" "$@"
$(DESTDIR)$(PREFIX)/lib/%.dll: lib/%.dll \
$(DESTDIR)$(PREFIX)/lib
@$(INSTALL) -v -m0755 "$<" "$@"
install-static: $(DESTDIR)$(PREFIX)/lib/libsass.a
install-shared: $(DESTDIR)$(PREFIX)/lib/libsass.so \
install-headers
$(SASSC_BIN): $(BUILD)
$(MAKE) -C $(SASS_SASSC_PATH) build-$(BUILD)-dev
sassc: $(SASSC_BIN)
$(SASSC_BIN) -v
version: $(SASSC_BIN)
$(SASSC_BIN) -h
$(SASSC_BIN) -v
test: $(SASSC_BIN)
$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.5 -c $(SASSC_BIN) --impl libsass $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
test_build: $(SASSC_BIN)
$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.5 -c $(SASSC_BIN) --impl libsass $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
test_full: $(SASSC_BIN)
$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.5 -c $(SASSC_BIN) --impl libsass --run-todo $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
test_probe: $(SASSC_BIN)
$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.5 -c $(SASSC_BIN) --impl libsass --probe-todo $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
clean-objects: lib
-$(RM) lib/*.a lib/*.so lib/*.dll lib/*.la
-$(RMDIR) lib
clean: clean-objects
$(RM) $(CLEANUPS)
clean-all:
$(MAKE) -C $(SASS_SASSC_PATH) clean
lib-file: lib-file-$(BUILD)
lib-opts: lib-opts-$(BUILD)
lib-file-static:
@echo $(LIB_STATIC)
lib-file-shared:
@echo $(LIB_SHARED)
lib-opts-static:
@echo -L"$(SASS_LIBSASS_PATH)/lib"
lib-opts-shared:
@echo -L"$(SASS_LIBSASS_PATH)/lib -lsass"
.PHONY: all static shared sassc \
version install-headers \
clean clean-all clean-objects \
debug debug-static debug-shared \
install install-static install-shared \
lib-opts lib-opts-shared lib-opts-static \
lib-file lib-file-shared lib-file-static
.DELETE_ON_ERROR: