From 421e7400142aa6ce19410591870d064657ad54c9 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 26 Sep 2022 11:00:45 -0300 Subject: [PATCH] Add building static lib to makefile and a header which includes every other header --- Makefile | 22 +++++++++++++++++----- include/rabbitizer.h | 20 ++++++++++++++++++++ setup.cfg | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 include/rabbitizer.h diff --git a/Makefile b/Makefile index 8e3a991..8713bc7 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,11 @@ ASAN ?= 0 EXPERIMENTAL ?= 0 CC := clang +AR := ar IINC := -I include CSTD := -std=c11 -CFLAGS := -LDFLAGS := +CFLAGS := -fPIC +LDFLAGS := -Lbuild -lrabbitizer WARNINGS := -Wall -Wextra -Wpedantic # WARNINGS := -Wall -Wextra -Wpedantic -Wpadded WARNINGS += -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=vla -Werror=switch -Werror=implicit-fallthrough -Werror=unused-function -Werror=unused-parameter -Werror=shadow @@ -43,6 +44,8 @@ H_FILES := $(foreach dir,$(IINC),$(wildcard $(dir)/**/*.h)) O_FILES := $(foreach f,$(C_FILES:.c=.o),build/$f) DEP_FILES := $(O_FILES:%.o=%.d) +STATIC_LIB := build/librabbitizer.a +DYNAMIC_LIB := build/librabbitizer.so # create build directories $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) @@ -50,7 +53,10 @@ $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) #### Main Targets ### -all: tests +all: static tests + +static: $(STATIC_LIB) +dynamic: $(DYNAMIC_LIB) clean: $(RM) -rf build @@ -73,8 +79,14 @@ tests: build/test.elf build/rsptest.elf build/r5900test.elf build/registersTrack #### Various Recipes #### -build/%.elf: %.c $(O_FILES) - $(CC) -MMD $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ +build/%.elf: %.c | $(STATIC_LIB) + $(CC) -MMD $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +build/%.a: $(O_FILES) + $(AR) rcs $@ $^ + +build/%.so: $(O_FILES) + $(CC) -shared -o $@ $^ build/%.o: %.c # The -MMD flags additionaly creates a .d file with the same name as the .o file. diff --git a/include/rabbitizer.h b/include/rabbitizer.h new file mode 100644 index 0000000..15b4c0b --- /dev/null +++ b/include/rabbitizer.h @@ -0,0 +1,20 @@ +#ifndef RABBITIZER_H +#define RABBITIZER_H + +#include "common/Utils.h" +#include "common/RabbitizerConfig.h" + +#include "instructions/RabbitizerOperandType.h" +#include "instructions/RabbitizerInstrId.h" +#include "instructions/RabbitizerInstrSuffix.h" +#include "instructions/RabbitizerInstrDescriptor.h" +#include "instructions/RabbitizerRegister.h" +#include "instructions/RabbitizerInstruction.h" +#include "instructions/RabbitizerInstructionRsp.h" +#include "instructions/RabbitizerInstructionR5900.h" + +#include "analysis/RabbitizerTrackedRegisterState.h" +#include "analysis/RabbitizerLoPairingInfo.h" +#include "analysis/RabbitizerRegistersTracker.h" + +#endif diff --git a/setup.cfg b/setup.cfg index 20ad1e7..d63ecbd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ [metadata] name = rabbitizer -version = 1.2.0 +version = 1.2.1 author = Decompollaborate license = MIT description = MIPS instruction decoder