changed link argument sent to makefile:

instead of using linker, user may specify linker line including tools
This commit is contained in:
fros4943 2007-09-05 14:00:59 +00:00
parent 661a76408a
commit db74bb6566
2 changed files with 149 additions and 95 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile.cooja,v 1.18 2007/05/21 14:57:47 fros4943 Exp $
# $Id: Makefile.cooja,v 1.19 2007/09/05 14:04:17 fros4943 Exp $
## The COOJA Simulator Contiki platform Makefile
##
@ -48,7 +48,7 @@ endif ## QUICKSTART
OUTPUT_DIR = obj_cooja
LIBFILE = $(OUTPUT_DIR)/$(TYPEID).library
DEPFILE = $(OUTPUT_DIR)/$(TYPEID).a
ARFILE = $(OUTPUT_DIR)/$(TYPEID).a
MAPFILE = $(OUTPUT_DIR)/$(TYPEID).map
MAINFILE = $(OUTPUT_DIR)/$(TYPEID).co
@ -79,19 +79,19 @@ CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include
CFLAGS = $(CFLAGSNO)
### Define custom targets
$(LIBFILE): $(MAINFILE) $(PROJECT_OBJECTFILES) $(DEPFILE)
$(LIBFILE): $(MAINFILE) $(PROJECT_OBJECTFILES) $(ARFILE)
ifdef SYMBOLS
# Recreate symbols file and relink with final memory layout (twice)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
$(LD) -Map=$(MAPFILE) -shared $(LD_ARGS_1) -o $@ $^ $(LD_ARGS_2)
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
${CONTIKI}/tools/make-symbols-nm $(LIBFILE)
$(CC) $(CFLAGS) -c symbols.c -o $(OBJECTDIR)/symbols.o
$(LD) -Map=$(MAPFILE) -shared $(LD_ARGS_1) -o $@ $^ $(LD_ARGS_2)
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
else
$(LD) -Map=$(MAPFILE) -shared $(LD_ARGS_1) -o $@ $^ $(LD_ARGS_2)
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
endif
$(DEPFILE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)}
$(ARFILE): ${addprefix $(OBJECTDIR)/, $(CONTIKI_SOURCEFILES:.c=.o)}
$(AR) rcf $@ $^
ifndef WINDIR

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ContikiMoteTypeDialog.java,v 1.32 2007/05/28 07:26:51 fros4943 Exp $
* $Id: ContikiMoteTypeDialog.java,v 1.33 2007/09/05 14:00:59 fros4943 Exp $
*/
package se.sics.cooja.contikimote;
@ -217,10 +217,11 @@ public class ContikiMoteTypeDialog extends JDialog {
.getProjectDirs();
String projectText = null;
for (File projectDir : myDialog.moteTypeProjectDirs) {
if (projectText == null)
if (projectText == null) {
projectText = "'" + projectDir.getPath() + "'";
else
} else {
projectText += ", '" + projectDir.getPath() + "'";
}
}
myDialog.textProjectDirs.setText(projectText);
}
@ -525,30 +526,33 @@ public class ContikiMoteTypeDialog extends JDialog {
textField.setText("[enter description here]");
textField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateVisualFields();
}
});
}
}
public void removeUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateVisualFields();
}
});
}
}
public void changedUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateVisualFields();
}
});
}
}
});
@ -781,15 +785,19 @@ public class ContikiMoteTypeDialog extends JDialog {
showAdvancedCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
if (entireCoreInterfacePane != null)
if (entireCoreInterfacePane != null) {
entireCoreInterfacePane.setVisible(true);
if (entireSensorPane != null)
}
if (entireSensorPane != null) {
entireSensorPane.setVisible(true);
}
} else {
if (entireCoreInterfacePane != null)
if (entireCoreInterfacePane != null) {
entireCoreInterfacePane.setVisible(false);
if (entireSensorPane != null)
}
if (entireSensorPane != null) {
entireSensorPane.setVisible(false);
}
}
}
});
@ -1031,8 +1039,9 @@ public class ContikiMoteTypeDialog extends JDialog {
progressDialog.setVisible(true);
// Create temp output directory if not already exists
if (!ContikiMoteType.tempOutputDirectory.exists())
if (!ContikiMoteType.tempOutputDirectory.exists()) {
ContikiMoteType.tempOutputDirectory.mkdir();
}
// Parse selected sensors
Vector<String> sensors = new Vector<String>();
@ -1163,8 +1172,9 @@ public class ContikiMoteTypeDialog extends JDialog {
libraryCreatedOK = false;
} else {
libraryCreatedOK = true;
if (!libFile.exists() || !depFile.exists() || !mapFile.exists())
if (!libFile.exists() || !depFile.exists() || !mapFile.exists()) {
libraryCreatedOK = false;
}
}
if (libraryCreatedOK) {
@ -1207,39 +1217,44 @@ public class ContikiMoteTypeDialog extends JDialog {
String sensorString = "";
String externSensorDefs = "";
for (String sensor : sensors) {
if (!sensorString.equals(""))
if (!sensorString.equals("")) {
sensorString += ", ";
}
sensorString += "&" + sensor;
externSensorDefs += "extern const struct sensors_sensor " + sensor
+ ";\n";
}
if (!sensorString.equals(""))
if (!sensorString.equals("")) {
sensorString = "SENSORS(" + sensorString + ");";
else
} else {
sensorString = "SENSORS(NULL);";
}
// CORE INTERFACES
String interfaceString = "";
String externInterfaceDefs = "";
for (String coreInterface : coreInterfaces) {
if (!interfaceString.equals(""))
if (!interfaceString.equals("")) {
interfaceString += ", ";
}
interfaceString += "&" + coreInterface;
externInterfaceDefs += "SIM_INTERFACE_NAME(" + coreInterface + ");\n";
}
if (!interfaceString.equals(""))
if (!interfaceString.equals("")) {
interfaceString = "SIM_INTERFACES(" + interfaceString + ");";
else
} else {
interfaceString = "SIM_INTERFACES(NULL);";
}
// PROCESSES (including any default processes)
String userProcessString = "";
String externProcessDefs = "";
for (String process : userProcesses) {
if (!userProcessString.equals(""))
if (!userProcessString.equals("")) {
userProcessString += ", ";
}
userProcessString += "&" + process;
externProcessDefs += "PROCESS_NAME(" + process + ");\n";
}
@ -1248,8 +1263,9 @@ public class ContikiMoteTypeDialog extends JDialog {
String defaultProcesses[] = GUI.getExternalToolsSetting(
"CONTIKI_STANDARD_PROCESSES").split(";");
for (String process : defaultProcesses) {
if (!defaultProcessString.equals(""))
if (!defaultProcessString.equals("")) {
defaultProcessString += ", ";
}
defaultProcessString += "&" + process;
}
@ -1259,15 +1275,17 @@ public class ContikiMoteTypeDialog extends JDialog {
}
String processString;
if (!defaultProcessString.equals(""))
if (!defaultProcessString.equals("")) {
processString = "PROCINIT(" + defaultProcessString + ");";
else
} else {
processString = "PROCINIT(NULL);";
}
if (!userProcessString.equals(""))
if (!userProcessString.equals("")) {
processString += "\nAUTOSTART_PROCESSES(" + userProcessString + ");";
else
} else {
processString += "\nAUTOSTART_PROCESSES(NULL);";
}
// CHECK JNI CLASS AVAILABILITY
String libString = CoreComm.getAvailableClassName();
@ -1323,10 +1341,12 @@ public class ContikiMoteTypeDialog extends JDialog {
sourceFile.close();
} catch (Exception e) {
try {
if (destFile != null)
if (destFile != null) {
destFile.close();
if (sourceFile != null)
}
if (sourceFile != null) {
sourceFile.close();
}
} catch (Exception e2) {
}
@ -1362,48 +1382,53 @@ public class ContikiMoteTypeDialog extends JDialog {
identifier + ContikiMoteType.librarySuffix);
File mapFile = new File(ContikiMoteType.tempOutputDirectory,
identifier + ContikiMoteType.mapSuffix);
File depFile = new File(ContikiMoteType.tempOutputDirectory,
File arFile = new File(ContikiMoteType.tempOutputDirectory,
identifier + ContikiMoteType.dependSuffix);
// Recheck that contiki path exists
if (!contikiDir.exists()) {
if (errorStream != null)
if (errorStream != null) {
errorStream.println("Bad Contiki OS path");
}
logger.fatal("Contiki path does not exist: " + contikiDir.getAbsolutePath());
return false;
}
if (!contikiDir.isDirectory()) {
if (errorStream != null)
if (errorStream != null) {
errorStream.println("Bad Contiki OS path");
}
logger.fatal("Contiki path is not a directory");
return false;
}
if (libFile.exists()) {
if (errorStream != null)
if (errorStream != null) {
errorStream.println("Bad output filenames");
}
logger.fatal("Could not overwrite already existing library");
return false;
}
if (CoreComm.hasLibraryFileBeenLoaded(libFile)) {
if (errorStream != null)
if (errorStream != null) {
errorStream.println("Bad output filenames");
logger
.fatal("A library has already been loaded with the same name before");
}
logger.fatal("A library has already been loaded with the same name before");
return false;
}
if (depFile.exists()) {
if (errorStream != null)
if (arFile.exists()) {
if (errorStream != null) {
errorStream.println("Bad output filenames");
}
logger.fatal("Could not overwrite already existing dependency file");
return false;
}
if (mapFile.exists()) {
if (errorStream != null)
if (errorStream != null) {
errorStream.println("Bad output filenames");
}
logger.fatal("Could not overwrite already existing map file");
return false;
}
@ -1419,13 +1444,27 @@ public class ContikiMoteTypeDialog extends JDialog {
String sourceDirs = System.getProperty("PROJECTDIRS", "");
String sourceFileNames = "";
String ccFlags = GUI.getExternalToolsSetting("COMPILER_ARGS", "");
// Replace Java home references
if (ccFlags.contains("$(JAVA_HOME)")) {
String javaHome = (String) System.getenv().get("JAVA_HOME");
ccFlags = ccFlags.replace("$(JAVA_HOME)", javaHome);
}
// Prepare compilation command
String ccFlags = GUI.getExternalToolsSetting("COMPILER_ARGS", "");
String link1 = GUI.getExternalToolsSetting("LINK_COMMAND_1", "");
String link2 = GUI.getExternalToolsSetting("LINK_COMMAND_2", "");
link1 = link1.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));
link2 = link2.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));
ccFlags = ccFlags.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));
link1 = link1.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));
link2 = link2.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));
ccFlags = ccFlags.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));
link1 = link1.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));
link2 = link2.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));
ccFlags = ccFlags.replace("$(DEPFILE)", arFile.getPath().replace(File.separatorChar, '/'));
link1 = link1.replace("$(JAVA_HOME)", System.getenv().get("JAVA_HOME"));
link2 = link2.replace("$(JAVA_HOME)", System.getenv().get("JAVA_HOME"));
ccFlags = ccFlags.replace("$(JAVA_HOME)", System.getenv().get("JAVA_HOME"));
for (File sourceFile : sourceFiles) {
if (sourceFile.isDirectory()) {
@ -1458,8 +1497,8 @@ public class ContikiMoteTypeDialog extends JDialog {
String[] env = new String[]{
"CONTIKI=" + contikiDir.getPath().replace(File.separatorChar, '/'),
"TARGET=cooja", "TYPEID=" + identifier,
"LD_ARGS_1=" + GUI.getExternalToolsSetting("LINKER_ARGS_1", ""),
"LD_ARGS_2=" + GUI.getExternalToolsSetting("LINKER_ARGS_2", ""),
"LINK_COMMAND_1=" + link1,
"LINK_COMMAND_2=" + link2,
"EXTRA_CC_ARGS=" + ccFlags,
"SYMBOLS=" + (includeSymbols?"1":""),
"CC=" + GUI.getExternalToolsSetting("PATH_C_COMPILER"),
@ -1489,8 +1528,9 @@ public class ContikiMoteTypeDialog extends JDialog {
String readLine;
try {
while ((readLine = input.readLine()) != null) {
if (outputStream != null && readLine != null)
if (outputStream != null && readLine != null) {
outputStream.println(readLine);
}
}
} catch (IOException e) {
logger.warn("Error while reading from process");
@ -1503,8 +1543,9 @@ public class ContikiMoteTypeDialog extends JDialog {
String readLine;
try {
while ((readLine = err.readLine()) != null) {
if (errorStream != null && readLine != null)
if (errorStream != null && readLine != null) {
errorStream.println(readLine);
}
}
} catch (IOException e) {
logger.warn("Error while reading from process");
@ -1646,8 +1687,9 @@ public class ContikiMoteTypeDialog extends JDialog {
BufferedReader err = new BufferedReader(new InputStreamReader(p
.getErrorStream()));
if (err.ready())
if (err.ready()) {
logger.warn("Error occured during scan:");
}
while ((line = err.readLine()) != null) {
logger.warn(line);
}
@ -1711,8 +1753,9 @@ public class ContikiMoteTypeDialog extends JDialog {
BufferedReader err = new BufferedReader(new InputStreamReader(p
.getErrorStream()));
if (err.ready())
if (err.ready()) {
logger.warn("Error occured during scan:");
}
while ((line = err.readLine()) != null) {
logger.warn(line);
}
@ -1771,19 +1814,23 @@ public class ContikiMoteTypeDialog extends JDialog {
File sourceFile = new File(textCoreDir.getText(), sourceFilename);
boolean foundFile = sourceFile.exists();
if (!foundFile)
if (!foundFile) {
for (File projectDir : myGUI.getProjectDirs()) {
sourceFile = new File(projectDir, sourceFilename);
if (foundFile = sourceFile.exists())
if (foundFile = sourceFile.exists()) {
break;
}
}
}
if (!foundFile)
if (!foundFile) {
for (File projectDir : moteTypeProjectDirs) {
sourceFile = new File(projectDir, sourceFilename);
if (foundFile = sourceFile.exists())
if (foundFile = sourceFile.exists()) {
break;
}
}
}
if (!foundFile) {
// Die quietly
@ -2057,28 +2104,31 @@ public class ContikiMoteTypeDialog extends JDialog {
ActionListener,
DocumentListener {
public void insertUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
pathsWereUpdated();
}
});
}
}
public void removeUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
pathsWereUpdated();
}
});
}
}
public void changedUpdate(DocumentEvent e) {
if (myDialog.isVisible())
if (myDialog.isVisible()) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
pathsWereUpdated();
}
});
}
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("cancel")) {
@ -2090,8 +2140,9 @@ public class ContikiMoteTypeDialog extends JDialog {
File objectDir = ContikiMoteType.tempOutputDirectory;
if (objectDir.exists() && objectDir.isDirectory()) {
File[] objectFiles = objectDir.listFiles();
for (File objectFile : objectFiles)
for (File objectFile : objectFiles) {
objectFile.delete();
}
objectDir.delete();
}
@ -2189,10 +2240,11 @@ public class ContikiMoteTypeDialog extends JDialog {
moteTypeProjectDirs = newProjectDirs;
String projectDirText = null;
for (File projectDir : newProjectDirs) {
if (projectDirText == null)
if (projectDirText == null) {
projectDirText = "'" + projectDir.getPath() + "'";
else
} else {
projectDirText += " + '" + projectDir.getPath() + "'";
}
}
textProjectDirs.setText(projectDirText);
@ -2431,13 +2483,15 @@ public class ContikiMoteTypeDialog extends JDialog {
}
}
if (!processWasSelected || sourceFilename == null)
if (!processWasSelected || sourceFilename == null) {
return;
}
autoSelectDependencyProcesses(processName, sourceFilename, true);
} else
} else {
logger.warn("Unhandled action: " + e.getActionCommand());
}
createButton.setEnabled(libraryCreatedOK = false);