summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-01-25 15:24:36 +0000
committernorly <ny-git@enpas.org>2013-02-11 01:24:36 +0000
commitd9eb4398773cbda1dc185f4cf7b1b0e4cb9fb135 (patch)
treea2421aa140b17db64df439f894fa892833e3ac96 /Makefile
parent43e69328d849391abfed996214eed1dca49b3ac3 (diff)
Print ELF header/segments/sections
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 46 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..df5f59f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,46 @@
+PROJ := elfedit
+
+BUILDDIR := build
+INCLUDEDIR := include
+SRCDIR := src
+
+EXE := $(BUILDDIR)/$(PROJ)
+HEADERS := $(shell find $(INCLUDEDIR)/ -iname "*.h")
+HEADERS += $(shell find $(SRCDIR)/ -iname "*.h")
+
+SOURCES := $(shell find $(SRCDIR)/ -iname "*.c")
+OBJS := $(patsubst %.c, $(BUILDDIR)/%.o, $(SOURCES))
+
+INCLUDES := $(patsubst %, -I%, $(INCLUDEDIR) $(SRCDIR)) -I /usr/include/libelf
+CFLAGS := -g -Wall
+LDFLAGS := -lelf
+
+
+
+.PHONY: default
+default: $(EXE)
+
+
+
+$(EXE): $(OBJS)
+ @if [ ! -d $(BUILDDIR) ] ; then echo "Error: Build dir '$(BUILDDIR)' does not exist." ; false ; fi
+ gcc $(LDFLAGS) -o $@ $^
+
+
+$(BUILDDIR)/$(SRCDIR)/%.o: $(SRCDIR)/%.c $(HEADERS)
+ @if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+ gcc $(INCLUDES) $(CFLAGS) -c -o $@ $<
+
+
+.PHONY: clean
+clean:
+ rm -f $(STATICLIB)
+ rm -f $(OBJS)
+ rm -f $(TESTEXES)
+ rm -rf $(BUILDDIR)/
+
+
+.PHONY: distclean
+distclean: clean
+ find . -xdev -name "*~" -exec rm {} \;
+ find . -xdev -name "core" -exec rm {} \;