1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
shell = /bin/sh
# We want to disable the default rules. It's not c/c++ anyway
.SUFFIXES:
PROJECT_TYPE ?= NFO
################################################################
# Programme definitions / search paths
################################################################
# Build parameters and programmes
NFORENUM_FLAGS ?=
GRFCODEC_FLAGS ?= -e -p 2 -c
CATCODEC_FLAGS ?= -e
TAR_FLAGS ?= -cf
ZIP_FLAGS ?= -r
SRCZIP_FLAGS ?=
BZIP_FLAGS ?= -k9f
CC_FLAGS ?= -nostdinc -C -E - <
MAKE_FLAGS ?=
UNIX2DOS_FLAGS ?= -q
NML_FLAGS ?=
# OSX has nice extended file attributes which create their own file within tars. We don't want those, thus don't copy them
CP_FLAGS ?= $(shell [ "$(OSTYPE)" = "Darwin" ] && echo "-rfX" || echo "-rf")
NFORENUM ?= $(shell [ `which nforenum 2>/dev/null` ] && echo "nforenum" || echo "renum")
GRFCODEC ?= grfcodec
CATCODEC ?= catcodec
TAR ?= tar
ZIP ?= zip
SRCZIP ?= gzip
BZIP ?= bzip2
CC ?= gcc
AWK ?= awk
GIT ?= git
MAKE ?= make
UNIX2DOS ?= $(shell [ `which unix2dos 2>/dev/null` ] && echo "unix2dos" || echo "")
# Macs have a different md5 command than linux or mingw envirnoment:
MD5SUM ?= $(shell [ "$(OSTYPE)" = "Darwin" ] && echo "md5 -r" || echo "md5sum")
NML ?= nml2nfo
SCRIPT_DIR ?= scripts
SRC_DIR ?= sprites
NFO_DIR ?= $(SRC_DIR)/nfo
DOC_DIR ?= docs
ifeq ($(PROJECT_TYPE),NML)
LANG_DIR ?= lang
endif
# Add some OS detection and guess an install path (use the system's default)
OSTYPE:=$(shell uname -s)
ifeq ($(OSTYPE),Linux)
INSTALL_DIR?=$(HOME)/.openttd/data
else
ifeq ($(OSTYPE),Darwin)
INSTALL_DIR?=$(HOME)/Documents/OpenTTD/data
else
ifeq ($(shell echo "$(OSTYPE)" | cut -d_ -f1),MINGW32)
INSTALL_DIR?=C:\Documents and Settings\$(USERNAME)\My Documents\OpenTTD\data
else
INSTALL_DIR?=
endif
endif
endif
# Previous versions used INSTALLDIR instead of INSTALL_DIR. Use the previous version,
# if supplied via command line parameter:
ifdef INSTALLDIR
INSTALL_DIR = $(INSTALLDIR)
endif
# file extentions which indicate plain text source files,
# parsable by a text editor (SRC) and binary source files (INC)
ifeq ($(PROJECT_TYPE),NFO) # NFO style
FILE_SRC_EXTENSIONS ?= pnfo tnfo
FILE_INC_EXTENSIONS ?= wav pcx
endif
ifeq ($(PROJECT_TYPE),NML) # NML style
FILE_SRC_EXTENSIONS ?= pnml nml tnml
FILE_INC_EXTENSIONS ?= wav pcx png
LANG_FILES := $(shell ls $(LANG_DIR)/*.lng)
endif
################################################################
# Get the Repository revision, tags and the modified status
# The displayed name within OpenTTD / TTDPatch
# Looks like either
# a nightly build: GRF's Name nightly-r51
# a release build (taged version): GRF's Name 0.1
################################################################
DEFAULT_BRANCH_NAME ?= nightly
REPO_HASH ?= $(shell $(GIT) log -n1 --pretty="format:%h")
REPO_REVISION := $(REPO_HASH)
TEMP_GITSTATUS ?= $(shell $(GIT) status --porcelain=v2 | grep "^[12]")
REPO_MODIFIED ?= $(shell [ -z "$TEMP_GITSTATUS" ] && echo "" || echo "M")
REPO_BRANCH ?= $(shell $(GIT) status -b --porcelain=v2 | grep "^# branch\.head" | tail -c7)
REPO_TAGS ?= $(shell echo "")
REPO_FILES_CMD := $(GIT) ls-tree -r master --name-only
REPO_FILES ?= $(shell $(REPO_FILES_CMD))
REPO_DIRS ?= $(shell for i in $(REPO_FILES); do dirname $$i; done | sort | uniq)
REPO_TITLE := $(REPO_NAME) $(shell [ -n "$(REPO_TAGS)" ] && echo $(REPO_TAGS)$(REPO_MODIFIED) || echo $(REPO_BRANCH)-r$(REPO_REVISION)$(REPO_MODIFIED))
################################################################
# Rules on how to generate filenames. Usually no need to change
################################################################
# Define how the displayed name and the filename of the bundled grf shall look like:
# The result will either be
# nightly build: mynewgrf-nightly-r51
# a release build (tagged version): mynewgrf-0.1
# followed by an M, if the source repository is not a clean version.
VPATH =
VPATH = $(REPO_DIRS)
FILENAME_STUB := $(basename $(MAIN_TARGET))
DIR_BASE := $(FILENAME_STUB)-
VERSION_STRING := $(shell [ -n "$(REPO_TAGS)" ] && echo $(REPO_TAGS)$(REPO_MODIFIED) || echo $(REPO_BRANCH)-r$(REPO_REVISION)$(REPO_MODIFIED))
DIR_NAME := $(shell [ -n "$(REPO_TAGS)" ] && echo $(DIR_BASE)$(VERSION_STRING) || echo $(DIR_BASE)$(REPO_BRANCH))
VERSIONED_FILENAME := $(DIR_BASE)$(VERSION_STRING)
DIR_NAME_SRC := $(VERSIONED_FILENAME)-source
TAR_FILENAME := $(DIR_NAME).tar
BZIP_FILENAME := $(TAR_FILENAME).bz2
ZIP_FILENAME := $(VERSIONED_FILENAME).zip
REV_EXTENSION ?= REV
MD5_FILENAME := $(DIR_NAME).md5
REV_FILENAME := $(VERSIONED_FILENAME).$(REV_EXTENSION)
# customly defined tags. Don't change the filename.
FILE_CUSTOM_TAGS := custom_tags.txt
# replacement tags for the doc files:
REPO_TITLE_DUMMY ?= {{REPO_TITLE}}
GRF_ID_DUMMY ?= {{GRF_ID}}
REPO_REVISION_DUMMY ?= {{REPO_REVISION}}
OUTPUT_FILENAME_DUMMY ?= {{FILENAME}}
GRF_MD5SUM_DUMMY ?= {{GRF_MD5}}
DOC_FILES_SRC := $(LICENSE_FILENAME_SRC) $(README_FILENAME_SRC) $(CHANGELOG_FILENAME_SRC)
DOC_FILES := $(addsuffix .txt,$(basename $(DOC_FILES_SRC)))
# Directories which to remember when creating a source release
MAIN_DIRS = $(SRC_DIR) $(DOC_DIR) $(SCRIPT_DIR) $(TEMPLATE_DIR) $(LANG_DIR) $(EXTRA_DIRS)
FILE_SRC_RE := $(shell echo $(FILE_SRC_EXTENSIONS) | tr -s "[:space:]" "|")
FILE_INC_RE := $(shell echo $(FILE_INC_EXTENSIONS) | tr -s "[:space:]" "|")
FILES_NOT_PACK_RE := "(\.gitignore|backup\.push|\.devzone)"
# Remove the @ when you want a more verbose output.
_V ?= @
_E ?= @echo
|