2014-02-23 21:28:28 +00:00
|
|
|
CC ?= gcc
|
|
|
|
DESTDIR ?= /usr/local
|
|
|
|
LD ?= gcc
|
|
|
|
C_COMMON_FLAGS ?= -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src
|
|
|
|
MAJOR_VERSION = 0
|
|
|
|
MINOR_VERSION = 2
|
2014-03-22 17:22:29 +00:00
|
|
|
PATCH_VERSION = 9
|
2014-02-23 21:28:28 +00:00
|
|
|
VERSION = "$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)"
|
2014-03-10 10:23:43 +00:00
|
|
|
SONAME = libucl.dll
|
2014-02-23 21:28:28 +00:00
|
|
|
OBJDIR ?= .obj
|
|
|
|
TESTDIR ?= tests
|
|
|
|
SRCDIR ?= src
|
|
|
|
INCLUDEDIR ?= include
|
|
|
|
MKDIR ?= mkdir
|
|
|
|
INSTALL ?= install
|
|
|
|
RM ?= rm
|
|
|
|
RMDIR ?= rmdir
|
2014-03-10 10:23:43 +00:00
|
|
|
ifeq (Windows_NT, $(OS))
|
2014-02-23 21:28:28 +00:00
|
|
|
LN ?= ln
|
2014-03-10 10:23:43 +00:00
|
|
|
else
|
|
|
|
LN ?= rem ln
|
|
|
|
endif
|
2014-02-23 21:28:28 +00:00
|
|
|
LD_SHARED_FLAGS ?= -Wl,-soname,$(SONAME) -shared -lm
|
|
|
|
LD_UCL_FLAGS ?= -L$(OBJDIR) -Wl,-rpath,$(OBJDIR) -lucl
|
|
|
|
LD_ADD ?= -lrt
|
2014-03-10 10:23:43 +00:00
|
|
|
COPT_FLAGS ?= -O2
|
2014-03-22 17:22:29 +00:00
|
|
|
HDEPS = $(SRCDIR)/ucl_hash.h \
|
|
|
|
$(SRCDIR)/ucl_chartable.h \
|
|
|
|
$(SRCDIR)/ucl_internal.h \
|
|
|
|
$(INCLUDEDIR)/ucl.h \
|
2016-10-01 00:11:09 +00:00
|
|
|
$(SRCDIR)/mum.h
|
2014-03-22 17:22:29 +00:00
|
|
|
OBJECTS = $(OBJDIR)/ucl_hash.o \
|
|
|
|
$(OBJDIR)/ucl_util.o \
|
|
|
|
$(OBJDIR)/ucl_parser.o \
|
|
|
|
$(OBJDIR)/ucl_emitter.o \
|
2014-11-29 00:33:10 +00:00
|
|
|
$(OBJDIR)/ucl_emitter_utils.o \
|
2016-10-01 00:11:09 +00:00
|
|
|
$(OBJDIR)/ucl_schema.o
|
2014-02-23 21:28:28 +00:00
|
|
|
|
|
|
|
all: $(OBJDIR) $(OBJDIR)/$(SONAME)
|
|
|
|
|
2014-03-10 10:23:43 +00:00
|
|
|
$(OBJDIR)/$(SONAME): $(OBJECTS)
|
|
|
|
$(CC) -o $(OBJDIR)/$(SONAME) $(OBJECTS) $(LD_SHARED_FLAGS) $(LDFLAGS) $(SSL_LIBS) $(FETCH_LIBS)
|
2014-02-23 21:28:28 +00:00
|
|
|
|
|
|
|
$(OBJDIR):
|
|
|
|
@$(MKDIR) -p $(OBJDIR)
|
|
|
|
|
|
|
|
# Compile rules
|
|
|
|
$(OBJDIR)/ucl_util.o: $(SRCDIR)/ucl_util.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_util.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_util.c
|
|
|
|
$(OBJDIR)/ucl_parser.o: $(SRCDIR)/ucl_parser.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_parser.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_parser.c
|
|
|
|
$(OBJDIR)/ucl_emitter.o: $(SRCDIR)/ucl_emitter.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_emitter.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_emitter.c
|
2014-11-29 00:33:10 +00:00
|
|
|
$(OBJDIR)/ucl_emitter_utils.o: $(SRCDIR)/ucl_emitter_utils.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_emitter_utils.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_emitter_utils.c
|
2014-02-23 21:28:28 +00:00
|
|
|
$(OBJDIR)/ucl_hash.o: $(SRCDIR)/ucl_hash.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_hash.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_hash.c
|
2014-03-22 17:22:29 +00:00
|
|
|
$(OBJDIR)/ucl_schema.o: $(SRCDIR)/ucl_schema.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/ucl_schema.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_schema.c
|
2014-02-23 21:28:28 +00:00
|
|
|
$(OBJDIR)/xxhash.o: $(SRCDIR)/xxhash.c $(HDEPS)
|
|
|
|
$(CC) -o $(OBJDIR)/xxhash.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/xxhash.c
|
|
|
|
|
|
|
|
clean:
|
2014-03-10 10:23:43 +00:00
|
|
|
$(RM) $(OBJDIR)/*.o $(OBJDIR)/$(SONAME) $(OBJDIR)/$(SONAME) $(OBJDIR)/chargen $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/objdump $(OBJDIR)/test_generate
|
2014-02-23 21:28:28 +00:00
|
|
|
$(RMDIR) $(OBJDIR)
|
2014-11-29 00:33:10 +00:00
|
|
|
|
2014-02-23 21:28:28 +00:00
|
|
|
# Utils
|
|
|
|
|
|
|
|
chargen: utils/chargen.c $(OBJDIR)/$(SONAME)
|
|
|
|
$(CC) -o $(OBJDIR)/chargen $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) utils/chargen.c
|
|
|
|
objdump: utils/objdump.c $(OBJDIR)/$(SONAME)
|
|
|
|
$(CC) -o $(OBJDIR)/objdump $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) utils/objdump.c $(LD_UCL_FLAGS)
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
|
|
|
test: $(OBJDIR) $(OBJDIR)/$(SONAME) $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/test_generate
|
|
|
|
|
|
|
|
run-test: test
|
|
|
|
TEST_DIR=$(TESTDIR) $(TESTDIR)/run_tests.sh $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/test_generate
|
2014-11-29 00:33:10 +00:00
|
|
|
|
2014-02-23 21:28:28 +00:00
|
|
|
$(OBJDIR)/test_basic: $(TESTDIR)/test_basic.c $(OBJDIR)/$(SONAME)
|
|
|
|
$(CC) -o $(OBJDIR)/test_basic $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) $(TESTDIR)/test_basic.c $(LD_UCL_FLAGS)
|
|
|
|
$(OBJDIR)/test_speed: $(TESTDIR)/test_speed.c $(OBJDIR)/$(SONAME)
|
|
|
|
$(CC) -o $(OBJDIR)/test_speed $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) $(TESTDIR)/test_speed.c $(LD_UCL_FLAGS) $(LD_ADD)
|
|
|
|
$(OBJDIR)/test_generate: $(TESTDIR)/test_generate.c $(OBJDIR)/$(SONAME)
|
|
|
|
$(CC) -o $(OBJDIR)/test_generate $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) $(LDFLAGS) $(TESTDIR)/test_generate.c $(LD_UCL_FLAGS) $(LD_ADD)
|
|
|
|
|
|
|
|
install: $(OBJDIR)/$(SONAME)
|
|
|
|
$(INSTALL) -m0755 $(SONAME) $(DESTDIR)/lib/$(SONAME)
|
|
|
|
$(INSTALL) -m0644 include/ucl.h $(DESTDIR)/include/ucl.h
|
|
|
|
|
|
|
|
.PHONY: clean $(OBJDIR)
|