Blame Makefile

Packit Service 7770af
OS       ?= $(shell uname -s)
Packit Service 7770af
CC       ?= gcc
Packit Service 7770af
CXX      ?= g++
Packit Service 7770af
RM       ?= rm -f
Packit Service 7770af
CP       ?= cp -a
Packit Service 7770af
MKDIR    ?= mkdir
Packit Service 7770af
RMDIR    ?= rmdir
Packit Service 7770af
WINDRES  ?= windres
Packit Service 7770af
# Solaris/Illumos flavors
Packit Service 7770af
# ginstall from coreutils
Packit Service 7770af
ifeq ($(OS),SunOS)
Packit Service 7770af
INSTALL  ?= ginstall
Packit Service 7770af
endif
Packit Service 7770af
INSTALL  ?= install
Packit Service 7770af
CFLAGS   ?= -Wall
Packit Service 7770af
CXXFLAGS ?= -Wall
Packit Service 7770af
LDFLAGS  ?= -Wall
Packit Service 7770af
ifeq "x$(COVERAGE)" "x"
Packit Service 7770af
  CFLAGS   += -O2
Packit Service 7770af
  CXXFLAGS += -O2
Packit Service 7770af
  LDFLAGS  += -O2
Packit Service 7770af
else
Packit Service 7770af
  CFLAGS   += -O1 -fno-omit-frame-pointer
Packit Service 7770af
  CXXFLAGS += -O1 -fno-omit-frame-pointer
Packit Service 7770af
  LDFLAGS  += -O1 -fno-omit-frame-pointer
Packit Service 7770af
endif
Packit Service 7770af
LDFLAGS  += -Wl,-undefined,error
Packit Service 7770af
CAT      ?= $(if $(filter $(OS),Windows_NT),type,cat)
Packit Service 7770af
Packit Service 7770af
ifneq (,$(findstring /cygdrive/,$(PATH)))
Packit Service 7770af
	UNAME := Cygwin
Packit Service 7770af
else
Packit Service 7770af
	ifneq (,$(findstring Windows_NT,$(OS)))
Packit Service 7770af
		UNAME := Windows
Packit Service 7770af
	else
Packit Service 7770af
		ifneq (,$(findstring mingw32,$(MAKE)))
Packit Service 7770af
			UNAME := Windows
Packit Service 7770af
		else
Packit Service 7770af
			ifneq (,$(findstring MINGW32,$(shell uname -s)))
Packit Service 7770af
				UNAME = Windows
Packit Service 7770af
			else
Packit Service 7770af
				UNAME := $(shell uname -s)
Packit Service 7770af
			endif
Packit Service 7770af
		endif
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq ($(SASS_LIBSASS_PATH),)
Packit Service 7770af
	SASS_LIBSASS_PATH = $(abspath $(CURDIR))
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq ($(LIBSASS_VERSION),)
Packit Service 7770af
	ifneq ($(wildcard ./.git/ ),)
Packit Service 7770af
		LIBSASS_VERSION ?= $(shell git describe --abbrev=4 --dirty --always --tags)
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq ($(LIBSASS_VERSION),)
Packit Service 7770af
	ifneq ($(wildcard VERSION),)
Packit Service 7770af
		LIBSASS_VERSION ?= $(shell $(CAT) VERSION)
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifneq ($(LIBSASS_VERSION),)
Packit Service 7770af
	CFLAGS   += -DLIBSASS_VERSION="\"$(LIBSASS_VERSION)\""
Packit Service 7770af
	CXXFLAGS += -DLIBSASS_VERSION="\"$(LIBSASS_VERSION)\""
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
# enable mandatory flag
Packit Service 7770af
ifeq (Windows,$(UNAME))
Packit Service 7770af
	ifneq ($(BUILD),shared)
Packit Service 7770af
		STATIC_ALL     ?= 1
Packit Service 7770af
	endif
Packit Service 7770af
	STATIC_LIBGCC    ?= 1
Packit Service 7770af
	STATIC_LIBSTDCPP ?= 1
Packit Service 7770af
	CXXFLAGS += -std=gnu++0x
Packit Service 7770af
	LDFLAGS  += -std=gnu++0x
Packit Service 7770af
else
Packit Service 7770af
	STATIC_ALL       ?= 0
Packit Service 7770af
	STATIC_LIBGCC    ?= 0
Packit Service 7770af
	STATIC_LIBSTDCPP ?= 0
Packit Service 7770af
	CXXFLAGS += -std=c++0x
Packit Service 7770af
	LDFLAGS  += -std=c++0x
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifneq ($(SASS_LIBSASS_PATH),)
Packit Service 7770af
	CFLAGS   += -I $(SASS_LIBSASS_PATH)/include
Packit Service 7770af
	CXXFLAGS += -I $(SASS_LIBSASS_PATH)/include
Packit Service 7770af
else
Packit Service 7770af
	# this is needed for mingw
Packit Service 7770af
	CFLAGS   += -I include
Packit Service 7770af
	CXXFLAGS += -I include
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifneq ($(EXTRA_CFLAGS),)
Packit Service 7770af
	CFLAGS   += $(EXTRA_CFLAGS)
Packit Service 7770af
endif
Packit Service 7770af
ifneq ($(EXTRA_CXXFLAGS),)
Packit Service 7770af
	CXXFLAGS += $(EXTRA_CXXFLAGS)
Packit Service 7770af
endif
Packit Service 7770af
ifneq ($(EXTRA_LDFLAGS),)
Packit Service 7770af
	LDFLAGS  += $(EXTRA_LDFLAGS)
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
LDLIBS = -lm
Packit Service 7770af
Packit Service 7770af
ifneq ($(BUILD),shared)
Packit Service 7770af
	LDLIBS += -lstdc++
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
# link statically into lib
Packit Service 7770af
# makes it a lot more portable
Packit Service 7770af
# increases size by about 50KB
Packit Service 7770af
ifeq ($(STATIC_ALL),1)
Packit Service 7770af
	LDFLAGS += -static
Packit Service 7770af
endif
Packit Service 7770af
ifeq ($(STATIC_LIBGCC),1)
Packit Service 7770af
	LDFLAGS += -static-libgcc
Packit Service 7770af
endif
Packit Service 7770af
ifeq ($(STATIC_LIBSTDCPP),1)
Packit Service 7770af
	LDFLAGS += -static-libstdc++
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq ($(UNAME),Darwin)
Packit Service 7770af
	CFLAGS += -stdlib=libc++
Packit Service 7770af
	CXXFLAGS += -stdlib=libc++
Packit Service 7770af
	LDFLAGS += -stdlib=libc++
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifneq (Windows,$(UNAME))
Packit Service 7770af
	ifneq (FreeBSD,$(UNAME))
Packit Service 7770af
		ifneq (OpenBSD,$(UNAME))
Packit Service 7770af
			LDFLAGS += -ldl
Packit Service 7770af
			LDLIBS += -ldl
Packit Service 7770af
		endif
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifneq ($(BUILD),shared)
Packit Service 7770af
	BUILD := static
Packit Service 7770af
endif
Packit Service 7770af
ifeq ($(DEBUG),1)
Packit Service 7770af
	BUILD := debug-$(BUILD)
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq (,$(TRAVIS_BUILD_DIR))
Packit Service 7770af
	ifeq ($(OS),SunOS)
Packit Service 7770af
		PREFIX ?= /opt/local
Packit Service 7770af
	else
Packit Service 7770af
		PREFIX ?= /usr/local
Packit Service 7770af
	endif
Packit Service 7770af
else
Packit Service 7770af
	PREFIX ?= $(TRAVIS_BUILD_DIR)
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
SASS_SASSC_PATH ?= sassc
Packit Service 7770af
SASS_SPEC_PATH ?= sass-spec
Packit Service 7770af
SASS_SPEC_SPEC_DIR ?= spec
Packit Service 7770af
SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc
Packit Service 7770af
RUBY_BIN = ruby
Packit Service 7770af
Packit Service 7770af
LIB_STATIC = $(SASS_LIBSASS_PATH)/lib/libsass.a
Packit Service 7770af
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.so
Packit Service 7770af
Packit Service 7770af
ifeq (Windows,$(UNAME))
Packit Service 7770af
	ifeq (shared,$(BUILD))
Packit Service 7770af
		CFLAGS     += -D ADD_EXPORTS
Packit Service 7770af
		CXXFLAGS   += -D ADD_EXPORTS
Packit Service 7770af
		LIB_SHARED  = $(SASS_LIBSASS_PATH)/lib/libsass.dll
Packit Service 7770af
	endif
Packit Service 7770af
else
Packit Service 7770af
	ifneq (Cygwin,$(UNAME))
Packit Service 7770af
		CFLAGS   += -fPIC
Packit Service 7770af
		CXXFLAGS += -fPIC
Packit Service 7770af
		LDFLAGS  += -fPIC
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
ifeq (Windows,$(UNAME))
Packit Service 7770af
	SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
include Makefile.conf
Packit Service 7770af
Packit Service 7770af
RESOURCES =
Packit Service 7770af
STATICLIB = lib/libsass.a
Packit Service 7770af
SHAREDLIB = lib/libsass.so
Packit Service 7770af
ifeq (Windows,$(UNAME))
Packit Service 7770af
	RESOURCES += res/resource.rc
Packit Service 7770af
	SHAREDLIB  = lib/libsass.dll
Packit Service 7770af
	ifeq (shared,$(BUILD))
Packit Service 7770af
		CFLAGS    += -D ADD_EXPORTS
Packit Service 7770af
		CXXFLAGS  += -D ADD_EXPORTS
Packit Service 7770af
	endif
Packit Service 7770af
else
Packit Service 7770af
	ifneq (Cygwin,$(UNAME))
Packit Service 7770af
		CFLAGS   += -fPIC
Packit Service 7770af
		CXXFLAGS += -fPIC
Packit Service 7770af
		LDFLAGS  += -fPIC
Packit Service 7770af
	endif
Packit Service 7770af
endif
Packit Service 7770af
Packit Service 7770af
OBJECTS = $(addprefix src/,$(SOURCES:.cpp=.o))
Packit Service 7770af
COBJECTS = $(addprefix src/,$(CSOURCES:.c=.o))
Packit Service 7770af
RCOBJECTS = $(RESOURCES:.rc=.o)
Packit Service 7770af
Packit Service 7770af
DEBUG_LVL ?= NONE
Packit Service 7770af
Packit Service 7770af
CLEANUPS ?=
Packit Service 7770af
CLEANUPS += $(RCOBJECTS)
Packit Service 7770af
CLEANUPS += $(COBJECTS)
Packit Service 7770af
CLEANUPS += $(OBJECTS)
Packit Service 7770af
CLEANUPS += $(LIBSASS_LIB)
Packit Service 7770af
Packit Service 7770af
all: $(BUILD)
Packit Service 7770af
Packit Service 7770af
debug: $(BUILD)
Packit Service 7770af
Packit Service 7770af
debug-static: LDFLAGS := -g $(filter-out -O2,$(LDFLAGS))
Packit Service 7770af
debug-static: CFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CFLAGS))
Packit Service 7770af
debug-static: CXXFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CXXFLAGS))
Packit Service 7770af
debug-static: static
Packit Service 7770af
Packit Service 7770af
debug-shared: LDFLAGS := -g $(filter-out -O2,$(LDFLAGS))
Packit Service 7770af
debug-shared: CFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CFLAGS))
Packit Service 7770af
debug-shared: CXXFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2,$(CXXFLAGS))
Packit Service 7770af
debug-shared: shared
Packit Service 7770af
Packit Service 7770af
lib:
Packit Service 7770af
	$(MKDIR) lib
Packit Service 7770af
Packit Service 7770af
lib/libsass.a: lib $(COBJECTS) $(OBJECTS)
Packit Service 7770af
	$(AR) rcvs $@ $(COBJECTS) $(OBJECTS)
Packit Service 7770af
Packit Service 7770af
lib/libsass.so: lib $(COBJECTS) $(OBJECTS)
Packit Service 7770af
	$(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(LDLIBS)
Packit Service 7770af
Packit Service 7770af
lib/libsass.dll: lib $(COBJECTS) $(OBJECTS) $(RCOBJECTS)
Packit Service 7770af
	$(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(RCOBJECTS) $(LDLIBS) -s -Wl,--subsystem,windows,--out-implib,lib/libsass.a
Packit Service 7770af
Packit Service 7770af
%.o: %.c
Packit Service 7770af
	$(CC) $(CFLAGS) -c -o $@ $<
Packit Service 7770af
Packit Service 7770af
%.o: %.rc
Packit Service 7770af
	$(WINDRES) -i $< -o $@
Packit Service 7770af
Packit Service 7770af
%.o: %.cpp
Packit Service 7770af
	$(CXX) $(CXXFLAGS) -c -o $@ $<
Packit Service 7770af
Packit Service 7770af
%: %.o static
Packit Service 7770af
	$(CXX) $(CXXFLAGS) -o $@ $+ $(LDFLAGS) $(LDLIBS)
Packit Service 7770af
Packit Service 7770af
install: install-$(BUILD)
Packit Service 7770af
Packit Service 7770af
static: $(STATICLIB)
Packit Service 7770af
shared: $(SHAREDLIB)
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX):
Packit Service 7770af
	$(MKDIR) $(DESTDIR)$(PREFIX)
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/lib: $(DESTDIR)$(PREFIX)
Packit Service 7770af
	$(MKDIR) $(DESTDIR)$(PREFIX)/lib
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/include: $(DESTDIR)$(PREFIX)
Packit Service 7770af
	$(MKDIR) $(DESTDIR)$(PREFIX)/include
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/include/sass: $(DESTDIR)$(PREFIX)/include
Packit Service 7770af
	$(MKDIR) $(DESTDIR)$(PREFIX)/include/sass
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/include/%.h: include/%.h \
Packit Service 7770af
                                 $(DESTDIR)$(PREFIX)/include \
Packit Service 7770af
                                 $(DESTDIR)$(PREFIX)/include/sass
Packit Service 7770af
	$(INSTALL) -v -m0644 "$<" "$@"
Packit Service 7770af
Packit Service 7770af
install-headers: $(DESTDIR)$(PREFIX)/include/sass.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass2scss.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass/base.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass/version.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass/values.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass/context.h \
Packit Service 7770af
                 $(DESTDIR)$(PREFIX)/include/sass/functions.h
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/lib/%.a: lib/%.a \
Packit Service 7770af
                             $(DESTDIR)$(PREFIX)/lib
Packit Service 7770af
	@$(INSTALL) -v -m0755 "$<" "$@"
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/lib/%.so: lib/%.so \
Packit Service 7770af
                             $(DESTDIR)$(PREFIX)/lib
Packit Service 7770af
	@$(INSTALL) -v -m0755 "$<" "$@"
Packit Service 7770af
Packit Service 7770af
$(DESTDIR)$(PREFIX)/lib/%.dll: lib/%.dll \
Packit Service 7770af
                               $(DESTDIR)$(PREFIX)/lib
Packit Service 7770af
	@$(INSTALL) -v -m0755 "$<" "$@"
Packit Service 7770af
Packit Service 7770af
install-static: $(DESTDIR)$(PREFIX)/lib/libsass.a
Packit Service 7770af
Packit Service 7770af
install-shared: $(DESTDIR)$(PREFIX)/lib/libsass.so \
Packit Service 7770af
                install-headers
Packit Service 7770af
Packit Service 7770af
$(SASSC_BIN): $(BUILD)
Packit Service 7770af
	$(MAKE) -C $(SASS_SASSC_PATH)
Packit Service 7770af
Packit Service 7770af
sassc: $(SASSC_BIN)
Packit Service 7770af
	$(SASSC_BIN) -v
Packit Service 7770af
Packit Service 7770af
version: $(SASSC_BIN)
Packit Service 7770af
	$(SASSC_BIN) -h
Packit Service 7770af
	$(SASSC_BIN) -v
Packit Service 7770af
Packit Service 7770af
test: $(SASSC_BIN)
Packit Service 7770af
	$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.4 -c $(SASSC_BIN) --impl libsass $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
Packit Service 7770af
Packit Service 7770af
test_build: $(SASSC_BIN)
Packit Service 7770af
	$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.4 -c $(SASSC_BIN) --impl libsass $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
Packit Service 7770af
Packit Service 7770af
test_full: $(SASSC_BIN)
Packit Service 7770af
	$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.4 -c $(SASSC_BIN) --impl libsass --run-todo $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
Packit Service 7770af
Packit Service 7770af
test_probe: $(SASSC_BIN)
Packit Service 7770af
	$(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -V 3.4 -c $(SASSC_BIN) --impl libsass --probe-todo $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR)
Packit Service 7770af
Packit Service 7770af
clean-objects: lib
Packit Service 7770af
	-$(RM) lib/*.a lib/*.so lib/*.dll lib/*.la
Packit Service 7770af
	-$(RMDIR) lib
Packit Service 7770af
clean: clean-objects
Packit Service 7770af
	$(RM) $(CLEANUPS)
Packit Service 7770af
Packit Service 7770af
clean-all:
Packit Service 7770af
	$(MAKE) -C $(SASS_SASSC_PATH) clean
Packit Service 7770af
Packit Service 7770af
lib-file: lib-file-$(BUILD)
Packit Service 7770af
lib-opts: lib-opts-$(BUILD)
Packit Service 7770af
Packit Service 7770af
lib-file-static:
Packit Service 7770af
	@echo $(LIB_STATIC)
Packit Service 7770af
lib-file-shared:
Packit Service 7770af
	@echo $(LIB_SHARED)
Packit Service 7770af
lib-opts-static:
Packit Service 7770af
	@echo -L"$(SASS_LIBSASS_PATH)/lib"
Packit Service 7770af
lib-opts-shared:
Packit Service 7770af
	@echo -L"$(SASS_LIBSASS_PATH)/lib -lsass"
Packit Service 7770af
Packit Service 7770af
.PHONY: all static shared sassc \
Packit Service 7770af
        version install-headers \
Packit Service 7770af
        clean clean-all clean-objects \
Packit Service 7770af
        debug debug-static debug-shared \
Packit Service 7770af
        install install-static install-shared \
Packit Service 7770af
        lib-opts lib-opts-shared lib-opts-static \
Packit Service 7770af
        lib-file lib-file-shared lib-file-static
Packit Service 7770af
.DELETE_ON_ERROR: