forked from sass/sassc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (128 loc) · 2.98 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
CC ?= gcc
CXX ?= g++
RM ?= rm -f
CP ?= cp -a
MKDIR ?= mkdir -p
WINDRES ?= windres
CFLAGS ?= -Wall -O2
CXXFLAGS ?= -Wall -O2
LDFLAGS ?= -Wall -O2
ifneq (,$(findstring /cygdrive/,$(PATH)))
UNAME := Cygwin
else
ifneq (,$(findstring WINDOWS,$(PATH)))
UNAME := Windows
else
ifneq (,$(findstring mingw32,$(MAKE)))
UNAME := MinGW
else
UNAME := $(shell uname -s)
endif
endif
endif
ifeq "$(SASSC_VERSION)" ""
ifneq "$(wildcard ./.git/ )" ""
SASSC_VERSION = $(shell git describe --abbrev=4 --dirty --always --tags)
endif
endif
ifneq "$(SASSC_VERSION)" ""
CFLAGS += -DSASSC_VERSION="\"$(SASSC_VERSION)\""
CXXFLAGS += -DSASSC_VERSION="\"$(SASSC_VERSION)\""
endif
# enable mandatory flag
ifeq (MinGW,$(UNAME))
CXXFLAGS += -std=gnu++0x
LDFLAGS += -std=gnu++0x
else
CXXFLAGS += -std=c++0x
LDFLAGS += -std=c++0x
endif
ifneq "$(SASS_LIBSASS_PATH)" ""
CFLAGS += -I $(SASS_LIBSASS_PATH)
CXXFLAGS += -I $(SASS_LIBSASS_PATH)
endif
ifneq "$(EXTRA_CFLAGS)" ""
CFLAGS += $(EXTRA_CFLAGS)
endif
ifneq "$(EXTRA_CXXFLAGS)" ""
CXXFLAGS += $(EXTRA_CXXFLAGS)
endif
ifneq "$(EXTRA_LDFLAGS)" ""
LDFLAGS += $(EXTRA_LDFLAGS)
endif
LDLIBS = -lstdc++ -lm
ifeq ($(UNAME),Darwin)
CFLAGS += -stdlib=libc++
CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif
ifneq ($(BUILD),shared)
BUILD = static
endif
SOURCES = sassc.c
LIB_STATIC = $(SASS_LIBSASS_PATH)/lib/libsass.a
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.so
ifeq (MinGW,$(UNAME))
ifeq (shared,$(BUILD))
CFLAGS += -D ADD_EXPORTS
CXXFLAGS += -D ADD_EXPORTS
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.dll
endif
else
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
endif
OBJECTS = $(SOURCES:.c=.o)
TARGET = bin/sassc
SPEC_PATH = $(SASS_SPEC_PATH)
ifeq (MinGW,$(UNAME))
TARGET = bin/sassc.exe
endif
ifeq (Windows,$(UNAME))
TARGET = bin/sassc.exe
endif
STATICFLAG=-static
ifeq (Darwin,$(UNAME))
STATICFLAG=
endif
all: libsass $(TARGET)
$(TARGET): build-$(BUILD)
build-static: $(OBJECTS) $(LIB_STATIC)
$(CC) $(STATICFLAG) $(LDFLAGS) -o $(TARGET) $^ $(LDLIBS)
build-shared: $(OBJECTS) $(LIB_SHARED)
$(CP) $(LIB_SHARED) bin/
$(CC) $(LDFLAGS) -o $(TARGET) $^ $(LDLIBS)
$(LIB_STATIC): libsass-static
$(LIB_SHARED): libsass-shared
libsass: libsass-$(BUILD)
libsass-static:
ifdef SASS_LIBSASS_PATH
BUILD="static" $(MAKE) -C $(SASS_LIBSASS_PATH)
else
$(error SASS_LIBSASS_PATH must be defined)
endif
libsass-shared:
ifdef SASS_LIBSASS_PATH
BUILD="shared" $(MAKE) -C $(SASS_LIBSASS_PATH)
else
$(error SASS_LIBSASS_PATH must be defined)
endif
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
test: all
bin/sassc -h
bin/sassc -v
specs: all
ifdef SASS_LIBSASS_PATH
$(MAKE) -C $(SASS_LIBSASS_PATH) test_build
else
$(error SASS_LIBSASS_PATH must be defined)
endif
clean:
rm -f $(OBJECTS) $(TARGET) bin/*.so bin/*.dll
ifdef SASS_LIBSASS_PATH
$(MAKE) -C $(SASS_LIBSASS_PATH) clean
endif
.PHONY: clean libsass libsass-static libsass-shared build-static build-shared test specs
.DELETE_ON_ERROR: