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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
|
#
# This file is part of the NML build framework
# NML build framework 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.
# NML build framework 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 NML build framework. If not, see <http://www.gnu.org/licenses/>.
#
SHELL := /bin/bash
-include Makefile.config
##################################################################
#
# For easy updates you can copy these basic definitions in
# Makefile.config
# and place that next to the Makefile. This will allow easy
# updates to the generic Makefile
#
##################################################################
# Definition of the grfs
REPO_NAME ?= OpenMSX
# This is the filename part common to the grf file, main source file and the tar name
BASE_FILENAME ?= openmsx
# Documentation files
DOC_FILES ?= docs/readme.txt docs/license.txt docs/changelog.txt
# Possible offset to baseset version. Increase by one, if a release
# branch is added to the repository
REPO_BRANCH_VERSION ?= 0
# Directory structure
SCRIPT_DIR ?= build-common
# Uncomment in order to make use of gimp scripting. See the file
# for a description of the format
# GFX_SCRIPT_LIST_FILES := gfx/png_source_list
# If needed, declare the minimum NML requirements
# REQUIRED_NML_BRANCH = 0.3
# MIN_NML_REVISION = 0
###################################################################
#
# Everything below here usually need not change for simple basesets
#
###################################################################
# Define the filenames of the grf and nml file. They must be in the main directoy
GRF_FILE ?= $(BASE_FILENAME).grf
NML_FILE ?= $(BASE_FILENAME).nml
# uncomment MAIN_SRC_FILE if you do not want any preprocessing to happen to your source file
MAIN_SRC_FILE ?= $(BASE_FILENAME).pnml
# List of all files which will get shipped
# documentation files: readme, changelog and license, usually $(DOC_FILES)
# grf file: the above defined grf file, usualls $(GRF_FILE)
# Add any additional, not usual files here, too, including
# their relative path to the root of the repository
BUNDLE_FILES ?= $(GRF_FILE) $(DOC_FILES)
# Replacement strings in the source and in the documentation
# You may only change the values, not add new definitions
# (unless you know where to add them in other places, too)
REPLACE_TITLE := {{GRF_TITLE}}
REPLACE_GRFID := {{GRF_ID}}
REPLACE_REVISION := {{REPO_REVISION}}
REPLACE_FILENAME := {{FILENAME}}
GENERATE_GRF ?= grf
GENERATE_PNML ?= pnml
GENERATE_NML ?= nml
GENERATE_GFX ?= gfx
GENERATE_DOC ?= doc
GENERATE_LNG ?= lng
# target 'all' must be first target
all: $(GENERATE_GRF) $(GENERATE_DOC) bundle_tar
-include Makefile.in
# general definitions (no rules!)
-include Makefile.dist
.PHONY: all clean distclean doc bundle bundle_bsrc bundle_bzip bundle_gsrc bundle_src bundle_tar bundle_xsrc bundle_xz bundle_zip bundle_zsrc check
# We want to disable the default rules. It's not c/c++ anyway
.SUFFIXES:
# Don't delete intermediate files
.PRECIOUS: %.nml %.scm %.png
.SECONDARY: %.nml %.scm %.png
################################################################
# Programme definitions / search paths
################################################################
MAKE ?= make
MAKE_FLAGS ?= -r
NML ?= $(shell which nmlc 2>/dev/null)
NML_FLAGS ?= -c
ifdef REQUIRED_NML_BRANCH
NML_BRANCH = $(shell nmlc --version | head -n1 | cut -d. -f1-2)
endif
ifdef MIN_NML_REVISION
NML_REVISION = $(shell nmlc --version | head -n1 | cut -dr -f2 | cut -d: -f1)
endif
ifdef MAIN_SRC_FILE
CC ?= $(shell which gcc 2>/dev/null)
CC_FLAGS ?= -C -E -nostdinc -x c-header
endif
AWK ?= awk
GREP ?= grep
GIT ?= $(shell git status >/dev/null 2>/dev/null && which git 2>/dev/null)
PYTHON ?= python
UNIX2DOS ?= $(shell which unix2dos 2>/dev/null)
UNIX2DOS_FLAGS ?= $(shell [ -n $(UNIX2DOS) ] && $(UNIX2DOS) -q --version 1>&2 2>/dev/null && echo "-q" || echo "")
################################################################
#
# Working copy / bundle version detection.
#
################################################################
# Always run version detection, so we always have an accurate modified
# flag
REPO_VERSIONS := $(shell AWK="$(AWK)" "./findversion.sh")
# Use autodetected revisions
REPO_VERSION ?= $(shell echo "$(REPO_VERSIONS)" | cut -f 1 -d' ')
REPO_DATE ?= $(shell echo "$(REPO_VERSIONS)" | cut -f 2 -d' ')
REPO_HASH ?= $(shell echo "$(REPO_VERSIONS)" | cut -f 4 -d' ')
# Days of commit since 2000-01-01. REPO_DATE is in format YYYYMMDD.
REPO_DATE_YEAR := $(shell echo "${REPO_DATE}" | cut -b1-4)
REPO_DATE_MONTH := $(shell echo "${REPO_DATE}" | cut -b5-6 | sed s/^0//)
REPO_DATE_DAY := $(shell echo "${REPO_DATE}" | cut -b7-8 | sed s/^0//)
REPO_DAYS_SINCE_2000 := $(shell $(PYTHON) -c "from datetime import date; print( (date($(REPO_DATE_YEAR),$(REPO_DATE_MONTH),$(REPO_DATE_DAY))-date(2000,1,1)).days)")
REPO_TAGS ?= $(REPO_VERSION)
# The version reported to OpenTTD. Usually days since 2000 + branch offset
NEWGRF_VERSION ?= $(shell let x="$(REPO_DAYS_SINCE_2000) + 65536 * $(REPO_BRANCH_VERSION)"; echo "$$x")
# The shown version is either a tag, or in the absence of a tag the revision.
REPO_VERSION_STRING ?= $(shell [ -n "$(REPO_TAGS)" ] && echo $(REPO_TAGS) || echo $(REPO_DATE)$(REPO_BRANCH_STRING) \($(NEWGRF_VERSION):$(REPO_HASH)\))
# The title consists of name and version
REPO_TITLE ?= $(REPO_NAME) $(REPO_VERSION_STRING)
# Remove the @ when you want a more verbose output.
_V ?= @
_E ?= @echo
distclean:: clean
maintainer-clean:: distclean
# target nml
################################################################
# Pre-processing and generation of $(NML_FILE)
################################################################
# ifdef $(MAIN_SRC_FILE)
pnml:
nml: $(GENERATE_PNML)
$(_E) "[CPP] $(NML_FILE)"
$(_V) $(CC) -D REPO_REVISION=$(NEWGRF_VERSION) -D NEWGRF_VERSION=$(NEWGRF_VERSION) $(CC_USER_FLAGS) $(CC_FLAGS) -o $(NML_FILE) $(MAIN_SRC_FILE)
clean::
$(_E) "[CLEAN NML]"
$(_V)-rm -rf $(NML_FILE)
# else
# nml:
# endif
# target 'gfx' which builds all needed sprites
# Only a special gfx target for gimp exists so far
################################################################
# Targets related to creation of graphics files
################################################################
# Dependency on source list file via dep check
ifdef GFX_SCRIPT_LIST_FILES
# include dependency file, if we generate graphics
-include Makefile_gfx.dep
GIMP ?= $(shell [ `which gimp 2>/dev/null` ] && echo "gimp" || echo "")
GIMP_FLAGS ?= -n -i -b - <
%.scm: $(SCRIPT_DIR)/gimpscript $(SCRIPT_DIR)/gimp.sed
$(_E) "[GIMP-SCRIPT] $@"
$(_V) cat $(SCRIPT_DIR)/gimpscript > $@
$(_V) cat $(GFX_SCRIPT_LIST_FILES) | grep $(patsubst %.scm,%.png,$@) | sed -f $(SCRIPT_DIR)/gimp.sed >> $@
$(_V) echo "(gimp-quit 0)" >> $@
# create the png file. And make sure it's re-created even when present in the repo
%.png: %.scm
$(_E) "[GIMP] $@"
$(_V) $(GIMP) $(GIMP_FLAGS) $< >/dev/null
Makefile_gfx.dep: $(GFX_SCRIPT_LIST_FILES) Makefile
$(_E) "[GFX-DEP] $@"
$(_V) echo "" > $@
$(_V) for j in $(GFX_SCRIPT_LIST_FILES); do for i in `cat $$j | grep "\([pP][cCnN][xXgG]\)" | grep -v "^#" | cut -d\ -f1 | sed "s/\.\([pP][cCnN][xXgG]\)//"`; do echo "$$i.scm: $$j" >> $@; echo "$(GRF_FILE): $$i.png" >> $@; done; done
$(_V) cat $(GFX_SCRIPT_LIST_FILES) | grep "\([pP][cCnN][xXgG]\)" | grep -v "^#" | sed "s/[ ] */ /g" | cut -d\ -f1-2 | sed "s/ /: /g" >> $@
gfx: Makefile_gfx.dep
maintainer-clean::
$(_E) "[MAINTAINER CLEAN GFX]"
$(_V) rm -rf Makefile_gfx.dep
$(_V) for j in $(GFX_SCRIPT_LIST_FILES); do for i in `cat $$j | grep "\([pP][cCnN][xXgG]\)" | cut -d\ -f1 | sed "s/\.\([pP][cCnN][xXgG]\)//"`; do rm -rf $$i.scm; rm -rf $$i.png; done; done
else
gfx:
endif
#####################################################
# target 'lng' which builds the lang/*.lng files
#####################################################
lng: custom_tags.txt
custom_tags.txt: $(GENERATE_NML)
$(_E) "[LNG] $@"
$(_V) echo "VERSION :$(REPO_VERSION_STRING)" > $@
$(_V) echo "VERSION_STRING :$(REPO_VERSION_STRING)" >> $@
$(_V) echo "TITLE :$(REPO_TITLE)" >> $@
$(_V) echo "FILENAME :$(GRF_FILE)" >> $@
$(_V) echo "REPO_DATE :$(REPO_DATE)" >> $@
$(_V) echo "REPO_HASH :$(REPO_HASH)" >> $@
$(_V) echo "REPO_BRANCH :$(REPO_BRANCH)" >> $@
$(_V) echo "NEWGRF_VERSION :$(NEWGRF_VERSION)" >> $@
$(_V) echo "DAYS_SINCE_2K :$(REPO_DAYS_SINCE_2000)" >> $@
clean::
$(_E) "[CLEAN LNG]"
$(_V)-rm -rf custom_tags.txt
################################################################
# grf - specific rules
# target 'grf' which builds the grf from the nml
################################################################
grf: $(GENERATE_GFX) $(GENERATE_NML) $(GENERATE_LNG)
$(_E) "[NML] $(GRF_FILE)"
ifeq ($(NML),)
$(_E) "No NML compiler found!"
$(_V) false
endif
ifdef REQUIRED_NML_BRANCH
ifneq ($(REQUIRED_NML_BRANCH),$(NML_BRANCH))
$(_E) "Wrong NML version. This baseset requires an NML from the $(REQUIRED_NML_BRANCH) branch, but $(NML_BRANCH) found."
$(_V) false
endif
endif
ifdef MIN_NML_REVISION
ifeq ($(shell [ "$(NML_REVISION)" -lt "$(MIN_NML_REVISION)" ] && echo "true" || echo "false"),true)
$(_E) "Too old NML revision. At least r$(MIN_NML_REVISION) is required, but r$(NML_REVISION) found."
$(_V) false
endif
endif
$(_V) $(NML) $(NML_FLAGS) --grf $(GRF_FILE) $(NML_FILE)
$(GRF_FILE): $(GENERATE_GRF)
clean::
$(_E) "[CLEAN GRF]"
$(_V)-rm -rf $(GRF_FILE)
$(_V)-rm -rf $(GRF_FILE).cache
$(_V)-rm -rf $(GRF_FILE).cacheindex
$(_V)-rm -rf parsetab.py
maintainer-clean::
$(_E) "[MAINTAINER-CLEAN GRF]"
$(_V) -rm -rf $(MD5_SRC_FILENAME)
###############################################################
# Documentation targets
# target 'doc' which builds the docs
################################################################
%.txt: %.ptxt
$(_E) "[DOC] $@"
$(_V) cat $< \
| sed -e "s/$(REPLACE_TITLE)/$(REPO_TITLE)/" \
| sed -e "s/$(REPLACE_GRFID)/$(GRF_ID)/" \
| sed -e "s/$(REPLACE_REVISION)/$(NEWGRF_VERSION)/" \
| sed -e "s/$(REPLACE_FILENAME)/$(OUTPUT_FILENAME)/" \
> $@
$(_V) [ -z "$(UNIX2DOS)" ] || $(UNIX2DOS) $(UNIX2DOS_FLAGS) $@
doc: $(DOC_FILES) $(GRF_FILE)
clean::
$(_E) "[CLEAN DOC]"
$(_V) -for i in $(patsubst %.txt,%,$(DOC_FILES)); do [ -f $$i.ptxt ] && [ -f $$i.txt ] && rm -rf $$i.txt || true; done
################################################################
# Bundle targets
# Binary bundle targets
################################################################
# target 'bundle' and bundle_xxx which builds the distribution files
# and the distribution bundles like bundle_tar, bundle_zip, ...
# Programme definitions
TAR ?= $(shell which tar 2>/dev/null)
TAR_FLAGS ?= -cf
ZIP ?= $(shell which zip 2>/dev/null)
ZIP_FLAGS ?= -9rq
GZIP ?= $(shell which gzip 2>/dev/null)
GZIP_FLAGS ?= -9f
BZIP ?= $(shell which bzip2 2>/dev/null)
BZIP_FLAGS ?= -9fk
XZ ?= $(shell which xz 2>/dev/null)
XZ_FLAGS ?= -efk
# 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")
# Use the grfID programme to find the checksum which OpenTTD checks
GRFID ?= $(shell which grfid 2>/dev/null)
GRFID_FLAGS ?= -m
# 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.
# Common to all filenames
FILE_VERSION_STRING ?= $(shell [ -n "$(REPO_TAGS)" ] && echo "$(REPO_TAGS)" || echo "$(REPO_BRANCH_STRING)$(NEWGRF_VERSION)")
DIR_NAME := $(shell [ -n "$(REPO_TAGS)" ] && echo $(BASE_FILENAME)-$(FILE_VERSION_STRING) || echo $(BASE_FILENAME))
VERSIONED_FILENAME := $(BASE_FILENAME)-$(FILE_VERSION_STRING)
DIR_NAME_SRC := $(VERSIONED_FILENAME)-source
TAR_FILENAME := $(DIR_NAME).tar
BZIP_FILENAME := $(TAR_FILENAME).bz2
GZIP_FILENAME := $(TAR_FILENAME).gz
XZ_FILENAME := $(TAR_FILENAME).xz
ZIP_FILENAME := $(VERSIONED_FILENAME)-all.zip
MD5_FILENAME := $(DIR_NAME).md5
MD5_SRC_FILENAME ?= $(DIR_NAME).check.md5
# Creating file with checksum
%.md5: $(GRF_FILE)
$(_E) "[GRFID] $@"
$(_V) $(GRFID) $(GRFID_FLAGS) $< > $@
# Bundle directory
$(DIR_NAME): $(GENERATE_GRF) $(GENERATE_DOC)
$(_E) "[BUNDLE] $@"
$(_V) if [ -e $@ ]; then rm -rf $@; fi
$(_V) mkdir $@
$(_V) -for i in $(BUNDLE_FILES); do cp $(CP_FLAGS) $$i $@; done
$(DIR_NAME).tar: $(DIR_NAME)
$(_E) "[BUNDLE TAR] $@"
$(_V) $(TAR) $(TAR_FLAGS) $@ $<
bundle_tar: $(DIR_NAME).tar
bundle_zip: $(ZIP_FILENAME)
%.zip: $(DIR_NAME).tar
$(_E) "[BUNDLE ZIP] $@"
$(_V) $(ZIP) $(ZIP_FLAGS) $@ $< >/dev/null
bundle_bzip: $(DIR_NAME).tar.bz2
%.tar.bz2: %.tar
$(_E) "[BUNDLE BZIP] $@"
$(_V) $(BZIP) $(BZIP_FLAGS) $^
bundle_gzip: $(DIR_NAME).tar.gz
# gzip has no option -k, so we cat the tar to keep it
%.tar.gz: %.tar
$(_E) "[BUNDLE GZIP] $@"
$(_V) cat $^ | $(GZIP) $(GZIP_FLAGS) > $@
bundle_xz: $(DIR_NAME).tar.xz
%.tar.xz: %.tar
$(_E) "[BUNDLE XZ] $@"
$(_V) $(XZ) $(XZ_FLAGS) $^
clean::
$(_E) "[CLEAN BUNDLE]"
$(_V) -rm -rf $(DIR_NAME)
$(_V) -rm -rf $(DIR_NAME).tar
$(_V) -rm -rf $(DIR_NAME).tar.zip
$(_V) -rm -rf $(DIR_NAME).tar.gz
$(_V) -rm -rf $(DIR_NAME).tar.bz2
$(_V) -rm -rf $(DIR_NAME).tar.xz
################################################################
# Bundle source targets
# target 'bundle_src which builds source bundle
################################################################
RE_FILES_NO_SRC_BUNDLE = ^.devzone|^.git
check: $(MD5_FILENAME)
$(_V) if [ -f $(MD5_SRC_FILENAME) ]; then echo "[CHECKING md5sums]"; else echo "Required file '$(MD5_SRC_FILENAME)' which to test against not found!"; false; fi
$(_V) if [ -z "`diff $(MD5_FILENAME) $(MD5_SRC_FILENAME)`" ]; then echo "Checksums are equal"; else echo "Differences in checksums:"; echo "`diff $(MD5_FILENAME) $(MD5_SRC_FILENAME)`"; false; fi
$(_V) rm $(MD5_FILENAME)
$(DIR_NAME_SRC).tar: $(DIR_NAME_SRC)
$(_E) "[BUNDLE SRC]"
$(_V) $(GIT) archive --format=tar HEAD | tar -x -C $(DIR_NAME_SRC)
$(_V) $(TAR) -uf $@ $^
bundle_src: $(DIR_NAME_SRC).tar
bundle_bsrc: $(DIR_NAME_SRC).tar.bz2
bundle_gsrc: $(DIR_NAME_SRC).tar.gz
bundle_xsrc: $(DIR_NAME_SRC).tar.xz
bundle_zsrc: $(DIR_NAME_SRC).tar.zip
# Addition to config for tar releases
Makefile.fordist:
$(_V) echo '################################################################' > $@
$(_V) echo '# Definitions needed for tar releases' >> $@
$(_V) echo '# This part is automatically generated' >> $@
$(_V) echo '################################################################' >> $@
$(_V) echo 'REPO_VERSION := $(REPO_VERSION)' >> $@
$(_V) echo 'REPO_REVISION := $(NEWGRF_VERSION)' >> $@
$(_V) echo 'NEWGRF_VERSION := $(NEWGRF_VERSION)' >> $@
$(_V) echo 'REPO_HASH := $(REPO_HASH)' >> $@
$(_V) echo 'REPO_VERSION_STRING := $(REPO_VERSION_STRING)' >> $@
$(_V) echo 'REPO_TITLE := $(REPO_TITLE)' >> $@
$(_V) echo 'REPO_DATE := $(REPO_DATE)' >> $@
$(_V) echo 'REPO_BRANCH := $(REPO_BRANCH)' >> $@
$(_V) echo 'GIT := :' >> $@
$(_V) echo 'PYTHON := :' >> $@
ifneq ("$(strip $(GIT))",":")
$(DIR_NAME_SRC): $(MD5_SRC_FILENAME) Makefile.fordist
$(_E) "[ASSEMBLING] $(DIR_NAME_SRC)"
$(_V)-rm -rf $@
$(_V) mkdir $@
$(_V) cp $(CP_FLAGS) $(MD5_SRC_FILENAME) $(DIR_NAME_SRC)
$(_V) cp $(CP_FLAGS) Makefile.fordist $@/Makefile.dist
else
$(DIR_NAME_SRC):
$(_E) "Source releases can only be made from a git checkout."
$(_V) false
endif
clean::
$(_E) "[CLEAN BUNDLE SRC]"
$(_V) -rm -rf $(DIR_NAME_SRC)
$(_V) -rm -rf $(DIR_NAME_SRC).tar
$(_V) -rm -rf Makefile.fordist
maintainer-clean::
$(_E) "[MAINTAINER-CLEAN BUNDLE SRC]"
$(_V) -rm -rf $(MD5_SRC_FILENAME)
# target 'install' which installs the baseset
################################################################
# Install targets
################################################################
################################################################
# OS-specific definitions and paths
################################################################
# If we are not given an install dir explicitly we'll try to
# find the default one for the OS we have
ifndef INSTALL_DIR
# Determine the OS we run on and set the default install path accordingly
OSTYPE:=$(shell uname -s)
# Check for OSX
ifeq ($(OSTYPE),Darwin)
INSTALL_DIR :=$(HOME)/Documents/OpenTTD/baseset/$(BASE_FILENAME)
endif
# Check for Windows / MinGW32
ifeq ($(shell echo "$(OSTYPE)" | cut -d_ -f1),MINGW32)
# If CC has been set to the default implicit value (cc), check if it can be used. Otherwise use a saner default.
ifeq "$(origin CC)" "default"
CC=$(shell which cc 2>/dev/null && echo "cc" || echo "gcc")
endif
WIN_VER = $(shell echo "$(OSTYPE)" | cut -d- -f2 | cut -d. -f1)
ifeq ($(WIN_VER),5)
INSTALL_DIR :=C:\Documents and Settings\All Users\Shared Documents\OpenTTD\baseset\$(BASE_FILENAME)
else
INSTALL_DIR :=C:\Users\Public\Documents\OpenTTD\baseset\$(BASE_FILENAME)
endif
endif
# Check for Windows / Cygwin
ifeq ($(shell echo "$(OSTYPE)" | cut -d_ -f1),CYGWIN)
INSTALL_DIR :=$(shell cygpath -A -O)/OpenTTD/baseset/$(BASE_FILENAME)
endif
# If non of the above matched, we'll assume we're on a unix-like system
ifeq ($(OSTYPE),Linux)
INSTALL_DIR := $(HOME)/.openttd/baseset/$(BASE_FILENAME)
endif
endif
install: $(DIR_NAME).tar
ifeq ($(INSTALL_DIR),"")
$(_E) "No install dir defined! Aborting."
$(_E) "Try calling 'make install -D INSTALL_DIR=path/to/install_dir'"
$(_V) false
endif
$(_E) "[INSTALL] to $(INSTALL_DIR)"
$(_V) install -d $(INSTALL_DIR)/$(DIR_NAME)
$(_V) install -m644 $(DIR_NAME)/* $(INSTALL_DIR)/$(DIR_NAME)
# misc. convenience targets like 'langcheck'
-include $(SCRIPT_DIR)/Makefile_misc
help:
$(_E) "all: Build the entire baseset and its documentation"
$(_E) "install: Install into the default baseset directory ($(INSTALL_DIR))"
$(_E) "$(GENERATE_DOC): Build the documentation ($(DOC_FILES))"
ifdef GFX_SCRIPT_LIST_FILES
$(_E) "$(GENERATE_GFX): Build the graphics dependencies"
endif
$(_E) "$(GENERATE_GRF): Build the grf file only ($(GRF_FILE))"
ifdef MAIN_SRC_FILE
$(_E) "$(GENERATE_NML): Generate the combined nml file only ($(NML_FILE))"
endif
$(_E) "$(GENERATE_LNG): Generate the language file(s) and custom_tags.txt"
$(_E)
$(_E) "clean: Clean all built files"
$(_E) "distclean: Clean really everything"
$(_E) "maintainer-clean:"
$(_E) " Reset the repository to prestine state"
$(_E)
$(_E) "Bundles for distribution:"
$(_E) "bundle: Build the distribution bundle in $(DIR_NAME)"
$(_E) "bundle_tar: Build the distritubion bundle as tar archive ($(DIR_NAME).tar)"
$(_E) "bundle_zip: Build the distritubion bundle and compress with zip ($(DIR_NAME).tar.zip)"
$(_E) "bundle_xz: Build the distritubion bundle and compress with xz ($(DIR_NAME).tar.xz)"
$(_E) "bundle_gzip: Build the distritubion bundle and compress with gzip ($(DIR_NAME).tar.gz)"
$(_E) "bundle_bzip: Build the distribution bundle and compress with bzip2 ($(DIR_NAME).tar.bz2)"
$(_E) "bundle_src: Build the source bundle as tar archive for distribution"
$(_E) "bundle_bsrc: Build the source bundle as tar archive compressed with bzip2"
$(_E) "bundle_gsrc: Build the source bundle as tar archive compressed with gzip"
$(_E) "bundle_xsrc: Build the source bundle as tar archive compressed with xz"
$(_E) "bundle_zsrc: Build the source bundle as tar archive compressed with zip"
$(_E)
$(_E) "Valid command line variables are:"
$(_E) "Helper programmes:"
$(_E) "MAKE MAKE_FLAGS. defaults: $(MAKE) $(MAKE_FLAGS)"
ifdef MAIN_SRC_FILE
$(_E) "CC CC_FLAGS. defaults: $(CC) $(CC_FLAGS)"
endif
$(_E) "AWK defaults: $(AWK)"
$(_E) "GREP defaults: $(GREP)"
$(_E) "GRFID GRFID_FLAGS. defaults: $(GRFID) $(GRFID_FLAGS)"
$(_E) "UNIX2DOS UNIX2DOS_FLAGS defaults: $(UNIX2DOS) $(UNIX2DOS_FLAGS)"
ifdef GFX_SCRIPT_LIST_FILES
$(_E) "GIMP GIMP_FLAGS defaults: $(GIMP) $(GIMP_FLAGS)"
endif
$(_E) "CP_FLAGS (for cp command): $(CP_FLAGS)"
$(_E)
$(_E) "NML NML_FLAGS. defaults: $(NML) $(NML_FLAGS)"
$(_E)
$(_E) "archive and compression programmes:"
$(_E) "TAR TAR_FLAGS . defaults: $(TAR) $(TAR_FLAGS)"
$(_E) "ZIP ZIP_FLAGS. defaults: $(ZIP) $(ZIP_FLAGS)"
$(_E) "GZIP GZIP_FLAGS defaults: $(GZIP) $(GZIP_FLAGS)"
$(_E) "BZIP BZIP_FLAGS defaults: $(BZIP) $(BZIP_FLAGS)"
$(_E) "XZ XZ_FLAGS defaults: $(XZ) $(XZ_FLAGS)"
$(_E)
$(_E) "INSTALL_DIR defaults: $(INSTALL_DIR)"
$(_E) " Sets the default installation directory for basesets"
|