The International Simutrans Forum

 

Author Topic: Makefile for pak128.britain[standard + ex] -- and some questions  (Read 4340 times)

0 Members and 1 Guest are viewing this topic.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
A few nights ago i tried to write a Makefile to build  pak128.britain standard and experimental, pulled from github. My frustration with mose.py was high enough to start this. (btw why mose at all instead of gnu make?) It worked well enough to let it run, however i've got a couple of questions:

first i'm missing a couple of files in my build (e.g. symbol.BigLogo.pak, demo.sve) are they included in the repository at all? Or do i have to look more carefully, and they're built not just directly from dirs.

does contain ground.Outside.pak all dat files of grounds dir, or only Outside.pak?

in view of possible later releases of my Makefile, how important is it to follow the naming conventions? eg. you capitalized the pak filenames, while the directories from which they are built were not. Such things can be done but it's a bit awkward in the makefile.

Why is the -Ex and .all required in the filenames? As far as i understood it this would make sense if the files would be built, for both paksets and then mixed together to assemble the paksets. But with git repositories, it's much more sense to have all sources, also those identical in both, in both branches? Please correct me if i'm wrong, it's not unlikely i completely missunderstood the workflow.

By the way, having Boats192 in Boats/192 makes it difficult to generalize, gui/gui64 is quite easy and can be well generalized in the Makefile

EDIT: changed the subject line, to let me accomodate the release of the files in this thread
EDIT: changed topic to make it clearer it is for both branches
« Last Edit: June 26, 2010, 11:37:10 PM by sdog »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: some questions about building pak128.britain(-experimental)
« Reply #1 on: May 30, 2010, 09:59:34 PM »
Sdog,

I haven't been involved in automated building of the pakset yet (although I plan to have a go at setting it up when/if I get the time), but the -Ex naming convention is specific to Experimental, the idea being to differentiate the .pak files compiled for Experimental from those compiled for Standard. It is not strictly necessary, but it is the naming convention for Pak128.Britain-Ex, and should be respected where possible to avoid, for example, duplicate items when upgrading.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: some questions about building pak128.britain(-experimental)
« Reply #2 on: May 30, 2010, 11:06:23 PM »
adding a Brit prefix and -Ex suffix is straightforward. But changing the first char of the directory (and later name strings) to upercase is not. It would be easy with sed, but not with gnu make functions. But using those outside programs will likely break the Makefile for windows.*

better news, i think i can almost cope with boats192 now.

could you please clarify how grounds should be treated? from the makeALL.mos it looked like all *.dat in grounds/ are paked into ground.Outside.pak not just ground.Outside.dat. This also looks like it in the pak128 release: 852K   ground.Outside.pak. Is this assumption correct?

*this is something i can't test by the way. i killed my win a couple of months ago by accident and wasn't able to reinstall it.


 
« Last Edit: May 30, 2010, 11:17:09 PM by sdog »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: some questions about building pak128.britain(-experimental)
« Reply #3 on: May 30, 2010, 11:20:18 PM »
Sdog,

I can't answer all of your questions (The Hood is best placed to do that), but I can confirm that everything in the grounds subdirectory goes into ground.Outside.pak.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #4 on: May 31, 2010, 12:20:13 AM »
So here's the first version of the Makefile for experimental. I'll do some further testing, and changing variables for standard to-morrow.
Code: [Select]
# Just run
#   make clean all archives
# to get fresh and ready to deploy .tbz2 and .zip archives
CONFIG ?= config.default
-include $(CONFIG)

MAKEOBJ ?= ./makeobj

PAKNAME ?= pak128.britain.testing
DESTDIR  ?= ./
PAKDIR   ?= $(DESTDIR)/$(PAKNAME)
DESTFILE ?= $(PAKNAME)

NAMEPREFIX ?=
NAMESUFFIX ?=

CPFILES ?= compat.tab

DIRS64 :=
DIRS64 += gui/gui64

DIRS128 :=
DIRS128 += attractions
DIRS128 += boats
DIRS128 += bus
DIRS128 += citybuildings
DIRS128 += citycars
DIRS128 += depots
DIRS128 += goods
DIRS128 += grounds
DIRS128 += industry
DIRS128 += london-underground
DIRS128 += maglev
DIRS128 += pedestrians
DIRS128 += smokes
DIRS128 += stations
DIRS128 += townhall
DIRS128 += trains
DIRS128 += trams
DIRS128 += trees
DIRS128 += ways
DIRS128 += gui/gui128

DIRS192 :=
DIRS192 += boats/192

DIRS224 :=
DIRS224 += boats/224


DIRS := $(DIRS64) $(DIRS128) $(DIRS192) $(DIRS224)

#generating filenames
#with this function the filenames are assembled, by removing the dir, adding prefix
#and suffix and excluding grounds
#all dat files in the grounds dir are paked into ground.Outside.pak
make_name = $(subst $(NAMEPREFIX)grounds$(NAMESUFFIX),ground.Outside.pak,$(NAMEPREFIX)$(notdir $1)$(NAMESUFFIX))


.PHONY: $(DIRS) copy tar zip clean

all: copy $(DIRS)

archives: tar zip

tar: $(DESTFILE).tbz2
zip: $(DESTFILE).zip

$(DESTFILE).tbz2: $(PAKDIR)
@echo "===> TAR $@"
@tar cjf $@ $(DESTDIR)

$(DESTFILE).zip: $(PAKDIR)
@echo "===> ZIP $@"
@zip -rq $@ $(DESTDIR)

copy:
@echo "===> COPY"
@mkdir $(PAKDIR)
@cp -prt $(PAKDIR) $(CPFILES)

$(DIRS64):
@echo "===> PAK64 $@"
@mkdir -p $(PAKDIR)
$(MAKEOBJ) quiet PAK $(PAKDIR)/$(call make_name,$@) $@/ > /dev/null

$(DIRS128):
@echo "===> PAK128 $@"
@mkdir -p $(PAKDIR)
$(MAKEOBJ) quiet PAK128 $(PAKDIR)/$(call make_name,$@) $@/ > /dev/null

#since the subdirectories in the boats dir lack a boats, the / is removed for the filename
#this will cause trouble as soon as files with a different structure are included.
#(e.g. planes/planes192)
$(DIRS192):
@echo "===> PAK192 $@"
@mkdir -p $(PAKDIR)
@$(MAKEOBJ) quiet PAK192 $(PAKDIR)/$(call make_name,$(subst /,,$@)) $@/ > /dev/null

$(DIRS224):
@echo "===> PAK224 $@"
@mkdir -p $(PAKDIR)
@$(MAKEOBJ) quiet PAK224 $(PAKDIR)/$(call make_name,$(subst /,,$@)) $@/ > /dev/null

clean:
@echo "===> CLEAN"
@rm -fr $(PAKDIR) $(DESTFILE).tbz2 $(DESTFILE).zip

config.template:
Code: [Select]


#makeobject executable (default ./makeobj)
MAKEOBJ = ./makeobj-ex

#name of the pakset the pakset destination dir is also named after it
PAKNAME = pak128.britain-ex

#Name of the tar and zip files. default is $(PAKNAME).
#DESTFILE =

#path where the pakset dir should be built (default ./)
#DESTDIR  =


#prefix and suffix for pak files (default empty)
NAMEPREFIX = brit-
NAMESUFFIX = -ex


#files and dirs to be copied into the pakset directory
#(default compat.tab only)
CPFILES = compat.tab readme.txt README
CPFILES += sound/ config/ text/ doc/

i'm breaking your filename convention a bit however. instead of BritAttractions-Ex.pak this Makefile makes brit-attractions-ex.pak. UCing the first char of the directory name is not achievable for me in Makefiles.
« Last Edit: May 31, 2010, 12:24:53 AM by sdog »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #5 on: May 31, 2010, 08:39:10 AM »
Sdog,

thank you very much - that is most kind. How does one use a makefile on a Windows system...?

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #6 on: June 18, 2010, 03:26:20 PM »
could you please clarify how grounds should be treated? from the makeALL.mos it looked like all *.dat in grounds/ are paked into ground.Outside.pak not just ground.Outside.dat. This also looks like it in the pak128 release: 852K   ground.Outside.pak. Is this assumption correct?

The core code for Simutrans looks for ground.Outside.pak in order to identify whether it has found a .pak folder or not.  makeALL.mos actually packs each ground file into its own pak (so there are eleven ground.*.pak files).  This is actually stupid.  Ideally all the ground except for ground.Outside.pak would be in a BritGround.pak file.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #7 on: June 18, 2010, 05:23:08 PM »
Hmm, when I make it manually, I just put everything into ground.Outside.pak, which works fine.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #8 on: June 18, 2010, 06:53:26 PM »
The filename is hardcoded as the best candidate for checking tile size. There is at the moment no better way to determine this, I'm afraid...?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9353
  • Languages: De,EN,JP
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #9 on: June 18, 2010, 10:28:00 PM »
It is not a good idea to pak everything into ground.outside.pak, as this file will be loaded twice and will be parsed also for every pak directory to determine, if it contains a pak or not.

You can have also a look at the Makefile for pak64, which is also in the SVN together with pak128.Britain.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #10 on: June 18, 2010, 10:39:45 PM »
the pak64 Makefile was very helpfull when i created the Makefile, which is based on the 64 file.

I can't think of an easy way to address the grounds issue in make, without using a script or doing filesystem operations. My suggestion is to take it out of the grounds dir and treat it independently.

update: Just did this, and pushed it to github.

Thanks for restructuring the boats/boats* directories! I can reduce the complexity of the makefile.:wq

update:
i also updated the Makefile and directory structure for standard in the same way. If you want to integrate the suggestion to experimental, please do it for standard too.
I haven't tested my changes to makeAll.mos (i always have trouble geting it to round properly)
« Last Edit: June 19, 2010, 01:17:20 AM by sdog »

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Makefile for pak128.britain[-ex] -- and some questions
« Reply #11 on: June 26, 2010, 11:35:39 PM »
James, you pulled and merged the changes into experimental. Did you do something for standard too? Or should i contact The Hood?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Makefile for pak128.britain[standard + ex] -- and some questions
« Reply #12 on: June 27, 2010, 12:16:56 AM »
You'll need to ask The Hood about Standard :-)