-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (39 loc) · 1001 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
TARGET = hammock
CC = gcc
# compiling flags here
CFLAGS = -Wall -g
LINKER = gcc
# linking flags here
LFLAGS = -Wall -lcurl
# change these to proper directories where each file should be
SRCDIR = src
OBJDIR = obj
BINDIR = bin
PREFIX = /usr/local
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -f
mkdir = mkdir -p
$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
@echo "link complete"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@$(mkdir) $(OBJDIR) $(BINDIR)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "compiled "$<" successfully"
.PHONY: install
install:
@$(mkdir) $(DESTDIR)$(PREFIX)/bin
@cp $(BINDIR)/$(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
.PHONY: uninstall
uninstall:
@rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET)
.PHONY: clean
clean:
@$(rm) $(OBJECTS)
@$(rm) -r $(OBJDIR)
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@$(rm) -r $(OBJDIR)