diff options
-rw-r--r-- | Makefile | 38 | ||||
-rw-r--r-- | src/libelfu/elfops/check.c (renamed from src/elfops/check.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/check.c (renamed from src/modelops/check.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/clone.c (renamed from src/modelops/clone.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/detour.c (renamed from src/modelops/detour.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/dump.c (renamed from src/modelops/dump.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/fromFile.c (renamed from src/modelops/fromFile.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/layout.c (renamed from src/modelops/layout.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/phdr.c (renamed from src/modelops/phdr.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/reladd.c (renamed from src/modelops/reladd.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/relocate.c (renamed from src/modelops/relocate.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/section.c (renamed from src/modelops/section.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/symtab.c (renamed from src/modelops/symtab.c) | 0 | ||||
-rw-r--r-- | src/libelfu/modelops/toFile.c (renamed from src/modelops/toFile.c) | 0 |
14 files changed, 25 insertions, 13 deletions
@@ -1,4 +1,5 @@ -PROJ := elfucli +LIBNAME := elfu +EXENAME := elfucli LIBRARIES := libelf @@ -6,21 +7,31 @@ BUILDDIR := build INCLUDEDIR := include SRCDIR := src -EXE := $(BUILDDIR)/$(PROJ) +EXE := $(BUILDDIR)/$(EXENAME) +STATICLIB := $(BUILDDIR)/lib$(LIBNAME).a + +SHARED_VERMAJ := 0 +SHARED_VERMIN := 0 +SHARED_VERREV := 0 +SHAREDLIB := $(BUILDDIR)/lib$(LIBNAME).so.$(SHARED_VERMAJ).$(SHARED_VERMIN).$(SHARED_VERREV) + HEADERS := $(shell find $(INCLUDEDIR)/ -iname "*.h") HEADERS += $(shell find $(SRCDIR)/ -iname "*.h") -SOURCES := $(shell find $(SRCDIR)/ -iname "*.c") -OBJS := $(patsubst %.c, $(BUILDDIR)/%.o, $(SOURCES)) +ALLSRCS := $(shell find $(SRCDIR)/ -iname "*.c") +LIBSRCS := $(filter $(SRCDIR)/lib$(LIBNAME)/%.c, $(ALLSRCS)) +EXESRCS := $(filter-out $(SRCDIR)/lib$(LIBNAME)/%.c, $(ALLSRCS)) +LIBOBJS := $(patsubst %.c, $(BUILDDIR)/%.o, $(LIBSRCS)) +EXEOBJS := $(patsubst %.c, $(BUILDDIR)/%.o, $(EXESRCS)) INCLUDES := $(patsubst %, -I%, $(INCLUDEDIR) $(SRCDIR)) $(shell pkg-config --cflags-only-I $(LIBRARIES)) -CFLAGS := -g -Wall -pedantic -Wno-variadic-macros $(shell pkg-config --cflags-only-other $(LIBRARIES)) +CFLAGS := -g -Wall -pedantic -Wno-variadic-macros -fPIC $(shell pkg-config --cflags-only-other $(LIBRARIES)) LDFLAGS := $(shell pkg-config --libs $(LIBRARIES)) -.PHONY: default -default: $(EXE) +.PHONY: all +all: $(STATICLIB) $(SHAREDLIB) $(EXE) .PHONY: check @@ -30,13 +41,17 @@ check: $(EXE) .PHONY: debug debug: $(EXE) - gdb $(EXE) $(shell ps -e | sed "s/^ *\([0-9]\+\) .*$(PROJ).*$$/\1/g;te;d;:e") + gdb $(EXE) $(shell ps -e | sed "s/^ *\([0-9]\+\) .*$(EXENAME).*$$/\1/g;te;d;:e") -$(EXE): $(OBJS) - @if [ ! -d $(BUILDDIR) ] ; then echo "Error: Build dir '$(BUILDDIR)' does not exist." ; false ; fi +$(EXE): $(EXEOBJS) $(STATICLIB) gcc -o $@ $^ $(LDFLAGS) +$(SHAREDLIB): $(LIBOBJS) + gcc -shared -Wl,-soname,lib$(LIBNAME).so.$(SHARED_VERMAJ) -o $@ $^ $(LDFLAGS) + +$(STATICLIB): $(LIBOBJS) + ar rcs $@ $^ $(BUILDDIR)/$(SRCDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) @if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi @@ -45,9 +60,6 @@ $(BUILDDIR)/$(SRCDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) .PHONY: clean clean: - rm -f $(STATICLIB) - rm -f $(OBJS) - rm -f $(TESTEXES) rm -rf $(BUILDDIR)/ make -C tests clean diff --git a/src/elfops/check.c b/src/libelfu/elfops/check.c index e184b26..e184b26 100644 --- a/src/elfops/check.c +++ b/src/libelfu/elfops/check.c diff --git a/src/modelops/check.c b/src/libelfu/modelops/check.c index 5234bef..5234bef 100644 --- a/src/modelops/check.c +++ b/src/libelfu/modelops/check.c diff --git a/src/modelops/clone.c b/src/libelfu/modelops/clone.c index 8f92919..8f92919 100644 --- a/src/modelops/clone.c +++ b/src/libelfu/modelops/clone.c diff --git a/src/modelops/detour.c b/src/libelfu/modelops/detour.c index 075d945..075d945 100644 --- a/src/modelops/detour.c +++ b/src/libelfu/modelops/detour.c diff --git a/src/modelops/dump.c b/src/libelfu/modelops/dump.c index b2e172e..b2e172e 100644 --- a/src/modelops/dump.c +++ b/src/libelfu/modelops/dump.c diff --git a/src/modelops/fromFile.c b/src/libelfu/modelops/fromFile.c index dd8b462..dd8b462 100644 --- a/src/modelops/fromFile.c +++ b/src/libelfu/modelops/fromFile.c diff --git a/src/modelops/layout.c b/src/libelfu/modelops/layout.c index 8abc766..8abc766 100644 --- a/src/modelops/layout.c +++ b/src/libelfu/modelops/layout.c diff --git a/src/modelops/phdr.c b/src/libelfu/modelops/phdr.c index d26eb77..d26eb77 100644 --- a/src/modelops/phdr.c +++ b/src/libelfu/modelops/phdr.c diff --git a/src/modelops/reladd.c b/src/libelfu/modelops/reladd.c index bc909e4..bc909e4 100644 --- a/src/modelops/reladd.c +++ b/src/libelfu/modelops/reladd.c diff --git a/src/modelops/relocate.c b/src/libelfu/modelops/relocate.c index eefed02..eefed02 100644 --- a/src/modelops/relocate.c +++ b/src/libelfu/modelops/relocate.c diff --git a/src/modelops/section.c b/src/libelfu/modelops/section.c index 2675126..2675126 100644 --- a/src/modelops/section.c +++ b/src/libelfu/modelops/section.c diff --git a/src/modelops/symtab.c b/src/libelfu/modelops/symtab.c index ef8443f..ef8443f 100644 --- a/src/modelops/symtab.c +++ b/src/libelfu/modelops/symtab.c diff --git a/src/modelops/toFile.c b/src/libelfu/modelops/toFile.c index 368f12a..368f12a 100644 --- a/src/modelops/toFile.c +++ b/src/libelfu/modelops/toFile.c |