Update readme.md
[openttd-joker.git] / Makefile.grf.in
blob1625b9e4c0d068f368557d31da369cb5b881d035
1 # $Id$
3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
8 # Building requires GRFCodec.
10 # Recent versions (including sources) can be found at:
11 #  http://www.openttd.org/download-grfcodec
13 # The mercurial repository can be found at:
14 #  http://hg.openttdcoop.org/grfcodec
18 ROOT_DIR = !!ROOT_DIR!!
19 GRF_DIR  = $(ROOT_DIR)/media/extra_grf
20 BASESET_DIR = $(ROOT_DIR)/media/baseset
21 LANG_DIR = $(ROOT_DIR)/src/lang
22 BIN_DIR  = !!BIN_DIR!!/baseset
23 OBJS_DIR = !!GRF_OBJS_DIR!!
24 OS       = !!OS!!
25 STAGE    = !!STAGE!!
27 # Check if we want to show what we are doing
28 ifdef VERBOSE
29         Q =
30         E = @true
31 else
32         Q = @
33         E = @echo
34 endif
36 GRFCODEC := !!GRFCODEC!!
37 NFORENUM := !!NFORENUM!!
38 CC_BUILD := !!CC_BUILD!!
39 MD5SUM   := $(shell [ "$(OS)" = "OSX" ] && echo "md5 -r" || echo "md5sum")
41 # Some "should not be changed" settings.
42 NFO_FILES    := $(GRF_DIR)/*.nfo $(GRF_DIR)/rivers/*.nfo
43 PNG_FILES    := $(GRF_DIR)/*.png $(GRF_DIR)/rivers/*.png
45 # Build the GRF.
46 ifdef GRFCODEC
47 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
48 else
49 all:
50 endif
52 $(OBJS_DIR)/langfiles.tmp: $(LANG_DIR)/*.txt
53         $(E) '$(STAGE) Collecting baseset translations'
54         $(Q) cat $^ > $@
56 $(BIN_DIR)/%.obg: $(BASESET_DIR)/%.obg $(BIN_DIR)/orig_extra.grf $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
57         $(E) '$(STAGE) Updating $(notdir $@)'
58         $(Q) sed 's/^ORIG_EXTRA.GRF    = *[0-9a-f]*$$/ORIG_EXTRA.GRF    = '`$(MD5SUM) $(BIN_DIR)/orig_extra.grf | sed 's@ .*@@'`'/' $< > $@.tmp
59         $(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $@.tmp >$@
60         $(Q) rm $@.tmp
62 $(BIN_DIR)/%.obs: $(BASESET_DIR)/%.obs $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
63         $(E) '$(STAGE) Updating $(notdir $@)'
64         $(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
66 $(BIN_DIR)/%.obm: $(BASESET_DIR)/%.obm $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
67         $(E) '$(STAGE) Updating $(notdir $@)'
68         $(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
70 # Compile extra grf
71 $(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk
72         $(E) '$(STAGE) Assembling openttd.nfo'
73         $(Q)-mkdir -p $(OBJS_DIR)/sprites
74         $(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
75         $(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/openttd.nfo > $(OBJS_DIR)/sprites/openttd.nfo
76         $(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
77         $(E) '$(STAGE) Compiling openttd.grf'
78         $(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
79         $(Q)cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf
81 # The copy operation of PNG_FILES is duplicated from the target 'openttd.grf', thus those targets may not run in parallel.
82 $(BIN_DIR)/orig_extra.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk | $(BIN_DIR)/openttd.grf
83         $(E) '$(STAGE) Assembling orig_extra.nfo'
84         $(Q)-mkdir -p $(OBJS_DIR)/sprites
85         $(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
86         $(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/orig_extra.nfo > $(OBJS_DIR)/sprites/orig_extra.nfo
87         $(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/orig_extra.nfo
88         $(E) '$(STAGE) Compiling orig_extra.grf'
89         $(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/orig_extra.grf
90         $(Q)cp $(OBJS_DIR)/orig_extra.grf $(BIN_DIR)/orig_extra.grf
92 # Clean up temporary files.
93 clean:
94         $(Q)rm -f *.bak *.grf
96 # Clean up temporary files
97 mrproper: clean
98         $(Q)rm -fr sprites
100 .PHONY: all mrproper depend clean