roo_e/Makefile.djgpp

142 lines
2.9 KiB
Text

#
# Kangaroo Punch MultiPlayer Game Server Mark II
# Copyright (C) 2020-2021 Scott Duensing
#
# This program 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, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#
BACKEND=DJGPP
#BACKEND=GRX
# General
CC = gcc
LD = gcc
RM = rm -f
RMDIR = rm -rf
INSTALL = install
DEBUG = -g
## CHANGE THIS ##
TARGET = client
SRCDIR = .
OBJDIR = obj
BINDIR = bin
## CHANGE THIS ##
# CFLAGS, LDFLAGS, CPPFLAGS, PREFIX can be overriden on CLI
CFLAGS := $(DEBUG)
CFLAGS += -I$(SRCDIR)/shared -I$(SRCDIR)/client/src
CPPFLAGS :=
LDFLAGS :=
LDLIBS :=
PREFIX :=
TARGET_ARCH :=
# DJGPP
ifeq ($(BACKEND),DJGPP)
$(info Building DJGPP Backend)
CFLAGS += -DBACKEND_DJGPP
TARGET = vesa
endif
# GRX
ifeq ($(BACKEND),GRX)
$(info Building GRX Backend)
CFLAGS += -DBACKEND_GRX
CFLAGS += -I$(SRCDIR)/installed/dos/include
LDFLAGS := -L$(SRCDIR)/installed/dos/lib
LDLIBS := -lgrx20 -ljpeg -lpng -lz
TARGET = grx
endif
# Compiler Flags
ALL_CFLAGS := $(CFLAGS)
ALL_CFLAGS += -Wall -Ofast
#ALL_CFLAGS += -Wall -O0 -pg
# Preprocessor Flags
ALL_CPPFLAGS := $(CPPFLAGS)
# Linker Flags
ALL_LDFLAGS := $(LDFLAGS)
ALL_LDLIBS := $(LDLIBS) -lc
# Source, Binaries, Dependencies
SRC := $(shell find $(SRCDIR)/client -type f -name '*.c')
SRC += $(shell find $(SRCDIR)/shared -type f -name '*.c')
OBJ := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SRC:.c=.o))
DEP := $(OBJ:.o=.d)
BIN := $(BINDIR)/$(TARGET)
-include $(DEP)
#$(info [${SRC}])
#$(info [${OBJ}])
# Verbosity Control, ala automake
V = 0
# Verbosity for CC
REAL_CC := $(CC)
CC_0 = @echo "CC $<"; $(REAL_CC)
CC_1 = $(REAL_CC)
CC = $(CC_$(V))
# Verbosity for LD
REAL_LD := $(LD)
LD_0 = @echo "LD $@"; $(REAL_LD)
LD_1 = $(REAL_LD)
LD = $(LD_$(V))
# Verbosity for RM
REAL_RM := $(RM)
RM_0 = @echo "Cleaning..."; $(REAL_RM)
RM_1 = $(REAL_RM)
RM = $(RM_$(V))
# Verbosity for RMDIR
REAL_RMDIR := $(RMDIR)
RMDIR_0 = @$(REAL_RMDIR)
RMDIR_1 = $(REAL_RMDIR)
RMDIR = $(RMDIR_$(V))
# Build Rules
.PHONY: clean
.DEFAULT_GOAL := all
all: setup $(BIN)
setup: dir
remake: clean all
dir:
@mkdir -p $(OBJDIR)
@mkdir -p $(BINDIR)
$(BIN): $(OBJ)
$(LD) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -c -MMD -MP -o $@ $<
install: $(BIN)
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) $(BIN) $(PREFIX)/bin
clean:
$(RM) $(OBJ) $(DEP) $(BIN)
$(RMDIR) $(OBJDIR) $(BINDIR) 2> /dev/null; true