From c4445bf0ab97efd9b1f63f46c8fe5be0d816ae32 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 16 Apr 2021 00:20:59 -0400 Subject: [PATCH] hello Makefile --- unit_tests/Makefile | 20 +++++++++++++ unit_tests/rules.mk | 68 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 unit_tests/Makefile create mode 100644 unit_tests/rules.mk diff --git a/unit_tests/Makefile b/unit_tests/Makefile new file mode 100644 index 0000000..67512af --- /dev/null +++ b/unit_tests/Makefile @@ -0,0 +1,20 @@ +CSRC = ../src/hash.c + + +ifeq ($(OS),Windows_NT) +ifeq ($(USE_MINGW32_I686),) +#this one is 64 bit + TRGT = x86_64-w64-mingw32- +else +#this one was 32 bit + TRGT = i686-w64-mingw32- +endif +else + TRGT = +endif + +CC = $(CCPREFIX) $(TRGT)gcc +CPPC = $(CCPREFIX) $(TRGT)g++ + + +include rules.mk \ No newline at end of file diff --git a/unit_tests/rules.mk b/unit_tests/rules.mk new file mode 100644 index 0000000..0b105c6 --- /dev/null +++ b/unit_tests/rules.mk @@ -0,0 +1,68 @@ +# Output directory and files +ifeq ($(BUILDDIR),) + BUILDDIR = build +endif +ifeq ($(BUILDDIR),.) + BUILDDIR = build +endif +OUTFILES = $(BUILDDIR)/$(PROJECT) + + +# Source files groups and paths +ifeq ($(USE_THUMB),yes) + TCSRC += $(CSRC) + TCPPSRC += $(CPPSRC) +else + ACSRC += $(CSRC) + ACPPSRC += $(CPPSRC) +endif +ASRC = $(ACSRC)$(ACPPSRC) +TSRC = $(TCSRC)$(TCPPSRC) +SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC))) + +# Various directories +OBJDIR = $(BUILDDIR)/obj +LSTDIR = $(BUILDDIR)/lst + + +# Object files groups +ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o))) +TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o))) +TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o))) +ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) +ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o))) +OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) + + +# +# Makefile rules +# + +all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK + +MAKE_ALL_RULE_HOOK: + +$(OBJS): | $(BUILDDIR) + +$(BUILDDIR) $(OBJDIR) $(LSTDIR): +ifneq ($(USE_VERBOSE_COMPILE),yes) + @echo Compiler Options + @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o + @echo +endif + mkdir -p $(OBJDIR) + mkdir -p $(LSTDIR) + +$(BUILDDIR)/$(PROJECT): $(OBJS) +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ +else + @echo Linking $@ + @$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ +endif + +clean: + @echo Cleaning + -rm -fR .dep $(BUILDDIR) + @echo Done