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 and NFORenum. Older versions of GRFCodec are
9 # known to miscompile the graphics.
11 # Recent nightlies (including sources) of both can be found at:
12 # http://www.openttd.org/download-grfcodec
13 # http://www.openttd.org/download-nforenum
15 # The mercurial repository of both can be found at:
16 # http://hg.openttdcoop.org/grfcodec
17 # http://hg.openttdcoop.org/nforenum
21 ROOT_DIR = !!ROOT_DIR!!
22 GRF_DIR = $(ROOT_DIR)/media/extra_grf
23 BIN_DIR = !!BIN_DIR!!/baseset
24 OBJS_DIR = !!GRF_OBJS_DIR!!
28 # Check if we want to show what we are doing
37 GRFCODEC := !!GRFCODEC!!
38 NFORENUM := !!NFORENUM!!
39 CC_BUILD := !!CC_BUILD!!
40 MD5SUM := $(shell [ "$(OS)" = "OSX" ] && echo "md5 -r" || echo "md5sum")
42 # Some "should not be changed" settings.
43 NFO_FILES := $(GRF_DIR)/*.nfo $(GRF_DIR)/rivers/*.nfo
44 PNG_FILES := $(GRF_DIR)/*.png $(GRF_DIR)/rivers/*.png
48 all: $(BIN_DIR)/openttd.grf
53 # Make sure the sprites directory exists.
58 $(BIN_DIR)/openttd.grf: $(OBJS_DIR)/openttd.grf
59 $(Q)cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf
60 $(E) '$(STAGE) Updating base graphics sets'
61 $(Q) for grf in $(BIN_DIR)/orig*.obg; do sed 's/^OPENTTD.GRF = [0-9a-f]*$$/OPENTTD.GRF = '`$(MD5SUM) $(BIN_DIR)/openttd.grf | sed 's@ .*@@'`'/' $$grf > $$grf.tmp && mv $$grf.tmp $$grf; done
63 # Yeah, we'd like to use -i in the sed, but Mac OS X's sed and GNU sed just can't agree on the usage of -i. In any case either one of them fails.
64 $(OBJS_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites
65 $(E) '$(STAGE) Assembling openttd.nfo'
66 $(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
67 $(Q) $(CC_BUILD) -nostdinc -I$(GRF_DIR) -C -E - < "$(GRF_DIR)/openttd.nfo" | sed -e '/^#/d' -e '/^$$/d' > $(OBJS_DIR)/sprites/openttd.nfo
68 $(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
69 $(E) '$(STAGE) Compiling openttd.grf'
70 $(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
72 # Clean up temporary files.
76 # Clean up temporary files
80 .PHONY: all mrproper depend clean