The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: neroden on April 15, 2010, 01:24:35 am

Title: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: neroden on April 15, 2010, 01:24:35 am
This is a Makefile patch which eliminates some annoying behavior which causes my tree to continually differ from upstream.

Previously makeobj/Makefile had to be edited directly to set the ostype.

Now it uses config.default from the parent directory.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: Dwachs on April 15, 2010, 06:14:17 am
While you are at it: Now makeobj and simutrans requires log.cc to be compiled differently. debug_t::fatal(..) compiles differently with/without graphics. Maybe you know a Makefile trick to generate two different log.o's ? One for simutrans, one for makeobj.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: prissi on April 15, 2010, 10:27:45 am
Actually, for BeOS, I have to use the Linux switch ... The makeobj makefile was never updated to the system simutrans uses. This would make most sense imho.

For the problem in question I would jsut suggest to delete log.o after linking makeobj always.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: neroden on April 15, 2010, 04:15:04 pm
While you are at it: Now makeobj and simutrans requires log.cc to be compiled differently. debug_t::fatal(..) compiles differently with/without graphics. Maybe you know a Makefile trick to generate two different log.o's ? One for simutrans, one for makeobj.

Well, I actually do.  It's totally straightforward if you think about it -- just build a different object file from the .c file, and link that one instead of log.o:
Code: [Select]
makeobj-log.o: log.cc
   $(CXX) $(CXXFLAGS) -DMAKEOBJ -o $@ -c $<
(I probably didn't get the directories or other details right there, of course.)

EDIT: it gets messy in the presence of automatic dependency generation, however.

Note that simtools.o is different in MAKEOBJ too.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: neroden on April 15, 2010, 04:20:22 pm
Actually, for BeOS, I have to use the Linux switch ...
Interesting, why?  The only difference (in makeobj) is that -lm is linked with the Linux switch.  This could be added to the BeOS configuration, no problem.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: prissi on April 15, 2010, 08:40:10 pm
You are right about BeOS. Aparently I changed this once and just kept it that way.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: neroden on April 17, 2010, 05:11:43 pm
Aaaand, here's the revised, dramatic patch which reconstructs the entire makeobj build to use a very similar system to the simutrans build.

I had to make an altered version of common.mk, hence "uncommon.mk".

Works on Linux.  If it's broken anywhere else it should work with minor CXXFLAGS or STD_LIBS changes.
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: prissi on April 17, 2010, 10:12:31 pm
Well, order of libraries under mingw must be exactly in this order in the makefile but otherwise worked fine.

By the way, now makeobj is 20 kB larger, might be the new compiler settings ...
Title: Re: [fix] Compile makeobj for the same OSTYPE as simutrans
Post by: neroden on April 17, 2010, 11:30:17 pm
Well, order of libraries under mingw must be exactly in this order in the makefile but otherwise worked fine.

By the way, now makeobj is 20 kB larger, might be the new compiler settings ...

Oh, probably that's the change in optimization settings.  If we care about size we should use -Os instead of -O2.
Title: Commit appears to have lost a file
Post by: neroden on April 18, 2010, 06:05:28 pm
The commit to SVN seems to have lost the file makeobj/uncommon.mk

The patch will not work without it; please commit.

Extra copy attached (zipped).