118 lines
2.5 KiB
Text
118 lines
2.5 KiB
Text
#
|
|
# Kangaroo Punch Multi Player 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/>.
|
|
#
|
|
|
|
# General
|
|
CC = gcc
|
|
LD = gcc
|
|
RM = rm -rf
|
|
RMDIR = rmdir
|
|
INSTALL = install
|
|
DEBUG = -g
|
|
|
|
## CHANGE THIS ##
|
|
TARGET = client
|
|
SRCDIR = src
|
|
OBJDIR = obj
|
|
BINDIR = bin
|
|
## CHANGE THIS ##
|
|
|
|
# CFLAGS, LDFLAGS, CPPFLAGS, PREFIX can be overriden on CLI
|
|
CFLAGS := $(DEBUG) -I$(SRCDIR) -I$(SRCDIR)/dos -I$(SRCDIR)/gui -I$(SRCDIR)/thirdparty
|
|
CPPFLAGS :=
|
|
LDFLAGS :=
|
|
PREFIX := /usr/local
|
|
TARGET_ARCH :=
|
|
|
|
|
|
# Compiler Flags
|
|
ALL_CFLAGS := $(CFLAGS)
|
|
ALL_CFLAGS += -Wall -O2
|
|
|
|
# Preprocessor Flags
|
|
ALL_CPPFLAGS := $(CPPFLAGS)
|
|
|
|
# Linker Flags
|
|
ALL_LDFLAGS := $(LDFLAGS)
|
|
ALL_LDLIBS := -lc
|
|
|
|
|
|
# Source, Binaries, Dependencies
|
|
SRC := $(shell find $(SRCDIR) -type f -name '*.c' | grep -v '/linux/')
|
|
OBJ := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SRC:.c=.o))
|
|
DEP := $(OBJ:.o=.d)
|
|
BIN := $(BINDIR)/$(TARGET)
|
|
-include $(DEP)
|
|
|
|
|
|
# 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
|
|
|