From a054078920536fac36179d542a7b4b920ba7956c Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 19 Aug 2010 08:07:19 +0000 Subject: (svn r20551) -Fix [FS#4056]: apparantly Mac OS X's sed and GNU's can't decide on a single "format" for replacing stuff in-place --- Makefile.grf.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Makefile.grf.in') diff --git a/Makefile.grf.in b/Makefile.grf.in index 267c46190..10a4bdcd1 100644 --- a/Makefile.grf.in +++ b/Makefile.grf.in @@ -22,6 +22,7 @@ ROOT_DIR = !!ROOT_DIR!! GRF_DIR = $(ROOT_DIR)/media/extra_grf BIN_DIR = !!BIN_DIR!!/data OBJS_DIR = !!GRF_OBJS_DIR!! +OS = !!OS!! # Check if we want to show what we are doing ifdef VERBOSE @@ -35,6 +36,7 @@ endif # Some configurational settings for your environment. GRFCODEC := grfcodec NFORENUM := $(shell [ `which nforenum 2>/dev/null` ] && echo "nforenum" || echo "renum") +MD5SUM := $(shell [ "$(OS)" = "OSX" ] && echo "md5 -r" || echo "md5sum") # Some "should not be changed" settings. NFO_FILES := $(GRF_DIR)/*.nfo @@ -52,13 +54,14 @@ $(BIN_DIR)/openttd.grf: $(PCX_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites @# Only try; if nforenum isn't available, just retouch the file as they likely didn't need it anyway. $(Q) ($(NFORENUM) -? > /dev/null 2>&1 && $(MAKE) $(OBJS_DIR)/openttd.grf && cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf) || ([ -e $(BIN_DIR)/openttd.grf ] && touch $(BIN_DIR)/openttd.grf && echo "no NFORenum and GRFCodec found, skipping rebuild of openttd.grf...") || (echo "no NFORenum and GRFCodec found, but no openttd.grf either. Install NFORenum and GRFCodec." && exit 1) +# 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. $(OBJS_DIR)/openttd.grf: $(PCX_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites $(Q)-cp $(PCX_FILES) $(OBJS_DIR)/sprites 2> /dev/null $(Q) gcc -I$(GRF_DIR) -C -E - < "$(GRF_DIR)/openttd.nfo" | sed -e '/^#/d' -e '/^$$/d' > $(OBJS_DIR)/sprites/openttd.nfo $(Q) $(NFORENUM) $(OBJS_DIR)/sprites/openttd.nfo $(Q) $(GRFCODEC) -e -m1 $(OBJS_DIR)/openttd.grf $(Q) cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf - $(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@ .*@@'`'/' -i $$grf; done + $(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 # Clean up temporary files. clean: -- cgit v1.2.3-54-g00ecf