From 1292cce5ae936b1629a44cc47064e15cc97ee4a2 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 2 Nov 2014 21:16:01 +0100 Subject: [PATCH] Aligns build system with autotools build and travis-ci Implements BUILD variable to link shared or static Expects libraries in lib directory as with autotools build --- .travis.yml | 8 ++++---- Makefile | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0a0964..f29cb02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,15 @@ compiler: - gcc - clang +env: + - AUTOTOOLS=no BUILD=shared + - AUTOTOOLS=no BUILD=static + before_install: - gem install sass - git clone https://github.com/sass/libsass.git - cd libsass && git submodule init && git submodule update && cd .. - export SASS_LIBSASS_PATH=libsass - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update -qq - - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi script: - make test diff --git a/Makefile b/Makefile index b893fe2..305419b 100644 --- a/Makefile +++ b/Makefile @@ -23,15 +23,35 @@ OBJECTS = $(SOURCES:.c=.o) TARGET = bin/sassc SPEC_PATH = $(SASS_SPEC_PATH) +ifneq ($(BUILD), shared) + BUILD = static +endif + all: libsass $(TARGET) -$(TARGET): $(OBJECTS) $(SASS_LIBSASS_PATH)/libsass.a - $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) +$(TARGET): build-$(BUILD) + +build-static: $(OBJECTS) $(SASS_LIBSASS_PATH)/lib/libsass.a + $(CC) $(LDFLAGS) -o $(TARGET) $^ $(LDLIBS) + +build-shared: $(OBJECTS) $(SASS_LIBSASS_PATH)/lib/libsass.so + $(CC) $(LDFLAGS) -o $(TARGET) $^ $(LDLIBS) + +$(SASS_LIBSASS_PATH)/lib/libsass.a: libsass-static +$(SASS_LIBSASS_PATH)/lib/libsass.so: 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 -$(SASS_LIBSASS_PATH)/libsass.a: libsass -libsass: +libsass-shared: ifdef SASS_LIBSASS_PATH - $(MAKE) -C $(SASS_LIBSASS_PATH) + BUILD="shared" $(MAKE) -C $(SASS_LIBSASS_PATH) else $(error SASS_LIBSASS_PATH must be defined) endif @@ -48,5 +68,5 @@ ifdef SASS_LIBSASS_PATH $(MAKE) -C $(SASS_LIBSASS_PATH) clean endif -.PHONY: clean libsass test +.PHONY: clean libsass libsass-static libsass-shared build-static build-shared test .DELETE_ON_ERROR: