Skip to content
Snippets Groups Projects
Commit 5b9982ba authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Fixed build scripts to properly call the linker with static libraries.

refs 3079
parent c536254e
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,9 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
public static final String INC_LIB_SUB_PACKAGE_NAME = "inc-lib";
/** Folder name for linkable static library files. */
private static final String LIB_SUB_PACKAGE_NAME = "lib";
/** Default library names to be used always. */
// Note that the order is important!
private static final String LIB_NAMES = "af3pihal rt pthread";
/** Constructor. */
public RaspberryPIExecutable(RaspberryPi modelElement) {
......@@ -87,7 +90,7 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
addLogicalComponentCode(deployedComponents, context, sourcePackage);
addEclipseCProjectFiles(sourcePackage, modelElement.getName());
addStaticLibraries(sourcePackage);
addConfigureAndMakedefsFiles(sourcePackage, modelElement.getName());
addConfigureAndMakedefsFiles(sourcePackage, modelElement.getName(), LIB_NAMES);
addMainFile(sourcePackage, deployedComponents, deployedPorts, context);
} catch(Exception ex) {
error(AF3PlatformRaspberryActivator.getDefault(), ex.getMessage(), ex);
......@@ -106,8 +109,9 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
}
/** Adds the build process files: configure and Makedefs. */
private void addConfigureAndMakedefsFiles(CSourcePackage sourcePackage, String binaryName) {
sourcePackage.addUnit(getConfigureFile(binaryName));
private void addConfigureAndMakedefsFiles(CSourcePackage sourcePackage, String binaryName,
String libNames) {
sourcePackage.addUnit(getConfigureFile(binaryName, libNames));
sourcePackage.addUnit(getMakedefsFile());
}
......
group ConfigureFile;
ConfigureFile(UNIT_NAME) ::= <<
ConfigureFile(UNIT_NAME, LIB_NAMES) ::= <<
#!/bin/sh
# The application's name.
......@@ -9,9 +9,11 @@ APPL="$UNIT_NAME$";
# The root path for this script.
if [ -z "\$ROOT" ]; then ROOT="."; fi;
# The include and source paths.
# The include, source and library paths.
IPATH=". inc-lib inc-gen inc";
VPATH=". src-lib src-gen src";
LPATH="lib";
LIBS="$LIB_NAMES$";
# The include file for common make definitions.
MAKEDEFS="Makedefs";
......@@ -46,6 +48,8 @@ echo ""
echo "# The include and source paths." \>\> \$MF;
echo "IPATH=\$IPATH" \>\> \$MF;
echo "VPATH=\$VPATH" \>\> \$MF;
echo "LPATH=\$LPATH" \>\> \$MF;
echo "LIBS=\$LIBS" \>\> \$MF;
echo "" \>\> \$MF;
echo "# Include the common make definitions." \>\> \$MF;
echo "include \$MAKEDEFS" \>\> \$MF;
......
......@@ -43,6 +43,8 @@ static void worker() {
$WORKER_CODE$
}
int global_debug_print_level = DEBUG_PRINT_LEVEL_NONE;
int main(int argc, char** argv) {
// initialize CAN interface with catalog implementation
can_catalog_initialize(can_device, $WAITING_SLEEPTIME_IN_MICROS$);
......
......@@ -23,7 +23,8 @@ endif
# The flags which are passed to the compiler and the linker.
CCFLAGS+=-std=c99 -Wall -pedantic -c \${patsubst %,-I%,\${subst :, ,\${IPATH}}}
LDFLAGS+=-std=c99 -Wall -pedantic
LDFLAGS+=-std=c99 -Wall -pedantic \${patsubst %,-L%,\${subst :, ,\${LPATH}}}
LIBFLAGS=\${patsubst %,-l%,\${subst :, ,\${LIBS}}}
# The default rules, i.e. the entry point.
all: \${BPATH}
......@@ -47,7 +48,7 @@ clean:
# The rule for linking an application.
\${BPATH}/%.run:
@echo "linking application '\${@}' ..."
@\${CROSSLD} \${LDFLAGS} -o \${@} \$(filter %.o %.a, \${^})
@\${CROSSLD} \${LDFLAGS} -o \${@} \$(filter %.o %.a, \${^}) \${LIBFLAGS}
# The rule to clean and remove generated Makefile
mrproper: clean
......
......@@ -66,9 +66,10 @@ public final class RasPiCTemplates {
}
/** Returns the 'configure' file used to create a Makefile. */
public static AbstractUnit getConfigureFile(String binaryName) {
public static AbstractUnit getConfigureFile(String binaryName, String libNames) {
StringTemplate template = makeTemplate("ConfigureFile.stg", "ConfigureFile");
template.setAttribute("UNIT_NAME", binaryName);
template.setAttribute("LIB_NAMES", libNames);
return createStaticContentSourceUnit("configure", template.toString(), true);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment