-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
archerC
committed
Sep 9, 2018
1 parent
afad290
commit 7c26d1b
Showing
5 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
include Makefile.common | ||
|
||
.PHONY: all build-static build-shared check clean distclean | ||
all: build-static build-shared check | ||
build-static: | ||
$(MAKE) -C src build-static | ||
|
||
build-shared: | ||
$(MAKE) -C src build-shared | ||
|
||
check: build-static build-shared | ||
$(MAKE) -C test | ||
|
||
clean: | ||
$(MAKE) -C src clean | ||
$(MAKE) -C test clean | ||
|
||
distclean: clean | ||
$(MAKE) -C src distclean | ||
|
||
ifneq ($(OS),Windows) | ||
.PHONY: install install-static | ||
install: | ||
$(MAKE) -C src install-static | ||
$(MAKE) -C src install-shared | ||
$(MAKE) -C include install | ||
|
||
install-static: | ||
$(MAKE) -C src install-static | ||
$(MAKE) -C include install | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
VERSION := 0.1.7 | ||
OS ?= $(shell uname -s) | ||
|
||
CXXWARNFLAGS := -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic | ||
CXXFLAGS := $(CXXWARNFLAGS) -g -O2 | ||
|
||
prefix := /usr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.PHONY: cleandeps | ||
|
||
ifneq ($(OS),Windows) | ||
|
||
.static-dep/%.dep: %.cpp | ||
@mkdir -p $(dir $@) | ||
$(CXX) -MM -MT $(patsubst %.cpp,%.o,$<) $(CPPFLAGS) $< > $@ | ||
|
||
.shared-dep/%.dep: %.cpp | ||
@mkdir -p $(dir $@) | ||
$(CXX) -MM -MT $(patsubst %.cpp,%.lo,$<) $(CPPFLAGS) $< > $@ | ||
|
||
ifneq ($(MAKECMDGOALS),clean) | ||
ifneq ($(MAKECMDGOALS),distclean) | ||
-include $(addprefix .static-dep/,$(SRC:.cpp=.dep)) | ||
-include $(addprefix .shared-dep/,$(SRC:.cpp=.dep)) | ||
endif | ||
endif | ||
|
||
cleandeps: | ||
$(RM) -R .static-dep | ||
$(RM) -R .shared-dep | ||
|
||
else | ||
cleandeps: | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
include ../Makefile.common | ||
|
||
SRC := $(wildcard *.cpp) | ||
STATIC_OBJ := $(SRC:.cpp=.o) | ||
SHARED_OBJ := $(SRC:.cpp=.lo) | ||
|
||
override CPPFLAGS += -I../include -DNDEBUG | ||
|
||
STATIC_LIB := libloki.a | ||
|
||
ifeq ($(OS), Darwin) | ||
SHARED_LIB_BASE := libloki.dylib | ||
SHARED_LIB_VERSIONED := libloki.$(VERSION).dylib | ||
override LDFLAGS += -dynamiclib -single_module -install_name $(SHARED_LIB_VERSIONED) -fPIC | ||
LDLIBS := -lpthread | ||
else | ||
ifeq ($(OS), Linux) | ||
SHARED_LIB_BASE := libloki.so | ||
SHARED_LIB_VERSIONED := libloki.so.$(VERSION) | ||
override LDFLAGS += --shared -Wl,-soname=$(SHARED_LIB_VERSIONED) -fPIC | ||
LDLIBS := -lpthread | ||
else | ||
ifeq ($(OS), GNU/kFreeBSD) | ||
SHARED_LIB_BASE := libloki.so | ||
SHARED_LIB_VERSIONED := libloki.so.$(VERSION) | ||
override LDFLAGS += --shared -Wl,-soname=$(SHARED_LIB_VERSIONED) -fPIC | ||
LDLIBS := -lpthread | ||
else | ||
ifeq ($(OS), GNU) | ||
SHARED_LIB_BASE := libloki.so | ||
SHARED_LIB_VERSIONED := libloki.so.$(VERSION) | ||
override LDFLAGS += --shared -Wl,-soname=$(SHARED_LIB_VERSIONED) -fPIC | ||
LDLIBS := -lpthread | ||
else | ||
ifeq ($(OS), HP-UX) | ||
SHARED_LIB_BASE := libloki.so | ||
SHARED_LIB_VERSIONED := libloki.so.$(VERSION) | ||
override LDFLAGS += --shared -fPIC -mlp64 | ||
override CXXFLAGS += -mlp64 | ||
LDLIBS := -lpthread | ||
RESULT_DIR := ../lib/ | ||
else | ||
SHARED_LIB_VERSIONED := libloki.dll | ||
override LDFLAGS += --shared | ||
LDLIBS := | ||
endif | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
RESULT_DIR := ../lib/ | ||
|
||
.PHONY: all build-static build-shared clean distclean | ||
all: build-static build-shared | ||
build-static: $(RESULT_DIR)$(STATIC_LIB) | ||
build-shared: $(RESULT_DIR)$(SHARED_LIB_VERSIONED) | ||
|
||
clean: | ||
$(RM) $(STATIC_OBJ) | ||
ifneq ($(OS), Windows) | ||
$(RM) $(SHARED_OBJ) | ||
endif | ||
|
||
distclean: clean cleandeps | ||
$(RM) $(RESULT_DIR)$(STATIC_LIB) | ||
$(RM) $(RESULT_DIR)$(SHARED_LIB_VERSIONED) | ||
|
||
ifneq ($(OS),Windows) | ||
INSTALL := install | ||
INSTALL_DATA := $(INSTALL) -m 644 | ||
|
||
.PHONY: install install-static install-shared | ||
install: install-static install-shared | ||
|
||
install-static: $(RESULT_DIR)$(STATIC_LIB) | ||
mkdir -p $(prefix)/lib | ||
$(INSTALL_DATA) $(RESULT_DIR)$(STATIC_LIB) $(prefix)/lib | ||
|
||
install-shared: $(RESULT_DIR)$(SHARED_LIB_VERSIONED) | ||
mkdir -p $(prefix)/lib | ||
$(INSTALL_DATA) $(RESULT_DIR)$(SHARED_LIB_VERSIONED) $(prefix)/lib | ||
cd $(prefix)/lib; ln -s $(SHARED_LIB_VERSIONED) $(SHARED_LIB_BASE) | ||
|
||
%.lo : %.cpp | ||
$(CXX) -c $(CXXFLAGS) -fPIC $(CPPFLAGS) -o $@ $< | ||
|
||
$(RESULT_DIR)$(SHARED_LIB_VERSIONED): $(SHARED_OBJ) | ||
else | ||
$(RESULT_DIR)$(SHARED_LIB_VERSIONED): $(STATIC_OBJ) | ||
endif | ||
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) | ||
|
||
$(RESULT_DIR)$(STATIC_LIB): $(STATIC_OBJ) | ||
$(AR) $(ARFLAGS) $@ $^ | ||
|
||
include ../Makefile.deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SUBTARGETS_ORIG := $(patsubst %/,%,$(dir $(wildcard */Makefile))) | ||
SUBTARGETS_FILTER_OUT := flex_string | ||
SUBTARGETS := $(filter-out $(SUBTARGETS_FILTER_OUT),$(SUBTARGETS_ORIG)) | ||
|
||
SUBTARGETS_CLEAN := $(addsuffix -clean,$(SUBTARGETS)) | ||
|
||
.PHONY: all clean $(SUBTARGETS) $(SUBTARGETS_CLEAN) | ||
all: $(SUBTARGETS) | ||
clean: $(SUBTARGETS_CLEAN) | ||
|
||
$(SUBTARGETS): | ||
$(MAKE) -C $@ | ||
|
||
$(SUBTARGETS_CLEAN): | ||
$(MAKE) -C $(@:-clean=) clean |