Skip to content

Commit

Permalink
Modified the generated Makefiles for models.
Browse files Browse the repository at this point in the history
 - "clean" should not be a dependency for the main target.
     If we have multiple threads making the target then they will try to clean and compile at the same time.
 - do "clean"s explicitly
 - Made sure that *_records.c is compiled always. (i.e. The executable will be compiled too)
 - Also the main target(executable) should be dependent on ModelName_functions.c since this is not compiled separately but is included in the ModelName.c file.

Now we can run the test-suite(most of it, at least) with "make -j" on windows. 

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11259 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed Mar 1, 2012
1 parent 9468fdc commit 3f54d84
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Compiler/susan_codegen/SimCode/CodegenC.tpl
Expand Up @@ -2115,18 +2115,28 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -lSimulationRuntimeC <%makefileParams.ldflags%>
SENDDATALIBS=<%makefileParams.senddatalibs%>
PERL=perl
MAINFILE=<%fileNamePrefix%><% if acceptMetaModelicaGrammar() then ".conv"%>.c
MAINOBJ=<%fileNamePrefix%><% if acceptMetaModelicaGrammar() then ".conv"%>.o
FILEPREFIX=<%fileNamePrefix%>
MAINFILE=$(FILEPREFIX)<% if acceptMetaModelicaGrammar() then ".conv"%>.c
MAINOBJ=$(FILEPREFIX)<% if acceptMetaModelicaGrammar() then ".conv"%>.o
GENERATEDFILES=$(MAINFILE) $(FILEPREFIX)_functions.c $(FILEPREFIX)_functions.h $(FILEPREFIX)_records.c $(FILEPREFIX).makefile

.PHONY: clean <%fileNamePrefix%>
<%fileNamePrefix%>: clean $(MAINOBJ) <%fileNamePrefix%>_records.o
<%\t%> $(CXX) -I. -o <%fileNamePrefix%>$(EXEEXT) $(MAINOBJ) <%fileNamePrefix%>_records.o $(CPPFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> $(CFLAGS) $(LDFLAGS) -linteractive $(SENDDATALIBS) <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%>
<%fileNamePrefix%>.conv.c: <%fileNamePrefix%>.c
<%\t%> $(PERL) <%makefileParams.omhome%>/share/omc/scripts/convert_lines.pl $< $@.tmp
<%\t%> @mv $@.tmp $@
$(MAINOBJ): $(MAINFILE) <%fileNamePrefix%>_functions.c <%fileNamePrefix%>_functions.h
.PHONY: omc_main_target clean bundle

# This is to make sure that <%fileNamePrefix%>_records.c is always compiled.
.PHONY: $(FILEPREFIX)_records.c

omc_main_target: $(MAINOBJ) $(FILEPREFIX)_records.o $(FILEPREFIX)_functions.c $(FILEPREFIX)_functions.h
<%\t%>$(CXX) -I. -o $(FILEPREFIX)$(EXEEXT) $(MAINOBJ) $(FILEPREFIX)_records.o $(CPPFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> $(CFLAGS) $(LDFLAGS) -linteractive $(SENDDATALIBS) <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%>

<%fileNamePrefix%>.conv.c: $(FILEPREFIX).c
<%\t%>$(PERL) <%makefileParams.omhome%>/share/omc/scripts/convert_lines.pl $< $@.tmp
<%\t%>@mv $@.tmp $@

clean:
<%\t%> @rm -f <%fileNamePrefix%>_records.o $(MAINOBJ)
<%\t%>@rm -f $(FILEPREFIX)_records.o $(MAINOBJ)

bundle:
<%\t%>@tar -cvf $(FILEPREFIX)_Files.tar $(GENERATEDFILES)
>>
end simulationMakefile;

Expand Down

0 comments on commit 3f54d84

Please sign in to comment.