From a06481042646ef197fba0975f3f247f1205ea584 Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Wed, 20 Jan 2010 18:38:29 +0100 Subject: [PATCH] cleanup: clean up and simplify the build system Mainly: Nothing is built in the generic/ subdirectory any more now: global stuff is built in global/ local stuff is built in local/ libraries are no longer renamed with _local or _global prefixes. This is another step heading towards proper modularization - and installing each module on its own, for both local and global tools. Signed-off-by: Gordon Hecker --- generic/Makefile | 54 ++------------------------------- generic/e2util.c | 9 +----- {local => generic}/loader.lua | 12 ++++---- generic/luafile_ll.c | 8 +---- global/Makefile | 39 +++++++++++++++++++++++- global/e2-create-project.lua.in | 2 +- global/e2-fetch-project.lua.in | 2 +- global/e2-install-e2.lua.in | 2 +- global/e2.lua.in | 2 +- local/Makefile | 23 ++++++++++++-- 10 files changed, 74 insertions(+), 79 deletions(-) rename {local => generic}/loader.lua (94%) diff --git a/generic/Makefile b/generic/Makefile index 0a5cad1..0f7f581 100644 --- a/generic/Makefile +++ b/generic/Makefile @@ -32,36 +32,20 @@ TOPLEVEL = .. include $(TOPLEVEL)/make.vars -CLEAN_FILES = *~ *.lc *.o *.so lua-version-map.lua e2-su-2.2 +CLEAN_FILES = *~ *.lc *.o *.so lua-version-map.lua .PHONY: all install uninstall local install-local clean -all: e2generic_global.lc luafile_ll_global.so e2util_global.so e2-su-2.2 sha1.so +all: install: all - install -m 644 e2generic_global.lc $(DESTDIR)$(LIBDIR) - install -m 755 sha1.so $(DESTDIR)$(LIBDIR) - install -m 755 luafile_ll_global.so $(DESTDIR)$(LIBDIR) - install -m 755 e2util_global.so $(DESTDIR)$(LIBDIR) - install -m 4754 -o root -g $(E2_GROUP) e2-su-2.2 $(DESTDIR)$(BINDIR)/ uninstall: - rm -f $(DESTDIR)$(BINDIR)/e2-su-2.2 - rm -f $(DESTDIR)$(LIBDIR)/e2generic_global.lc - rm -f $(DESTDIR)$(LIBDIR)/luafile_ll_global.so - rm -f $(DESTDIR)$(LIBDIR)/e2util_global.so -local: e2generic_local.lc luafile_ll_local.so e2util_local.so sha1.so +local: install-local: local - mkdir -p $(LOCALLIBDIR) $(LOCALMAKDIR) - install -m 755 -d $(LOCALPLUGINDIR) - install -m 644 e2generic_local.lc $(LOCALLIBDIR) - install -m 755 sha1.so $(LOCALLIBDIR) - install -m 755 luafile_ll_local.so $(LOCALLIBDIR) - install -m 755 e2util_local.so $(LOCALLIBDIR) - install -m 644 e2-su-2.2.c $(LOCALMAKDIR) doc: for s in $(SUBDIRS) ; do \ @@ -76,40 +60,8 @@ install-doc: clean: rm -f $(CLEAN_FILES) -e2generic_global.lc: strict.lua collection.lua e2lib_global_prefix.lua \ - plugin.lua \ - e2lib.lua e2option.lua hash.lua tools.lua \ - transport.lua cache.lua url.lua scm.git.lua \ - luafile.lua lua-version-map.lua \ - error.lua lock.lua - $(BUILD_LUAC) -o $@ $^ - -e2generic_local.lc: strict.lua collection.lua e2lib_local_prefix.lua \ - e2lib.lua e2option.lua hash.lua tools.lua \ - transport.lua cache.lua url.lua scm.git.lua \ - luafile.lua lua-version-map.lua - $(LUAC) -o $@ $^ - %: %.in $(TOPLEVEL)/scripts/genscript.sh $< $@ -e2-su-2.2: e2-su-2.2.c - $(CC) $(CFLAGS) $(E2_SU_CFLAGS) $(LDFLAGS) $< -o $@ - -luafile_ll_global.so: luafile_ll.c - $(CC) $(CFLAGS) $(BUILD_LUA_CPPFLAGS) $(LDFLAGS) -shared -fPIC $< -o $@ - -e2util_global.so: e2util.c - $(CC) $(CFLAGS) $(BUILD_LUA_CPPFLAGS) $(LDFLAGS) -shared -fPIC $< -o $@ - -luafile_ll_local.so: luafile_ll.c - $(CC) -DLOCAL $(CFLAGS) $(LUA_CPPFLAGS) $(LDFLAGS) -shared -fPIC $< -o $@ - -e2util_local.so: e2util.c - $(CC) -DLOCAL $(CFLAGS) $(LUA_CPPFLAGS) $(LDFLAGS) -shared -fPIC $< -o $@ - %.o: %.c $(CC) $(CFLAGS) $(LUA_CPPFLAGS) $(LDFLAGS) -fPIC -o $@ -c $< - -sha1.so: sha1.o lsha1.o - $(CC) -o $@ -shared sha1.o lsha1.o diff --git a/generic/e2util.c b/generic/e2util.c index 7e1fed1..8fbf7b2 100644 --- a/generic/e2util.c +++ b/generic/e2util.c @@ -48,13 +48,6 @@ #include -#ifndef LOCAL -# define ENTRY_POINT luaopen_e2util_global -#else -# define ENTRY_POINT luaopen_e2util_local -#endif - - static char buffer[ PATH_MAX + 1 ]; @@ -761,7 +754,7 @@ static luaL_Reg lib[] = { }; -int ENTRY_POINT(lua_State *lua) +int luaopen_e2util(lua_State *lua) { luaL_register(lua, "e2util", lib); globalL = lua; diff --git a/local/loader.lua b/generic/loader.lua similarity index 94% rename from local/loader.lua rename to generic/loader.lua index 7f57fad..a95594f 100644 --- a/local/loader.lua +++ b/generic/loader.lua @@ -4,28 +4,28 @@ Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - + For more information have a look at http://www.e2factory.org e2factory is a registered trademark by emlix GmbH. This file is part of e2factory, the emlix embedded build system. - + e2factory is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . ]] -- loads required libraries -require("e2util_local") -require("luafile_ll_local") +require("e2util") +require("luafile_ll") diff --git a/generic/luafile_ll.c b/generic/luafile_ll.c index 72fbcb8..7b243cf 100644 --- a/generic/luafile_ll.c +++ b/generic/luafile_ll.c @@ -38,12 +38,6 @@ #include #include -#ifndef LOCAL -# define ENTRY_POINT luaopen_luafile_ll_global -#else -# define ENTRY_POINT luaopen_luafile_ll_local -#endif - static int lua_fopen(lua_State *lua) { @@ -263,7 +257,7 @@ static luaL_Reg lib[] = { { NULL, NULL } }; -int ENTRY_POINT(lua_State *lua) +int luaopen_luafile_ll(lua_State *lua) { luaL_register(lua, "luafile_ll", lib); return 1; diff --git a/global/Makefile b/global/Makefile index ee23657..98fc9b7 100644 --- a/global/Makefile +++ b/global/Makefile @@ -29,6 +29,8 @@ TOPLEVEL = .. include $(TOPLEVEL)/make.vars +VPATH = .:$(TOPLEVEL)/generic + SCRIPTS = GLOBALLUATOOLS = e2-create-project e2-fetch-project e2-install-e2 e2-root GLOBALSHTOOLS = e2-locate-project-root e2ssh @@ -39,7 +41,8 @@ CLEAN_FILES = *~ $(GLOBALTOOLS) *.lc e2 $(SCRIPTS) *.lua e2-su *.sh e2.conf .PHONY: all install uninstall clean all: e2 e2-root $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \ - $(GLOBALSHTOOLS:=.sh) e2.conf + $(GLOBALSHTOOLS:=.sh) e2.conf e2generic.lc sha1.so e2-su-2.2 \ + luafile_ll.so e2util.so install: all for i in $(GLOBALLUATOOLS) ; do \ @@ -58,6 +61,11 @@ install: all fi install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf.sample install -d -m 2775 -g $(E2_GROUP) $(DESTDIR)$(LOCALSTATEDIR) + install -m 644 e2generic.lc $(DESTDIR)$(LIBDIR) + install -m 755 sha1.so $(DESTDIR)$(LIBDIR) + install -m 755 luafile_ll.so $(DESTDIR)$(LIBDIR) + install -m 755 e2util.so $(DESTDIR)$(LIBDIR) + install -m 4754 -o root -g $(E2_GROUP) e2-su-2.2 $(DESTDIR)$(BINDIR)/ uninstall: for i in $(GLOBALLUATOOLS) ; do \ @@ -67,6 +75,10 @@ uninstall: for i in $(GLOBALSHTOOLS) ; do \ rm -f $(DESTDIR)$(BINDIR)/$$i ; \ done + rm -f $(DESTDIR)$(BINDIR)/e2-su-2.2 + rm -f $(DESTDIR)$(LIBDIR)/e2generic.lc + rm -f $(DESTDIR)$(LIBDIR)/luafile_ll.so + rm -f $(DESTDIR)$(LIBDIR)/e2util.so rm -f $(DESTDIR)$(TOOLDIR)/e2-root rm -f $(DESTDIR)$(BINDIR)/e2-su rm -f $(DESTDIR)$(BINDIR)/e2 @@ -107,3 +119,28 @@ e2-root: e2-root.lc e2.conf: e2.conf.in $(TOPLEVEL)/scripts/genscript.sh $< $@ +e2generic.lc: strict.lua collection.lua loader.lua \ + plugin.lua \ + e2lib.lua e2option.lua hash.lua tools.lua \ + transport.lua cache.lua url.lua scm.git.lua \ + luafile.lua lua-version-map.lua \ + error.lua lock.lua + $(BUILD_LUAC) -o $@ $^ + +sha1.so: sha1.o lsha1.o + +luafile_ll.so: luafile_ll.o + +e2util.so: e2util.o + +%.so: + $(CC) -shared -o $@ $^ $(LDFLAGS) + +CLEAN_FILES += *.o +%.o: %.c + $(CC) $(CFLAGS) $(BUILD_LUA_CPPFLAGS) -fPIC -c -o $@ $< + +CLEAN_FILES += e2-su-2.2 +e2-su-2.2: e2-su-2.2.c + $(CC) $(CFLAGS) $(E2_SU_CFLAGS) $(LDFLAGS) $< -o $@ + diff --git a/global/e2-create-project.lua.in b/global/e2-create-project.lua.in index 413ca27..eb33720 100755 --- a/global/e2-create-project.lua.in +++ b/global/e2-create-project.lua.in @@ -26,7 +26,7 @@ ]] require("buildconfig") -require("e2generic_global") +require("e2generic") e2lib.init() diff --git a/global/e2-fetch-project.lua.in b/global/e2-fetch-project.lua.in index 760efda..585a369 100755 --- a/global/e2-fetch-project.lua.in +++ b/global/e2-fetch-project.lua.in @@ -26,7 +26,7 @@ ]] require("buildconfig") -require("e2generic_global") +require("e2generic") e2lib.init() local e = new_error("fetching project failed") diff --git a/global/e2-install-e2.lua.in b/global/e2-install-e2.lua.in index b862740..683c9c9 100755 --- a/global/e2-install-e2.lua.in +++ b/global/e2-install-e2.lua.in @@ -26,7 +26,7 @@ ]] require("buildconfig") -require("e2generic_global") +require("e2generic") install_prefix = buildconfig.PREFIX diff --git a/global/e2.lua.in b/global/e2.lua.in index 609c6e0..9fb6e0a 100755 --- a/global/e2.lua.in +++ b/global/e2.lua.in @@ -29,7 +29,7 @@ package.path = "@LIBDIR@/?.lc;@LIBDIR@/?.lua" package.cpath = "@LIBDIR@/?.so" require("buildconfig") -require("e2generic_global") +require("e2generic") e2lib.init() e2option.documentation = [[ diff --git a/local/Makefile b/local/Makefile index d944cd9..caf89de 100644 --- a/local/Makefile +++ b/local/Makefile @@ -32,6 +32,8 @@ TOPLEVEL = .. include $(TOPLEVEL)/make.vars +VPATH = .:$(TOPLEVEL)/generic + CLEAN_FILES = *~ *.so linux32 *.lc *.o CFLAGS += -I. -I$(DESTDIR)$(INCDIR) -I$(DESTDIR)$(INCDIR)/lua-$(LUA_VERSION) \ -I../lua/lua-$(LUA_VERSION)/src -fPIC @@ -48,7 +50,7 @@ SYMLINKS_2_1 = lookup-server use-source prepare-cargo sync-results cleanup \ .PHONY: all install uninstall install install-local doc install-doc -all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc) +all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc) sha1.so luafile_ll.so e2util.so install: # install symlinks for e2-2.1 compatibility @@ -59,9 +61,10 @@ install: ln -sf e2 $(DESTDIR)$(BINDIR)/e2-$$i ; \ done -install-local: all +install-local: all install_sourcefiles test -n "$(PROJECTDIR)" mkdir -p $(LOCALBINDIR) $(LOCALMAKDIR) $(LOCALLIBDIR) + install -m 755 -d $(LOCALPLUGINDIR) install -m644 e2local.lc $(LOCALLIBDIR)/ for i in $(LOCALLUATOOLS); do \ install -m 755 $$i.lc $(LOCALBINDIR)/e2-$$i; \ @@ -73,6 +76,13 @@ install-local: all install -m644 linux32.c $(LOCALMAKDIR)/ ln -sf $(LIBEXECDIR)/e2-lua-$(LUA_VERSION) $(LOCALBINDIR)/e2-lua $(MAKE) -C make install-local + install -m 755 sha1.so $(LOCALLIBDIR) + install -m 755 luafile_ll.so $(LOCALLIBDIR) + install -m 755 e2util.so $(LOCALLIBDIR) + +.PHONY: install_sourcefiles +install_sourcefiles: e2-su-2.2.c + install -m 644 $^ $(LOCALMAKDIR) doc: for s in $(SUBDIRS) ; do \ @@ -123,3 +133,12 @@ e2local.lc: $(TOPLEVEL)/generic/strict.lua \ $(LUAC) -o $@ $^ linux32: linux32.c + +sha1.so: sha1.o lsha1.o + +luafile_ll.so: luafile_ll.o + +e2util.so: e2util.o + +%.so: + $(CC) -shared -o $@ $^ $(LDFLAGS) -- 2.39.5