1# -*- Makefile -*- 2################################################################################ 3# 4# Author: Andy Rushton 5# Copyright: (c) Andy Rushton, 1999 onwards 6# License: BSD License, see docs/license.html 7# 8# Part of the generic makefile system - works out the current compilation platform 9# This part is specific to the gcc compiler 10# For use in gcc.mak 11# 12# New platforms should be added as required by adding more ifneq blocks 13# The uname command usually gives a string like CYGWIN_NT-5.0 and I convert it to a simpler form like CYGWIN 14# The rule is that every OS should map onto a different PLATFORM, 15# furthermore, every OS type/version that needs a separate build should map onto a different BUILD, 16# but OS versions that are binary-compatible with each other should map onto the same BUILD 17# - PLATFORM is the coarse-grain platform name used as a compiler directive e.g. LINUX 18# - BUILD is the fine-grain name used to differentiate between non-compatible objects = PLATFORM-CPU 19# - VARIANT is the kind of build - release/debug etc 20# - SUBDIR is the unique subdirectory name for object files = BUILD-VARIANT 21# 22################################################################################ 23 24# start by identifying the operating system 25OS := $(shell uname -o 2>/dev/null || uname) 26 27# on most platforms "uname -m" gives the CPU name 28# However, see below for situations where this is overridden 29# Also, allow the command-line to override it 30ifeq ($(CPU),) 31CPU := $(shell uname -m) 32endif 33 34# Windows builds 35 36# MinGW build on Windows 37# this is a native Windows build 38ifneq ($(findstring Msys,$(OS)),) 39PLATFORM := MINGW 40WINDOWS := on 41endif 42 43# Cygwin build on Windows 44# this is a Unix emulation running on Windows so is classed as Unix for building purposes 45ifneq ($(findstring Cygwin,$(OS)),) 46PLATFORM := CYGWIN 47UNIX := on 48endif 49 50# Unix builds 51 52# Build on GNU/Linux 53ifneq ($(findstring GNU/Linux,$(OS)),) 54PLATFORM := GNULINUX 55UNIX := on 56endif 57 58# Build on various flavours of BSD 59ifneq ($(findstring DragonFly,$(OS)),) 60PLATFORM := DRAGONFLY 61UNIX := on 62endif 63ifneq ($(findstring FreeBSD,$(OS)),) 64PLATFORM := FREEBSD 65UNIX := on 66endif 67ifneq ($(findstring OpenBSD,$(OS)),) 68PLATFORM := OPENBSD 69UNIX := on 70endif 71ifneq ($(findstring NetBSD,$(OS)),) 72PLATFORM := NETBSD 73UNIX := on 74endif 75 76# Build on Solaris - which identifies as SunOS 77# Note: If I ever need to support SunOS 4 or earlier I'll have to differentiate between them somehow 78# However, this is very unlikely and would cause many other problems since SunOS is not Posix compliant 79ifneq ($(findstring SunOS,$(OS)),) 80PLATFORM := SOLARIS 81UNIX := on 82endif 83 84# Build on MacOS-X which identifies as Darwin 85# Should this be identified as Unix? 86ifneq ($(findstring Darwin,$(OS)),) 87PLATFORM := MACOS 88CPU := $(shell uname -p) 89endif 90 91# test for undefined platform 92ifeq ($(PLATFORM),) 93$(error you need to configure the make system for platform $(OS)) 94endif 95 96BUILD := $(PLATFORM)-$(CPU) 97 98################################################################################ 99# Calculate build variant 100# there are four different build variants: 101# debug - for internal development (default) 102# release - for shipping to customers (switched on by environment variable RELEASE=on) 103# gprof - for performance profiling (switched on by environment variable GPROF=on) 104# gcov - for code coverage (switched on by environment variable GCOV=on) 105 106ifeq ($(RELEASE),on) 107# release variant 108VARIANT := release 109else # RELEASE off 110ifeq ($(GPROF),on) 111# gprof variant 112VARIANT := gprof 113else # GPROF off 114ifeq ($(GCOV),on) 115# gcov variant 116VARIANT := gcov 117else # GCOV off 118# debug variant 119VARIANT := debug 120endif # GCOV 121endif # GPROF 122endif # RELEASE 123 124# define the name of the subdirectory so that different builds have different subdirectories 125SUBDIR := $(BUILD)-$(VARIANT) 126 127################################################################################ 128