aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile49
1 files changed, 49 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f467e80
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+CC ?= clang
+
+BUILD = build
+
+TARGET = $(BUILD)/ihex
+PREFIX = /usr
+
+SRC =\
+ src/main.c\
+ src/ihex.c\
+ src/util.c\
+ src/array.c
+
+INCLUDE = -Iinclude
+
+OBJ = $(patsubst src/%.c,$(BUILD)/%.o,$(SRC))
+DEPS = $(patsubst %.o,%.d,$(OBJ))
+
+DEPFLAGS = -MP -MMD
+
+CFLAGS = $(DEPFLAGS) $(INCLUDE) -Wall -pedantic
+LDFLAGS =
+
+all : $(TARGET)
+
+$(BUILD)/%.o : src/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(TARGET) : $(OBJ)
+ $(CC) $(LDFLAGS) -o $@ $+
+
+$(OBJ) : | $(BUILD)
+
+$(BUILD) :
+ mkdir -p $@
+
+install :
+ mkdir -p $(PREFIX)/bin
+ install -m 755 $(TARGET) $(PREFIX)/bin
+
+uninstall :
+ rm -f $(PREFIX)/bin/ihex
+
+clean :
+ rm -rf build
+
+.PHONY : clean install
+
+-include $(DEPS)