From ad8213f35523cbb07f418ae275af448a47cc0288 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sun, 25 May 2025 22:37:57 -0300 Subject: linux Makefile + fix most compilation problems I wanted to see if the compiler had any problems with the code so far and added a few stub definitions so that each file would properly compile. We still fail when linking but we're able to to find and fix compile time errors. --- Makefile | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..18037c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +SRCDIR = src +BUILDDIR = build +OUTPUTEXE = game + +CC = g++ +CFLAGS = -m64 -fno-strict-aliasing -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation -std=c++11 -DOS_LINUX=1 -DARCH_X64=1 -D_CRT_SECURE_NO_WARNINGS=1 +LFLAGS = -Wl,-t + +DEBUG ?= 0 +ifneq ($(DEBUG), 0) + CFLAGS += -g -O0 +else + CFLAGS += -O2 +endif + +HEADERS = $(SRCDIR)/common.hh $(SRCDIR)/config.hh $(SRCDIR)/connection.hh $(SRCDIR)/containers.hh $(SRCDIR)/creature.hh $(SRCDIR)/enums.hh $(SRCDIR)/map.hh $(SRCDIR)/monster.hh $(SRCDIR)/objects.hh $(SRCDIR)/player.hh $(SRCDIR)/script.hh $(SRCDIR)/skill.hh $(SRCDIR)/thread.hh + +$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/config.obj $(BUILDDIR)/crcombat.obj $(BUILDDIR)/creature.obj $(BUILDDIR)/main.obj $(BUILDDIR)/map.obj $(BUILDDIR)/objects.obj $(BUILDDIR)/player.obj $(BUILDDIR)/script.obj $(BUILDDIR)/shm.obj $(BUILDDIR)/skill.obj $(BUILDDIR)/thread.obj $(BUILDDIR)/time.obj $(BUILDDIR)/util.obj + $(CC) $(CFLAGS) $(LFLAGS) -o $@ $^ + +$(BUILDDIR)/config.obj: $(SRCDIR)/config.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/crcombat.obj: $(SRCDIR)/crcombat.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/creature.obj: $(SRCDIR)/creature.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/main.obj: $(SRCDIR)/main.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/map.obj: $(SRCDIR)/map.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/objects.obj: $(SRCDIR)/objects.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/player.obj: $(SRCDIR)/player.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/script.obj: $(SRCDIR)/script.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/shm.obj: $(SRCDIR)/shm.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/skill.obj: $(SRCDIR)/skill.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/thread.obj: $(SRCDIR)/thread.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/time.obj: $(SRCDIR)/time.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +$(BUILDDIR)/util.obj: $(SRCDIR)/util.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + +.PHONY: clean +clean: + @rm -r $(BUILDDIR) -- cgit v1.2.3