Source

hxuv / ndll / Makefile

Full commit

NEKO_EXEC=$(shell which neko)
CUR_WD=$(shell dirname $(MAKEFILE_LIST))
CUR_WD:=$(shell realpath $(CUR_WD))
UV_PATH=$(CUR_WD)/libs/libuv

OBJS = nloop.o nstream.o ndns.o nasync.o ntimer.o nutils.o

LIBNAME=nuv.ndll

CC=gcc
CCP=g++ --std=c++11
CPPFLAGS=-Wall -I$(CUR_WD)/src -I$(UV_PATH)/include -O3 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

uname_S=$(shell uname -s)

ifeq (Darwin, $(uname_S))
	CFLAGS+=-framework CoreServices
endif

ifeq (Linux, $(uname_S))
	CFLAGS+=-lneko -lrt -ldl -lm
endif


FULL_LIBNAME=$(CUR_WD)/$(uname_S)/$(LIBNAME)
ifneq "" "$(PREFIX)"
	FULL_LIBNAME=$(PREFIX)/$(uname_S)/$(LIBNAME)
endif

all: $(UV_PATH)/libuv.a $(FULL_LIBNAME)

$(OBJS) : %.o: $(CUR_WD)/src/%.c
	$(CCP) -o $(CUR_WD)/obj/$*.o -c -fPIC $(CPPFLAGS) $<

$(UV_PATH)/libuv.a:
	make -C $(UV_PATH) CFLAGS=-fPIC

$(FULL_LIBNAME) : %.ndll: $(OBJS) $(UV_PATH)/libuv.a
	$(CCP) $(CFLAGS) --shared -o $(FULL_LIBNAME) $(CUR_WD)/obj/*.o  $(UV_PATH)/libuv.a

release: $(FULL_LIBNAME)
	strip $(FULL_LIBNAME)

test: $(FULL_LIBNAME)
	haxe $(CUR_WD)/../test/build.hxml --cwd $(CUR_WD)/../test/

test-release: release test

run:
	$(NEKO_EXEC) $(CUR_WD)/../test/run.n

test-run: test run

clean:
	rm -fr obj/*
	rm -f $(FULL_LIBNAME)
	rm -f $(CUR_WD)/../test/run.n

clean-all: clean
	make -C $(UV_PATH) clean