From bd994cd7976ac93c530792e3c0d6f45a33c757b4 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Thu, 8 Dec 2011 20:57:12 +1030 Subject: Fix Makefile for use with non-GNU make - Remove GNU make "override" statements. - Add OBJS variable since there is no portable way to specify all targets for linking. Also: - Put build defaults at the top to avoid potential confusion. - Don't assume a Linux platform. Default to USE_POSIX_SETLOCALE. - Change "install -d" to mkdir/install since the former isn't available on some platforms (Solaris). --- Makefile | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f32e4b1..1eb1090 100644 --- a/Makefile +++ b/Makefile @@ -12,54 +12,55 @@ LUA_VERSION = 5.1 # # USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). -## Common build defaults +## Build defaults PREFIX = /usr/local -CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -LDFLAGS_EXTRA = -shared +#CFLAGS = -g -Wall -pedantic -fno-inline +CFLAGS = -O3 -Wall -pedantic +CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE +CJSON_LDFLAGS = -shared +LUA_INCLUDE_DIR = $(PREFIX)/include +LUA_MODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) +INSTALL_CMD = install ## Platform overrides # -# Tweaking one of the platform sections below to suit your situation. +# Tweak one of the platform sections below to suit your situation. # # See http://lua-users.org/wiki/BuildingModules for further platform # specific details. ## Linux -CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE +#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE ## FreeBSD #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 ## MacOSX (Macports) #PREFIX = /opt/local -#CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE -#LDFLAGS_EXTRA = -bundle -undefined dynamic_lookup +#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE +#CJSON_LDFLAGS = -bundle -undefined dynamic_lookup ## Solaris -#CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF +#CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF ## End platform specific section -LUA_INCLUDE_DIR ?= $(PREFIX)/include -LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) - -#CFLAGS ?= -g -Wall -pedantic -fno-inline -CFLAGS ?= -O3 -Wall -pedantic -override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" -override LDFLAGS += $(LDFLAGS_EXTRA) - -INSTALL ?= install +CJSON_CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" +OBJS := lua_cjson.o strbuf.o .PHONY: all clean install package all: cjson.so -cjson.so: lua_cjson.o strbuf.o - $(CC) $(LDFLAGS) -o $@ $^ +.c.o: + $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CJSON_CFLAGS) -o $@ $< + +cjson.so: $(OBJS) + $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) -install: - $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR) - $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR) +install: cjson.so + mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR) + $(INSTALL_CMD) cjson.so $(DESTDIR)/$(LUA_MODULE_DIR) clean: rm -f *.o *.so -- cgit v1.2.3-55-g6feb