From cfdb103be823e3962b1551684c34cbf0d38b7477 Mon Sep 17 00:00:00 2001 From: VPR Date: Wed, 10 May 2023 10:17:49 -0400 Subject: [PATCH] Project reconfigured to use autotools/automake --- .gitignore | 82 +++++++++++++++++++++++++++++++++++++++++------ AUTHORS | 16 +++++++++ COPYING | 1 + ChangeLog | 2 ++ INSTALL | 1 + Makefile.am | 8 +++++ NEWS | 2 ++ README.md | 12 ++++--- Sources/Main.cpp | 5 +++ compile_flags.txt | 7 ---- configure.ac | 27 ++++++++++++++++ makefile | 63 ------------------------------------ 12 files changed, 141 insertions(+), 85 deletions(-) create mode 100644 AUTHORS create mode 120000 COPYING create mode 100644 ChangeLog create mode 120000 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS delete mode 100644 compile_flags.txt create mode 100644 configure.ac delete mode 100644 makefile diff --git a/.gitignore b/.gitignore index 1949580..4542919 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,65 @@ +# # Created by https://www.toptal.com/developers/gitignore/api/autotools +# Edit at https://www.toptal.com/developers/gitignore?templates=autotools + +### Autotools ### +# http://www.gnu.org/software/automake + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap +.deps/ +.dirstamp + +# http://www.gnu.org/software/autoconf + +autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.* +/config.cache +/config.guess +/config.h.in +/config.log +/config.status +/config.sub +/configure +/configure* +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +# https://www.gnu.org/software/libtool/ + +/ltmain.sh + +# http://www.gnu.org/software/texinfo + +/texinfo.tex + +# http://www.gnu.org/software/m4/ + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +# Generated Makefile +# (meta build system like autotools, +# can automatically generate from config.status script +# (which is called by configure script)) +Makefile + +### Autotools Patch ### +# End of https://www.toptal.com/developers/gitignore/api/autotools + # Prerequisites *.d @@ -35,15 +97,15 @@ # Exclude Folders venv bin -build +Build # Exclude Compiled Files -*.a -*.o -*.so -*.bin -*.obj -*.exe -*.lib -*.dll -vpr-extract +**/*.a +**/*.o +**/*.so +**/*.bin +**/*.obj +**/*.exe +**/*.lib +**/*.dll +**/vpr-extract diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..2ca6687 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,16 @@ +This is the AUTHORS file for the vpr-extract project located at: +https://github.com/0xvpr/vpr-extract + +Names should be inserted as follows: + +A: Alias Here +C: Contact Information +D: Description Here +C: Copyright Information + +------------------------- + +A: VPR +C: https://www.github.com/0xvpr (message me here) +D: Original Author +C: MIT diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..28ecdc8 --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +/usr/share/automake-1.16/COPYING \ No newline at end of file diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..1fa700c --- /dev/null +++ b/ChangeLog @@ -0,0 +1,2 @@ +2023-MAY-10 -> VPR + * Project reconfigured to build and install using GNU automake. diff --git a/INSTALL b/INSTALL new file mode 120000 index 0000000..e3f22c0 --- /dev/null +++ b/INSTALL @@ -0,0 +1 @@ +/usr/share/automake-1.16/INSTALL \ No newline at end of file diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..65165d7 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ +bin_PROGRAMS = vpr-extract +dist_doc_DATA = README.md +AUTOMAKE_OPTIONS = subdir-objects + +vpr_extract_SOURCES = Sources/Main.cpp +vpr_extract_CFLAGS = -std=c++17 -O2 -Wall -Wextra -Werror -Wshadow -Wpedantic -Wconversion \ + -ffast-math -funroll-loops +vpr_extract_LDFLAGS = -s diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..b71bf74 --- /dev/null +++ b/NEWS @@ -0,0 +1,2 @@ +* 2023-MAY-10 + Project reconfigured to build and install using GNU automake. diff --git a/README.md b/README.md index 73e06a5..8cff43c 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,14 @@ This project aims to provide a tool for the extraction of the .text section of a COFF object file. -## Build Instructions +## Build Instructions (Using GNU Autotools) ```bash -git clone https://github.com/0xvpr/vpr-extract -cd vpr-extract +git clone https://github.com/0xvpr/vpr-extract && cd vpr-extract +autoreconf -i +mkdir Build && cd Build +../configure --prefix=/usr/local make -# sudo make install # uncomment if you want it available globally (only recommended for LINUX/WSL/MSYS environments) +# make install # uncomment if you want it available globally ``` ## Example Usage @@ -26,5 +28,5 @@ vpr-extract path/to/file-1 path/to/file-2 ## Testing ```bash -make tests +make check ``` diff --git a/Sources/Main.cpp b/Sources/Main.cpp index 1d999d9..a76e98a 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -89,8 +89,13 @@ int main(int argc, char** argv) { file.read((char *)&file_header, sizeof(file_header)); switch (file_header.Machine) { + [[unlikely]] case machine_type::x86: + break; + [[unlikely]] case machine_type::iit: + break; + [[likely]] case machine_type::x64: break; default: diff --git a/compile_flags.txt b/compile_flags.txt deleted file mode 100644 index 4429cab..0000000 --- a/compile_flags.txt +++ /dev/null @@ -1,7 +0,0 @@ --std=c++2a --Iinclude --Wall --Wextra --Werror --Wshadow --Wconversion diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..4b9babd --- /dev/null +++ b/configure.ac @@ -0,0 +1,27 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.5]) +AC_INIT([vpr-extract], [1.0], [0x@vpr.io]) +AC_CONFIG_SRCDIR([Sources/Main.cpp]) +AC_CONFIG_HEADERS([config.h]) + +dnl Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +dnl Enable automake +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) + +dnl Checks for libraries. + +dnl Checks for header files. + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_INLINE +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T + +dnl Checks for library functions. + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT \ No newline at end of file diff --git a/makefile b/makefile deleted file mode 100644 index 61c1f79..0000000 --- a/makefile +++ /dev/null @@ -1,63 +0,0 @@ -TARGET = vpr-extract - -CC = g++ -CFLAGS = -O2 -Wall -Wextra -Werror -Wshadow -Wpedantic -Wconversion \ - -ffunction-sections -ffast-math -funroll-loops -fPIC - -LD = g++ -LDFLAGS = -s - -BIN = Bin -BUILD = Build - -SOURCE = Sources -OBJECT = $(BUILD) -SOURCES = $(wildcard $(SOURCE)/*.cpp) -OBJECTS = $(patsubst $(SOURCE)/%.cpp,$(OBJECT)/%.obj,$(SOURCES)) - -ifeq ($(PREFIX),) -PREFIX = /usr/local -endif - -MAKEFLAGS += $(prefix -j,$(shell nproc)) - -all: $(TARGET) -$(TARGET): $(BIN)/$(PROJECT) - -$(BIN)/$(PROJECT): $(BIN) $(BUILD) $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o $(BIN)/$(TARGET) - -$(OBJECT)/%.obj: $(SOURCE)/%.cpp - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -$(BIN): - mkdir -p $@ - -$(BUILD): - mkdir -p $@ - -.PHONY: tests -tests: - make -C Tests/PE - ./bin/$(TARGET) Tests/PE/x86-pe.o Tests/PE/x64-pe.o - #make -C Tests/ELF - #./bin/$(TARGET) Tests/PE/x86-elf.o Tests/PE/x64-elf.o - -.PHONY: install -install: $(BIN)/$(PROJECT) - install -d $(PREFIX)/bin - install -m 555 $(BIN)/$(TARGET) $(PREFIX)/bin - -.PHONY: clean -clean: - rm -fr `find . -name "*.o"` - rm -fr `find . -name "*.obj"` - rm -fr `find . -name "*.bin"` - rm -fr `find . -name "*.exe"` - rm -fr ./bin/* - rm -fr ./build/* - -.PHONY: extra-clean -extra-clean: - rm -fr ./bin - rm -fr ./build