diff --git a/Makefile b/Makefile index af8415e6..70431c51 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,14 @@ -PLAT ?= none -PLATS = linux freebsd macosx +include platform.mk -CC ?= gcc - -.PHONY : none $(PLATS) clean lua all - -ifneq ($(PLAT), none) - -.PHONY : default - -default : - $(MAKE) $(PLAT) - -endif - -none : - @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" - @echo " $(PLATS)" - -LUA_STATICLIB = 3rd/lua/liblua.a +LUA_STATICLIB := 3rd/lua/liblua.a LUA_LIB ?= $(LUA_STATICLIB) LUA_INC ?= -I3rd/lua LUA_CLIB_PATH ?= luaclib CSERVICE_PATH ?= cservice SKYNET_BUILD_PATH ?= . - CFLAGS = -g -Wall $(LUA_INC) $(MYCFLAGS) -LIBS = -lpthread -lm -SHARED = -fPIC --shared -EXPORT = -Wl,-E - -$(PLATS) : all - -linux : PLAT = linux -macosx : PLAT = macosx -freebsd : PLAT = freebsd - -macosx linux : LIBS += -ldl -macosx : SHARED = -fPIC -dynamiclib -Wl,-undefined,dynamic_lookup -macosx : EXPORT = -linux freebsd : LIBS += -lrt - $(LUA_STATICLIB) : cd 3rd/lua && $(MAKE) CC=$(CC) $(PLAT) diff --git a/platform.mk b/platform.mk new file mode 100644 index 00000000..11031f89 --- /dev/null +++ b/platform.mk @@ -0,0 +1,34 @@ +PLAT ?= none +PLATS = linux freebsd macosx + +CC ?= gcc + +.PHONY : none $(PLATS) clean all + +ifneq ($(PLAT), none) + +.PHONY : default + +default : + $(MAKE) $(PLAT) + +endif + +none : + @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" + @echo " $(PLATS)" + +LIBS := -lpthread -lm +SHARED := -fPIC --shared +EXPORT := -Wl,-E + +$(PLATS) : all + +linux : PLAT = linux +macosx : PLAT = macosx +freebsd : PLAT = freebsd + +macosx linux : LIBS += -ldl +macosx : SHARED := -fPIC -dynamiclib -Wl,-undefined,dynamic_lookup +macosx : EXPORT := +linux freebsd : LIBS += -lrt