.PHONY: all install uninstall install install-local doc install-doc
-all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc) libe2api.so
+all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc)
-install: libe2api.so
+install:
# install symlinks for e2-2.1 compatibility
for i in $(SYMLINKS_2_1); do \
ln -sf e2 $(DESTDIR)$(BINDIR)/e2-$$i ; \
for i in $(LOCALTOOLS); do \
ln -sf e2 $(DESTDIR)$(BINDIR)/e2-$$i ; \
done
- install -m755 libe2api.so $(DESTDIR)$(LIBDIR)/
- install -m644 e2api.h $(DESTDIR)$(INCDIR)/
- install -m644 e2api.lua $(DESTDIR)$(LIBDIR)/
install-local: all
test -n "$(PROJECTDIR)"
for i in $(LOCALTOOLS); do \
rm -f $(DESTDIR)$(BINDIR)/e2-$$i ; \
done
- rm -f $(DESTDIR)$(LIBDIR)/libe2api.so
- rm -f $(DESTDIR)$(INCDIR)/e2api.h
- rm -f $(DESTDIR)$(LIBDIR)/e2api.lua
clean:
rm -f $(CLEAN_FILES)
$(LUAC) -o $@ $^
linux32: linux32.c
-
-libe2api.so: e2api.o
- $(CC) -shared -o $@ $^ -I../lua/lua-$(LUA_VERSION)/src -I. $(CFLAGS)
-
-e2api.o: e2api.h
-
-testapi: testapi.o libe2api.so
- $(CC) -o $@ $< -le2api $(LDFLAGS) -llua -lm -ldl -export-dynamic
+++ /dev/null
-/*
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, 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 <http://www.gnu.org/licenses/>.
-*/
-
-/*
- e2api.c
-
- C-API for accessing project information
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-#include "e2api.h"
-
-
-static char *error_message = NULL;
-
-
-lua_State *
-e2_init(char *project_path)
-{
- char rpath[ PATH_MAX + 1 ];
- char buffer[ PATH_MAX + 1 ];
- lua_State *lua;
-
- if(realpath(project_path, rpath) == NULL) {
- free(error_message);
- error_message = strdup(strerror(errno));
- return NULL;
- }
-
- strcpy(buffer, rpath);
- strcat(buffer, "/.e2/lib/e2/?.lc;");
- strcat(buffer, rpath);
- strcat(buffer, "/.e2/lib/e2/?.lua");
- setenv("LUA_PATH", buffer, 1);
- strcpy(buffer, rpath);
- strcat(buffer, "/.e2/lib/e2/?.so");
- setenv("LUA_CPATH", buffer, 1);
- lua = lua_open();
- luaL_openlibs(lua);
- lua_newtable(lua);
- lua_setglobal(lua, "arg");
- lua_pushstring(lua, rpath);
- lua_setglobal(lua, "e2api_rpath");
- strcpy(buffer, rpath);
- strcat(buffer, "/.e2/lib/e2/e2local.lc");
-
- if(luaL_loadfile(lua, buffer) != 0) {
- free(error_message);
- error_message = strdup(lua_tostring(lua, -1));
- lua_close(lua);
- return NULL;
- }
-
- if(lua_pcall(lua, 0, 0, 0) != 0) {
- free(error_message);
- error_message = strdup(lua_tostring(lua, -1));
- lua_close(lua);
- return NULL;
- }
-
- return lua;
-}
-
-
-void
-e2_exit(lua_State *lua)
-{
- free(error_message);
- lua_close(lua);
-}
-
-
-static int
-exit_handler(lua_State *lua)
-{
- free(error_message);
- error_message = strdup(lua_tostring(lua, -1));
- return luaL_error(lua, error_message);
-}
-
-
-int
-e2_info(lua_State *lua)
-{
- lua_getglobal(lua, "e2lib");
- lua_pushstring(lua, "abort_with_message");
- lua_pushcfunction(lua, exit_handler);
- lua_rawset(lua, -3);
- lua_getglobal(lua, "e2tool");
- lua_pushstring(lua, "collect_project_info");
- lua_rawget(lua, -2);
- lua_remove(lua, -2); /* remove e2tool table */
- lua_getglobal(lua, "e2api_rpath");
-
- if(lua_pcall(lua, 1, 1, 0) != 0) {
- free(error_message);
- error_message = strdup(lua_tostring(lua, -1));
- return 0;
- }
-
- return 1;
-}
-
-
-char *
-e2_error(void)
-{
- return error_message;
-}
+++ /dev/null
-/*
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, 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 <http://www.gnu.org/licenses/>.
-*/
-
-/*
- e2api.h
-*/
-
-
-#ifndef E2API_H
-#define E2API_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
-
- extern lua_State *e2_init(char *project_path);
- extern void e2_exit(lua_State *state);
- extern int e2_info(lua_State *state);
- extern char *e2_error(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
---[[
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, 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 <http://www.gnu.org/licenses/>.
-]]
-
--- e2api.lua
--- Use e2 from a Lua program.
-
-
-e2api = {}
-
-function e2api.init(project_path)
- package.path = project_path .. "/.e2/lib/e2/?.lc;" ..
- project_path .. "/.e2/lib/e2/?.lua;" .. package.path
- package.cpath = project_path .. "/.e2/lib/e2/?.so;" .. package.cpath
- e2api.rpath = project_path
- require("e2local")
- e2lib.abort_with_message = error
-end
-
-function e2api.info()
- return e2tool.collect_project_info(e2api.rpath)
-end
+++ /dev/null
-/*
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, 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 <http://www.gnu.org/licenses/>.
-*/
-
-/*
- testapi.c
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#include "e2api.h"
-
-
-int
-main(int argc, char *argv[])
-{
- lua_State *lua;
- char rpath[ PATH_MAX + 1 ];
-
- if(argc > 1) strcpy(rpath, argv[ 1 ]);
- else strcpy(rpath, ".");
-
- lua = e2_init(rpath);
-
- if(lua == NULL) {
- fprintf(stderr, "[e2api] Error: %s\n", e2_error());
- exit(EXIT_FAILURE);
- }
-
- if(e2_info(lua)) {
- lua_pushnil(lua);
-
- while (lua_next(lua, -2) != 0) {
- printf("%s: %s\n", lua_tostring(lua, -2), lua_typename(lua, lua_type(lua, -1)));
- lua_pop(lua, 1);
- }
-
- lua_pop(lua, 1);
- }
- else {
- fprintf(stderr, "[e2api] Error: %s\n", e2_error());
- exit(EXIT_FAILURE);
- }
-
- e2_exit(lua);
- return 0;
-}
+++ /dev/null
---[[
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, 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 <http://www.gnu.org/licenses/>.
-]]
-
--- testapi.lua
---
--- Test Lua e2 api
-
-
-dofile("e2api.lua")
-
-e2api.init(arg[ 1 ] or error("usage: lua e2api.lua PATH"))
-table.foreach(e2api.info(), print)
-
-rc = e2lib.callcmd_capture("exit 3")
-print(rc)