2010-08-14 14:50:06 +00:00
# $Id$
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
#
2015-05-02 09:59:55 +00:00
# Building requires GRFCodec.
2010-08-14 14:50:06 +00:00
#
2015-05-02 09:59:55 +00:00
# Recent versions (including sources) can be found at:
2010-08-14 14:50:06 +00:00
# http://www.openttd.org/download-grfcodec
#
2015-05-02 09:59:55 +00:00
# The mercurial repository can be found at:
2010-08-14 14:50:06 +00:00
# http://hg.openttdcoop.org/grfcodec
#
ROOT_DIR = !!ROOT_DIR!!
GRF_DIR = $( ROOT_DIR) /media/extra_grf
2013-04-24 20:30:02 +00:00
BASESET_DIR = $( ROOT_DIR) /media/baseset
LANG_DIR = $( ROOT_DIR) /src/lang
2011-11-14 21:38:36 +00:00
BIN_DIR = !!BIN_DIR!!/baseset
2010-08-14 14:50:06 +00:00
OBJS_DIR = !!GRF_OBJS_DIR!!
2010-08-19 08:07:19 +00:00
OS = !!OS!!
2010-08-21 10:57:01 +00:00
STAGE = !!STAGE!!
2010-08-14 14:50:06 +00:00
# Check if we want to show what we are doing
i f d e f V E R B O S E
Q =
E = @true
e l s e
Q = @
E = @echo
e n d i f
2011-12-05 20:11:42 +00:00
GRFCODEC := !!GRFCODEC!!
NFORENUM := !!NFORENUM!!
2013-02-26 20:48:50 +00:00
CC_BUILD := !!CC_BUILD!!
2010-08-19 08:07:19 +00:00
MD5SUM := $( shell [ " $( OS) " = "OSX" ] && echo "md5 -r" || echo "md5sum" )
2010-08-14 14:50:06 +00:00
# Some "should not be changed" settings.
2011-08-20 12:52:45 +00:00
NFO_FILES := $( GRF_DIR) /*.nfo $( GRF_DIR) /rivers/*.nfo
PNG_FILES := $( GRF_DIR) /*.png $( GRF_DIR) /rivers/*.png
2010-08-14 14:50:06 +00:00
# Build the GRF.
2011-12-05 20:11:42 +00:00
i f d e f G R F C O D E C
2017-01-14 15:48:19 +00:00
all : $( BIN_DIR ) /openttd .grf $( BIN_DIR ) /orig_extra .grf $( BIN_DIR ) /orig_dos .obg $( BIN_DIR ) /orig_dos_de .obg $( BIN_DIR ) /orig_win .obg $( BIN_DIR ) /orig_dos .obs $( BIN_DIR ) /orig_win .obs $( BIN_DIR ) /no_sound .obs $( BIN_DIR ) /orig_win .obm $( BIN_DIR ) /no_music .obm
2011-12-05 20:11:42 +00:00
e l s e
all :
e n d i f
2010-08-14 14:50:06 +00:00
2013-04-24 20:30:02 +00:00
$(OBJS_DIR)/langfiles.tmp : $( LANG_DIR ) /*.txt
$( E) '$(STAGE) Collecting baseset translations'
$( Q) cat $^ > $@
2017-01-14 15:48:19 +00:00
$(BIN_DIR)/%.obg : $( BASESET_DIR ) /%.obg $( BIN_DIR ) /orig_extra .grf $( OBJS_DIR ) /langfiles .tmp $( BASESET_DIR ) /translations .awk
2013-04-24 20:30:02 +00:00
$( E) '$(STAGE) Updating $(notdir $@)'
2017-01-14 15:48:19 +00:00
$( Q) sed 's/^ORIG_EXTRA.GRF = *[0-9a-f]*$$/ORIG_EXTRA.GRF = ' ` $( MD5SUM) $( BIN_DIR) /orig_extra.grf | sed 's@ .*@@' ` '/' $< > $@ .tmp
2013-04-24 20:30:02 +00:00
$( Q) awk -v langfiles = '$(OBJS_DIR)/langfiles.tmp' -f $( BASESET_DIR) /translations.awk $@ .tmp >$@
$( Q) rm $@ .tmp
$(BIN_DIR)/%.obs : $( BASESET_DIR ) /%.obs $( OBJS_DIR ) /langfiles .tmp $( BASESET_DIR ) /translations .awk
$( E) '$(STAGE) Updating $(notdir $@)'
$( Q) awk -v langfiles = '$(OBJS_DIR)/langfiles.tmp' -f $( BASESET_DIR) /translations.awk $< >$@
2010-08-14 14:50:06 +00:00
2013-04-24 20:30:02 +00:00
$(BIN_DIR)/%.obm : $( BASESET_DIR ) /%.obm $( OBJS_DIR ) /langfiles .tmp $( BASESET_DIR ) /translations .awk
$( E) '$(STAGE) Updating $(notdir $@)'
$( Q) awk -v langfiles = '$(OBJS_DIR)/langfiles.tmp' -f $( BASESET_DIR) /translations.awk $< >$@
# Compile extra grf
2017-01-14 15:48:19 +00:00
$(BIN_DIR)/openttd.grf : $( PNG_FILES ) $( NFO_FILES ) $( GRF_DIR ) /assemble_nfo .awk
2010-08-21 10:57:01 +00:00
$( E) '$(STAGE) Assembling openttd.nfo'
2017-01-14 15:48:19 +00:00
$( Q) -mkdir -p $( OBJS_DIR) /sprites
2010-10-24 15:49:38 +00:00
$( Q) -cp $( PNG_FILES) $( OBJS_DIR) /sprites 2> /dev/null
2014-07-30 17:21:42 +00:00
$( Q) awk -f $( GRF_DIR) /assemble_nfo.awk $( GRF_DIR) /openttd.nfo > $( OBJS_DIR) /sprites/openttd.nfo
2011-12-05 20:11:42 +00:00
$( Q) $( NFORENUM) -s $( OBJS_DIR) /sprites/openttd.nfo
2010-08-21 10:57:01 +00:00
$( E) '$(STAGE) Compiling openttd.grf'
2012-02-24 22:19:45 +00:00
$( Q) $( GRFCODEC) -n -s -e -p1 $( OBJS_DIR) /openttd.grf
2013-04-24 20:30:02 +00:00
$( Q) cp $( OBJS_DIR) /openttd.grf $( BIN_DIR) /openttd.grf
2010-08-14 14:50:06 +00:00
2017-01-14 15:48:19 +00:00
# The copy operation of PNG_FILES is duplicated from the target 'openttd.grf', thus those targets may not run in parallel.
$(BIN_DIR)/orig_extra.grf : $( PNG_FILES ) $( NFO_FILES ) $( GRF_DIR ) /assemble_nfo .awk | $( BIN_DIR ) /openttd .grf
$( E) '$(STAGE) Assembling orig_extra.nfo'
$( Q) -mkdir -p $( OBJS_DIR) /sprites
$( Q) -cp $( PNG_FILES) $( OBJS_DIR) /sprites 2> /dev/null
$( Q) awk -f $( GRF_DIR) /assemble_nfo.awk $( GRF_DIR) /orig_extra.nfo > $( OBJS_DIR) /sprites/orig_extra.nfo
$( Q) $( NFORENUM) -s $( OBJS_DIR) /sprites/orig_extra.nfo
$( E) '$(STAGE) Compiling orig_extra.grf'
$( Q) $( GRFCODEC) -n -s -e -p1 $( OBJS_DIR) /orig_extra.grf
$( Q) cp $( OBJS_DIR) /orig_extra.grf $( BIN_DIR) /orig_extra.grf
2010-08-14 14:50:06 +00:00
# Clean up temporary files.
clean :
$( Q) rm -f *.bak *.grf
2010-09-05 21:50:59 +00:00
# Clean up temporary files
2010-08-14 14:50:06 +00:00
mrproper : clean
$( Q) rm -fr sprites
.PHONY : all mrproper depend clean