2021-05-02 09:54:51 +00:00
|
|
|
# GNU Makefile for SRB2
|
|
|
|
# the poly3 Makefile adapted over and over...
|
|
|
|
#
|
|
|
|
# Copyright 1998-2000 DooM Legacy Team.
|
|
|
|
# Copyright 2020-2021 James R.
|
|
|
|
# Copyright 2003-2021 Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
|
|
|
# This program is free software distributed under the
|
|
|
|
# terms of the GNU General Public License, version 2.
|
|
|
|
# See the 'LICENSE' file for more details.
|
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# Special targets:
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# clean - remove executables and objects for this build
|
|
|
|
# cleandep - remove dependency files for this build
|
|
|
|
# distclean - remove entire executable, object and
|
|
|
|
# dependency file directory structure.
|
2021-06-16 22:34:58 +00:00
|
|
|
# dump - disassemble executable
|
2021-05-02 09:54:51 +00:00
|
|
|
# info - print settings
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# This Makefile can automatically detect the host system
|
|
|
|
# as well as the compiler version. If system or compiler
|
|
|
|
# version cannot be detected, you may need to set a flag
|
|
|
|
# manually.
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# On Windows machines, 32-bit Windows is always targetted.
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# Platform/system flags:
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# LINUX=1, LINUX64=1
|
|
|
|
# MINGW=1, MINGW64=1 - Windows (MinGW toolchain)
|
|
|
|
# UNIX=1 - Generic Unix like system
|
|
|
|
# FREEBSD=1
|
|
|
|
# SDL=1 - Use SDL backend. SDL is the only backend though
|
|
|
|
# and thus, always enabled.
|
2014-03-15 16:59:03 +00:00
|
|
|
#
|
2021-05-02 09:54:51 +00:00
|
|
|
# A list of supported GCC versions can be found in
|
|
|
|
# Makefile.d/detect.mk -- search 'gcc_versions'.
|
|
|
|
#
|
|
|
|
# Feature flags:
|
|
|
|
#
|
|
|
|
# Safe to use online
|
|
|
|
# ------------------
|
|
|
|
# NO_IPV6=1 - Disable IPv6 address support.
|
|
|
|
# NOHW=1 - Disable OpenGL renderer.
|
|
|
|
# ZDEBUG=1 - Enable more detailed memory debugging
|
|
|
|
# HAVE_MINIUPNPC=1 - Enable automated port forwarding.
|
|
|
|
# Already enabled by default for 32-bit
|
|
|
|
# Windows.
|
|
|
|
# NOASM=1 - Disable hand optimized assembly code for the
|
|
|
|
# Software renderer.
|
|
|
|
# NOPNG=1 - Disable PNG graphics support. (TODO: double
|
|
|
|
# check netplay compatible.)
|
|
|
|
# NOCURL=1 - Disable libcurl--HTTP capability.
|
|
|
|
# NOGME=1 - Disable game music emu, retro VGM support.
|
|
|
|
# NOOPENMPT=1 - Disable module (tracker) music support.
|
|
|
|
# NOMIXER=1 - Disable SDL Mixer (audio playback).
|
|
|
|
# NOMIXERX=1 - Forgo SDL Mixer X--revert to standard SDL
|
|
|
|
# Mixer. Mixer X is the default for Windows
|
|
|
|
# builds.
|
|
|
|
# HAVE_MIXERX=1 - Enable SDL Mixer X. Outside of Windows
|
|
|
|
# builds, SDL Mixer X is not the default.
|
|
|
|
# NOTHREADS=1 - Disable multithreading.
|
|
|
|
#
|
|
|
|
# Netplay incompatible
|
|
|
|
# --------------------
|
|
|
|
# NONET=1 - Disable online capability.
|
|
|
|
# NOMD5=1 - Disable MD5 checksum (validation tool).
|
|
|
|
# NOPOSTPROCESSING=1 - ?
|
|
|
|
# MOBJCONSISTANCY=1 - ??
|
|
|
|
# PACKETDROP=1 - ??
|
|
|
|
# DEBUGMODE=1 - Enable various debugging capabilities.
|
|
|
|
# Also disables optimizations.
|
|
|
|
# NOZLIB=1 - Disable some compression capability. Implies
|
|
|
|
# NOPNG=1.
|
|
|
|
#
|
|
|
|
# Development flags:
|
|
|
|
#
|
|
|
|
# VALGRIND=1 - Enable Valgrind memory debugging support.
|
|
|
|
# PROFILEMODE=1 - Enable performance profiling (gprof).
|
|
|
|
#
|
|
|
|
# General flags for building:
|
|
|
|
#
|
|
|
|
# STATIC=1 - Use static linking.
|
|
|
|
# DISTCC=1
|
|
|
|
# CCACHE=1
|
2021-06-16 22:34:58 +00:00
|
|
|
# UPX= - UPX command to use for compressing final
|
|
|
|
# executable.
|
2021-05-02 09:54:51 +00:00
|
|
|
# WINDOWSHELL=1 - Use Windows commands.
|
|
|
|
# PREFIX= - Prefix to many commands, for cross compiling.
|
|
|
|
# YASM=1 - Use Yasm instead of NASM assembler.
|
|
|
|
# STABS=1 - ?
|
|
|
|
# ECHO=1 - Print out each command in the build process.
|
|
|
|
# NOECHOFILENAMES=1 - Don't print out each that is being
|
|
|
|
# worked on.
|
|
|
|
# SILENT=1 - Print absolutely nothing except errors.
|
|
|
|
# RELAXWARNINGS=1 - Use less compiler warnings/errors.
|
|
|
|
# ERRORMODE=1 - Treat most compiler warnings as errors.
|
|
|
|
# NOCASTALIGNWARN=1 - ?
|
|
|
|
# NOLDWARNING=1 - ?
|
|
|
|
# NOSDLMAIN=1 - ?
|
|
|
|
# SDLMAIN=1 - ?
|
|
|
|
#
|
|
|
|
# Library configuration flags:
|
|
|
|
# Everything here is an override.
|
|
|
|
#
|
|
|
|
# PNG_PKGCONFIG= - libpng-config command.
|
|
|
|
# PNG_CFLAGS=, PNG_LDFLAGS=
|
|
|
|
#
|
|
|
|
# CURLCONFIG= - curl-config command.
|
|
|
|
# CURL_CFLAGS=, CURL_LDFLAGS=
|
|
|
|
#
|
|
|
|
# VALGRIND_PKGCONFIG= - pkg-config package name.
|
|
|
|
# VALGRIND_CFLAGS=, VALGRIND_LDFLAGS=
|
|
|
|
#
|
|
|
|
# LIBGME_PKGCONFIG=, LIBGME_CFLAGS=, LIBGME_LDFLAGS=
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# LIBOPENMPT_PKGCONFIG=
|
|
|
|
# LIBOPENMPT_CFLAGS=, LIBOPENMPT_LDFLAGS=
|
|
|
|
#
|
|
|
|
# ZLIB_PKGCONFIG=, ZLIB_CFLAGS=, ZLIB_LDFLAGS=
|
|
|
|
#
|
|
|
|
# SDL_PKGCONFIG=
|
|
|
|
# SDL_CONFIG= - sdl-config command.
|
|
|
|
# SDL_CFLAGS=, SDL_LDFLAGS=
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
clean_targets=cleandep clean distclean info
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
.PHONY : $(clean_targets) all
|
2019-01-02 07:37:48 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
goals:=$(or $(MAKECMDGOALS),all)
|
|
|
|
cleanonly:=$(filter $(clean_targets),$(goals))
|
|
|
|
destructive:=$(filter-out info,$(cleanonly))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-22 22:14:42 +00:00
|
|
|
ifndef cleanonly
|
|
|
|
include Makefile.d/old.mk
|
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
include Makefile.d/util.mk
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef PREFIX
|
|
|
|
CC:=$(PREFIX)-gcc
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
OBJDUMP_OPTS?=--wide --source --line-numbers
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
OBJCOPY:=$(call Prefix,objcopy)
|
2021-06-22 22:47:48 +00:00
|
|
|
OBJDUMP:=$(call Prefix,objdump)
|
2021-05-02 09:54:51 +00:00
|
|
|
WINDRES:=$(call Prefix,windres)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef YASM
|
|
|
|
NASM?=yasm
|
|
|
|
else
|
|
|
|
NASM?=nasm
|
2016-05-19 00:14:53 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef YASM
|
|
|
|
ifdef STABS
|
|
|
|
NASMOPTS?=-g stabs
|
|
|
|
else
|
|
|
|
NASMOPTS?=-g dwarf2
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
2021-05-02 09:54:51 +00:00
|
|
|
else
|
|
|
|
NASMOPTS?=-g
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
GZIP?=gzip
|
|
|
|
GZIP_OPTS?=-9 -f -n
|
2021-02-18 15:03:25 +00:00
|
|
|
ifdef WINDOWSHELL
|
2021-05-02 09:54:51 +00:00
|
|
|
GZIP_OPTS+=--rsyncable
|
2021-02-18 15:03:25 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
UPX_OPTS?=--best --preserve-build-id
|
2014-03-15 16:59:03 +00:00
|
|
|
ifndef ECHO
|
2021-05-02 09:54:51 +00:00
|
|
|
UPX_OPTS+=-qq
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
include Makefile.d/detect.mk
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# make would try to remove the implicitly made directories
|
|
|
|
.PRECIOUS : %/ comptime.c
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-21 21:47:42 +00:00
|
|
|
sources:=
|
2021-05-02 09:54:51 +00:00
|
|
|
makedir:=../make
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# -DCOMPVERSION: flag to use comptime.h
|
|
|
|
opts:=-DCOMPVERSION -g
|
|
|
|
libs:=
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
nasm_format:=
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# This is a list of variables names, of which if defined,
|
|
|
|
# also defines the name as a macro to the compiler.
|
|
|
|
passthru_opts:=
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
include Makefile.d/platform.mk
|
|
|
|
include Makefile.d/features.mk
|
|
|
|
include Makefile.d/versions.mk
|
2015-01-10 22:35:36 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef DEBUGMODE
|
|
|
|
makedir:=$(makedir)/debug
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
depdir:=$(makedir)/deps
|
|
|
|
objdir:=$(makedir)/objs
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-21 21:47:42 +00:00
|
|
|
# very sophisticated dependency
|
|
|
|
sources+=\
|
|
|
|
$(call List,Sourcefile)\
|
|
|
|
$(call List,blua/Sourcefile)\
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
depends:=$(basename $(filter %.c %.s,$(sources)))
|
|
|
|
objects:=$(basename $(filter %.c %.s %.nas,$(sources)))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
depends:=$(depends:%=$(depdir)/%.d)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# comptime.o added directly to objects instead of thru
|
|
|
|
# sources because comptime.c includes comptime.h, but
|
|
|
|
# comptime.h may not exist yet. It's a headache so this is
|
|
|
|
# easier.
|
|
|
|
objects:=$(objects:=.o) comptime.o
|
2018-09-18 16:31:47 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# windows resource file
|
|
|
|
rc_file:=$(basename $(filter %.rc,$(sources)))
|
|
|
|
ifdef rc_file
|
|
|
|
objects+=$(rc_file:=.res)
|
2018-09-18 16:31:47 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
objects:=$(addprefix $(objdir)/,$(objects))
|
2018-10-04 23:47:19 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef DEBUGMODE
|
|
|
|
bin:=../bin/debug
|
2018-10-04 23:47:19 +00:00
|
|
|
else
|
2021-05-02 09:54:51 +00:00
|
|
|
bin:=../bin
|
2018-10-04 23:47:19 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# default EXENAME (usually set by platform)
|
|
|
|
EXENAME?=srb2
|
|
|
|
DBGNAME?=$(EXENAME).debug
|
2020-03-01 10:36:56 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
exe:=$(bin)/$(EXENAME)
|
|
|
|
dbg:=$(bin)/$(DBGNAME)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-16 22:48:16 +00:00
|
|
|
build_done==== Build is done, look for \
|
2021-06-16 23:58:47 +00:00
|
|
|
$(<F) at $(abspath $(<D)) ===
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
all : $(exe)
|
|
|
|
$(call Echo,$(build_done))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifndef VALGRIND
|
2021-06-16 22:34:58 +00:00
|
|
|
dump : $(dbg).txt
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef STATIC
|
|
|
|
libs+=-static
|
2017-01-01 22:07:34 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# build with profiling information
|
|
|
|
ifdef PROFILEMODE
|
|
|
|
opts+=-pg
|
|
|
|
libs+=-pg
|
2017-01-01 22:07:34 +00:00
|
|
|
endif
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
ifdef DEBUGMODE
|
2021-05-02 09:54:51 +00:00
|
|
|
debug_opts=-D_DEBUG
|
|
|
|
else # build a normal optimized version
|
|
|
|
debug_opts=-DNDEBUG
|
|
|
|
opts+=-O3
|
2016-05-27 18:14:04 +00:00
|
|
|
endif
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# debug_opts also get passed to windres
|
|
|
|
opts+=$(debug_opts)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS)
|
|
|
|
libs+=$(LDFLAGS)
|
|
|
|
asflags:=$(ASFLAGS) -x assembler-with-cpp
|
|
|
|
|
|
|
|
cc=$(CC)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef DISTCC
|
2021-06-22 22:47:48 +00:00
|
|
|
cc=distcc $(CC)
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef CCACHE
|
2021-06-22 22:47:48 +00:00
|
|
|
cc=ccache $(CC)
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-02-18 15:03:25 +00:00
|
|
|
ifndef SILENT
|
2021-05-02 09:54:51 +00:00
|
|
|
# makefile will 'restart' when it finishes including the
|
|
|
|
# dependencies.
|
|
|
|
ifndef MAKE_RESTARTS
|
2021-05-04 23:54:47 +00:00
|
|
|
ifndef destructive
|
2021-05-02 09:54:51 +00:00
|
|
|
$(shell $(CC) -v)
|
|
|
|
define flags =
|
2020-11-19 21:17:56 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
CC ........ $(cc)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
CFLAGS .... $(opts)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
LDFLAGS ... $(libs)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
endef
|
|
|
|
$(info $(flags))
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
2021-05-02 09:54:51 +00:00
|
|
|
# don't generate dependency files if only cleaning
|
|
|
|
ifndef cleanonly
|
|
|
|
$(info Checking dependency files...)
|
|
|
|
include $(depends)
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
LD:=$(CC)
|
2021-06-22 22:47:48 +00:00
|
|
|
cc:=$(cc) $(opts)
|
|
|
|
nasm=$(NASM) $(NASMOPTS) -f $(nasm_format)
|
2021-06-16 22:34:58 +00:00
|
|
|
ifdef UPX
|
2021-06-22 22:47:48 +00:00
|
|
|
upx=$(UPX) $(UPX_OPTS)
|
2021-06-16 22:34:58 +00:00
|
|
|
endif
|
2021-06-22 22:47:48 +00:00
|
|
|
windres=$(WINDRES) $(WINDRESFLAGS)\
|
2021-05-02 09:54:51 +00:00
|
|
|
$(debug_opts) --include-dir=win32 -O coff
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
%/ :
|
2021-05-05 05:34:20 +00:00
|
|
|
$(.)$(mkdir) $(call Windows_path,$@)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# this is needed so the target can be referenced in the
|
|
|
|
# prerequisites
|
|
|
|
.SECONDEXPANSION :
|
2016-05-19 00:14:53 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
# 'UPX' is also recognized in the environment by upx
|
2021-06-16 22:34:58 +00:00
|
|
|
unexport UPX
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# executable stripped of debugging symbols
|
|
|
|
$(exe) : $(dbg) | $$(@D)/
|
|
|
|
$(.)$(OBJCOPY) --strip-debug $< $@
|
|
|
|
$(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@
|
2021-06-16 22:34:58 +00:00
|
|
|
ifdef UPX
|
2021-05-02 09:54:51 +00:00
|
|
|
$(call Echo,Compressing final executable...)
|
2021-06-22 22:47:48 +00:00
|
|
|
$(.)-$(upx) $@
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# original executable with debugging symbols
|
|
|
|
$(dbg) : $(objects) | $$(@D)/
|
|
|
|
$(call Echo,Linking $(@F)...)
|
2021-06-22 22:47:48 +00:00
|
|
|
$(.)$(LD) -o $@ $^ $(libs)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# disassembly of executable
|
|
|
|
$(dbg).txt : $(dbg)
|
|
|
|
$(call Echo,Dumping debugging info...)
|
2021-06-22 22:47:48 +00:00
|
|
|
$(.)$(OBJDUMP) $(OBJDUMP_OPTS) $< > $@
|
|
|
|
$(.)$(GZIP) $(GZIP_OPTS) $@
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# '::' means run unconditionally
|
|
|
|
# this really updates comptime.h
|
|
|
|
comptime.c ::
|
|
|
|
ifdef WINDOWSHELL
|
|
|
|
$(.)..\comptime.bat .
|
|
|
|
else
|
|
|
|
$(.)../comptime.sh .
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# I wish I could make dependencies out of rc files :(
|
|
|
|
$(objdir)/win32/Srb2win.res : \
|
|
|
|
win32/afxres.h win32/resource.h
|
2021-03-01 01:02:08 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
# dependency recipe template
|
|
|
|
# 1: source file suffix
|
|
|
|
# 2: extra flags to gcc
|
|
|
|
define _recipe =
|
|
|
|
$(depdir)/%.d : %.$(1) | $$$$(@D)/
|
2021-02-18 14:15:11 +00:00
|
|
|
ifndef WINDOWSHELL
|
2021-05-02 09:54:51 +00:00
|
|
|
ifdef Echo_name
|
|
|
|
@printf '%-20.20s\r' $$<
|
2021-02-18 14:15:11 +00:00
|
|
|
endif
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|
2021-06-22 22:47:48 +00:00
|
|
|
$(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$<
|
2021-03-01 01:02:08 +00:00
|
|
|
endef
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
$(eval $(call _recipe,c))
|
2021-06-22 22:47:48 +00:00
|
|
|
$(eval $(call _recipe,s,$(asflags)))
|
2021-05-02 09:54:51 +00:00
|
|
|
|
|
|
|
# compiling recipe template
|
|
|
|
# 1: target file suffix
|
|
|
|
# 2: source file suffix
|
|
|
|
# 3: compile command
|
|
|
|
define _recipe =
|
|
|
|
$(objdir)/%.$(1) : %.$(2) | $$$$(@D)/
|
|
|
|
$(call Echo_name,$$<)
|
|
|
|
$(.)$(3)
|
|
|
|
endef
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-06-22 22:47:48 +00:00
|
|
|
$(eval $(call _recipe,o,c,$(cc) -c -o $$@ $$<))
|
|
|
|
$(eval $(call _recipe,o,nas,$(nasm) -o $$@ $$<))
|
|
|
|
$(eval $(call _recipe,o,s,$(cc) $(asflags) -c -o $$@ $$<))
|
|
|
|
$(eval $(call _recipe,res,rc,$(windres) -i $$< -o $$@))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-05 05:34:20 +00:00
|
|
|
_rm=$(.)$(rmrf) $(call Windows_path,$(1))
|
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
cleandep :
|
2021-05-05 05:34:20 +00:00
|
|
|
$(call _rm,$(depends) comptime.h)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
clean :
|
2021-05-05 05:34:20 +00:00
|
|
|
$(call _rm,$(exe) $(dbg) $(dbg).txt $(objects))
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
distclean :
|
2021-06-29 21:42:40 +00:00
|
|
|
$(call _rm,../bin ../objs ../dep ../make comptime.h)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-05-02 09:54:51 +00:00
|
|
|
info:
|
|
|
|
ifdef WINDOWSHELL
|
|
|
|
@REM
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
2021-05-02 09:54:51 +00:00
|
|
|
@:
|
2014-03-15 16:59:03 +00:00
|
|
|
endif
|