From 3da86cbf987461afc1c798f1addf8a1c4bdafcbb Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 13 Apr 2008 15:28:29 +0200 Subject: [PATCH] build variable sharing between uci and uci-lua, proper installation for lua plugin --- Makefile | 28 +--------------------------- Makefile.inc | 29 +++++++++++++++++++++++++++++ lua/Makefile | 19 +++++++++---------- 3 files changed, 39 insertions(+), 37 deletions(-) create mode 100644 Makefile.inc diff --git a/Makefile b/Makefile index 421c2d9..34b8fb5 100644 --- a/Makefile +++ b/Makefile @@ -5,35 +5,9 @@ PLUGIN_SUPPORT=1 DEBUG=0 DEBUG_TYPECAST=0 -prefix=/usr -DESTDIR= +include Makefile.inc -COPTS=-O2 -WOPTS=-pedantic -Wno-unused -Werror -FPIC=-fPIC -CFLAGS=$(COPTS) $(WOPTS) -Wall -std=gnu99 - -AR=ar -LD=ld -CC=gcc LIBS=-lc -RANLIB=ranlib -INSTALL=install - -ifeq ($(DEBUG),1) - COPTS = -O0 - CFLAGS += -g3 -endif -OS=$(shell uname) -ifeq ($(OS),Darwin) - LINK=$(LD) - SHLIB_EXT=dylib - SHLIB_FLAGS=-dylib -else - LINK=$(CC) - SHLIB_EXT=so - SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE) -endif SHLIB_FILE=libuci.$(SHLIB_EXT).$(VERSION) define add_feature diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 0000000..2578c72 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,29 @@ +prefix=/usr +DESTDIR= + +COPTS=-O2 +WOPTS=-pedantic -Werror -Wall +FPIC=-fPIC +CFLAGS=$(COPTS) $(WOPTS) -std=gnu99 + +AR=ar +LD=ld +CC=gcc +RANLIB=ranlib +INSTALL=install + +ifeq ($(DEBUG),1) + COPTS = -O0 + CFLAGS += -g3 +endif +OS=$(shell uname) +ifeq ($(OS),Darwin) + LINK=$(LD) + SHLIB_EXT=dylib + SHLIB_FLAGS=-dylib +else + LINK=$(CC) + SHLIB_EXT=so + SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE) +endif + diff --git a/lua/Makefile b/lua/Makefile index 29d7fbd..9cc6c39 100644 --- a/lua/Makefile +++ b/lua/Makefile @@ -1,27 +1,26 @@ -CC=gcc -LD=ld -CFLAGS=-O2 -Wall -Werror -pedantic --std=gnu99 -Wno-unused +include ../Makefile.inc + CPPFLAGS=-I.. LIBS=-L.. -luci -OS=$(shell uname) -LINK=$(CC) + +PLUGIN_LD=$(CC) ifeq ($(OS),Darwin) - SHLIB_FLAGS=-bundle -undefined dynamic_lookup + PLUGIN_LDFLAGS=-bundle -undefined dynamic_lookup else - SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE) + PLUGIN_LDFLAGS=-shared -Wl,-soname,$(SHLIB_FILE) endif all: uci.so uci.so: uci.o - $(LINK) $(SHLIB_FLAGS) -o $@ $^ $(LIBS) + $(PLUGIN_LD) $(PLUGIN_LDFLAGS) -o $@ $^ $(LIBS) %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< install: - mkdir -p $(DESTDIR)/usr/lib/lua - install -m0644 uci.so $(DESTDIR)/usr/lib/lua/ + mkdir -p $(DESTDIR)$(prefix)/lib/lua/5.1 + $(INSTALL) -m0644 uci.so $(DESTDIR)$(prefix)/lib/lua/5.1/ clean: rm -f *.so *.o uci.so -- 2.25.1