-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (29 loc) · 849 Bytes
/
Makefile
File metadata and controls
39 lines (29 loc) · 849 Bytes
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
TARGET := id100
CC := gcc
CFLAGS := -Ofast -flto=jobserver -Wall -fomit-frame-pointer
LFLAGS := -s
GIT_STATUS := $(shell git status --porcelain)
ifeq ($(strip $(GIT_STATUS)),)
DEFINES := -D GIT_HASH=\"$(shell git rev-parse --short=4 HEAD)\"
endif
SRCDIR := src
OBJDIR := obj
INSTALLDIR := /usr/local/bin
INSTALL := sudo install -o root -g root
RM := rm -rf
MKDIR := mkdir -p
.PHONY: default all clean remake install
default: $(TARGET)
all: default
remake: clean $(TARGET)
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(wildcard $(SRCDIR)/*.c))
-include $(OBJECTS:.o=.d)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@$(MKDIR) -p $(@D)
+$(CC) $(DEFINES) $(CFLAGS) -MMD -c $< -o $@
$(TARGET): $(OBJECTS)
+$(CC) $(CFLAGS) $(LFLAGS) $(OBJECTS) $(LIBS) -o $@
clean:
$(RM) $(TARGET) $(OBJDIR)
install: $(TARGET)
$(INSTALL) -s $(TARGET) $(INSTALLDIR)