mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-22 02:06:42 +00:00
Changed the built libraries and updated INSTALL.md accordingly: - the 'servaldwrap' executable is now built - libservald.[a,so] now contains the full daemon executable - libservalclient.[a,so] contains the client library - libserval.a is no longer built Building the 'servaldwrap' executable is a step towards ensuring that the libservald.so library can be linked and executed, without requiring an Android build to reveal any failure. Added the SOURCE_PREFIX variable that allows the make to be invoked from within any current working directory, not just the serval-dna repository's root directory. Fixed the serval_version.o target to invoke the version_string.sh script with the --repository=DIR option, so that the build will work even if the current working directory is not within the serval-dna repository. Re-ordered and added some comments for clarity, and added some missing .PHONY declarations.
50 lines
1.4 KiB
C
50 lines
1.4 KiB
C
/*
|
|
Serval DNA - executable wrapper around shared library
|
|
Copyright 2010-2012 Paul Gardner-Stephen
|
|
Copyright 2012-2013 Serval Project Inc.
|
|
Copyright 2016 Flinders University
|
|
|
|
This program 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 2
|
|
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, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc,char **argv)
|
|
{
|
|
const char *libservald_path =
|
|
#ifdef ANDROID
|
|
"/data/data/org.servalproject/lib/libservald.so"
|
|
#else
|
|
"libservald.so"
|
|
#endif
|
|
;
|
|
const char *entry_point ="servald_main";
|
|
|
|
void *h = dlopen(libservald_path, RTLD_LAZY);
|
|
if (!h) {
|
|
fprintf(stderr, "%s\n", dlerror());
|
|
return 1;
|
|
}
|
|
|
|
int (*servald_main)(int, char **) = dlsym(h, entry_point);
|
|
if (!servald_main) {
|
|
fprintf(stderr, "Could not resolve %s in %s\n", entry_point, libservald_path);
|
|
return 1;
|
|
}
|
|
|
|
return (*servald_main)(argc, argv);
|
|
}
|