From: Steven Barth Date: Wed, 28 May 2008 19:37:43 +0000 (+0000) Subject: * Reworked Makefiles X-Git-Tag: 0.8.0~968 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4e53d007bf30dddad1a2e1b44aa55d3ca8671ae4;p=oweals%2Fluci.git * Reworked Makefiles * Introduced following targets: build: gccbuild luabuild gccbuild: compile luabuild: luasource||luacompile * Removed requirement for lua-headers respecting lua-only builds * Split compile part of OpenWRT Makefile --- diff --git a/Makefile b/Makefile index d76be9a2d..c78f5a810 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,42 @@ include build/config.mk MODULES = applications/* libs/* modules/* themes/* i18n/* -LUA_TARGET = compile +LUA_TARGET = source + +### luaposix merge (temporary) ### OS:=$(shell uname) export OS ifeq ($(OS),Darwin) MODULES += contrib/luaposix endif -.PHONY: all build clean host hostclean + +.PHONY: all build gccbuild luabuild clean host gcchost luahost hostcopy hostclean all: build -build: - for i in $(MODULES); do make -C$$i $(LUA_TARGET); done +build: luabuild gccbuild + +gccbuild: + for i in $(MODULES); do make -C$$i compile; done + +luabuild: + for i in $(MODULES); do make -C$$i lua$(LUA_TARGET); done clean: for i in $(MODULES); do make -C$$i clean; done -host: build + +host: build hostcopy + +gcchost: gccbuild hostcopy + +luahost: luabuild hostcopy + +hostcopy: mkdir -p host for i in $(MODULES); do cp $$i/dist/* host/ -R 2>/dev/null || true; done ln -sf .$(LUCI_INSTALLDIR) host/luci hostclean: clean - rm host -rf + rm -rf host diff --git a/build/config.mk b/build/config.mk index 9db99cd6b..1755974f2 100644 --- a/build/config.mk +++ b/build/config.mk @@ -1,28 +1,4 @@ -OS ?= $(shell uname) - LUAC = luac LUAC_OPTIONS = -s LUCI_INSTALLDIR = /usr/lib/lua/luci -LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1) -LUA_LIBS = $(if $(LUA_SHLIBS),$(LUA_SHLIBS),$(firstword $(wildcard /usr/lib/liblua.a /usr/local/lib/liblua.a /opt/local/lib/liblua.a))) -LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1) -ifeq ($(LUA_LIBS),) - $(error LUA installation not found) -endif - -CC = gcc -AR = ar -RANLIB = ranlib -CFLAGS = -O2 -FPIC = -fPIC -EXTRA_CFLAGS = --std=gnu99 -WFLAGS = -Wall -Werror -pedantic -CPPFLAGS = -COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS) -ifeq ($(OS),Darwin) - SHLIB_FLAGS = -bundle -undefined dynamic_lookup -else - SHLIB_FLAGS = -shared -endif -LINK = $(CC) diff --git a/build/gccconfig.mk b/build/gccconfig.mk new file mode 100644 index 000000000..0e4de2795 --- /dev/null +++ b/build/gccconfig.mk @@ -0,0 +1,22 @@ +OS ?= $(shell uname) + +LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1) +LUA_LIBS = $(if $(LUA_SHLIBS),$(LUA_SHLIBS),$(firstword $(wildcard /usr/lib/liblua.a /usr/local/lib/liblua.a /opt/local/lib/liblua.a))) +LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1) + +CC = gcc +AR = ar +RANLIB = ranlib +CFLAGS = -O2 +FPIC = -fPIC +EXTRA_CFLAGS = --std=gnu99 +WFLAGS = -Wall -Werror -pedantic +CPPFLAGS = +COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS) +ifeq ($(OS),Darwin) + SHLIB_FLAGS = -bundle -undefined dynamic_lookup +else + SHLIB_FLAGS = -shared +endif +LINK = $(CC) + diff --git a/build/module.mk b/build/module.mk index 923caad70..228860838 100644 --- a/build/module.mk +++ b/build/module.mk @@ -1,20 +1,25 @@ -.PHONY: all compile compile-module source source-module clean clean-module +.PHONY: all build compile luacompile luasource clean luaclean -all: compile -compile: source-module -compile-all: compile-module -clean: clean-module -source: source-module +all: build -source-module: +build: luabuild gccbuild + +luabuild: lua$(LUA_TARGET) + +gccbuild: compile +compile: + +clean: luaclean + +luasource: mkdir -p dist$(LUCI_INSTALLDIR) cp root/* dist -R 2>/dev/null || true cp luasrc/* dist$(LUCI_INSTALLDIR) -R 2>/dev/null || true for i in $$(find dist -name .svn); do rm $$i -rf; done -compile-module: source-module +luacompile: luasource for i in $$(find dist -name *.lua -not -name debug.lua); do $(LUAC) $(LUAC_OPTIONS) -o $$i $$i; done -clean-module: +luaclean: rm -rf dist diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index f2a26245d..997b9f901 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -25,11 +25,12 @@ include $(INCLUDE_DIR)/package.mk define Build/Configure endef -define Build/Compile - $(MAKE) -C$(PKG_BUILD_DIR) build LUA_TARGET=$(LUA_TARGET) +define Package/luci/compiletpl + ifneq ($(CONFIG_PACKAGE_$(1)),) + $(MAKE) -C$(PKG_BUILD_DIR)/$(2) build LUA_TARGET=$(LUA_TARGET) + endif endef - ### Templates ### define Package/luci/libtemplate @@ -115,6 +116,8 @@ define Package/luci-ff-halle endef define Package/luci-ff-halle/install + $(call Package/luci/install/template,$(1),applications/community-halle) + $(CP) -a ./ipkg/luci-ff-halle.postinst $(1)/CONTROL/postinst endef @@ -270,6 +273,26 @@ define Package/luci-sgi-webuci/install endef +define Build/Compile + $(call Package/luci/compiletpl,luci-core,libs/core) + $(call Package/luci/compiletpl,luci-cbi,libs/cbi) + $(call Package/luci/compiletpl,luci-web,libs/web) + + $(call Package/luci/compiletpl,luci-ff-halle,applications/community-halle) + $(call Package/luci/compiletpl,luci-ff-leipzig,applications/community-leipzig) + $(call Package/luci/compiletpl,luci-ff-hannover,applications/community-hannover) + + $(call Package/luci/compiletpl,luci-mod-admin-core,modules/admin-core) + $(call Package/luci/compiletpl,luci-mod-freifunk,modules/freifunk) + + $(call Package/luci/compiletpl,luci-app-ffwizard-leipzig,applications/luci-ffwizard-leipzig) + $(call Package/luci/compiletpl,luci-app-firewall,applications/luci-fw) + $(call Package/luci/compiletpl,luci-app-splash,applications/luci-splash) + $(call Package/luci/compiletpl,luci-app-statistics,applications/luci-statistics) + + $(call Package/luci/compiletpl,luci-sgi-haserl,libs/sgi-haserl) + $(call Package/luci/compiletpl,luci-sgi-webuci,libs/sgi-webuci) +endef $(eval $(call BuildPackage,luci-core)) diff --git a/libs/sgi-webuci/Makefile b/libs/sgi-webuci/Makefile index 9efe0fe14..5be84dcb3 100644 --- a/libs/sgi-webuci/Makefile +++ b/libs/sgi-webuci/Makefile @@ -1,4 +1,5 @@ include ../../build/config.mk +include ../../build/gccconfig.mk include ../../build/module.mk BOA_VERSION = 0.94.13