-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
59 lines (44 loc) · 1.28 KB
/
GNUmakefile
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
52
53
54
55
56
57
58
59
TARGET := dwmguard
OBJDIR := obj
SRC := $(wildcard *.c)
OBJ := $(addprefix $(OBJDIR)/,$(notdir $(SRC:.c=.o)))
CC ?= cc
BUILD_HOST := build_host.h
INCLUDES :=
LIBS :=
CFLAGS := -Wall $(INCLUDES)
LFLAGS := $(LIBS)
INSTALL := install
INSTALL_ARGS := -o root -g root -m 755
INSTALL_DIR := /usr/local/bin/
ifeq ($(CC), $(filter $(CC), clang gcc cc))
CFLAGS += -std=c99 -pedantic
endif
all: debug
debug: CFLAGS += -g -DDEBUG
debug: LFLAGS += -g
debug: build
release: CFLAGS +=-Os
release: clean build
strip $(TARGET)
build: $(OBJDIR) $(BUILD_HOST) $(TARGET)
$(BUILD_HOST):
@echo "#define BUILD_HOST \"`hostname`\"" > $(BUILD_HOST)
@echo "#define BUILD_OS \"`uname`\"" >> $(BUILD_HOST)
@echo "#define BUILD_PLATFORM \"`uname -m`\"" >> $(BUILD_HOST)
@echo "#define BUILD_KERNEL \"`uname -r`\"" >> $(BUILD_HOST)
$(TARGET): $(BUILD_HOST) $(OBJ)
$(CC) $(LFLAGS) -o $@ $(OBJ)
$(OBJDIR)/%.o : %.c
$(CC) $(CFLAGS) -o $@ -c $?
$(OBJDIR):
@mkdir -p $(OBJDIR)
install: release
$(INSTALL) $(INSTALL_ARGS) $(TARGET) $(INSTALL_DIR)
@echo "DONE"
clean:
-rm -f *.core
-rm -f $(BUILD_HOST)
-rm -f $(TARGET)
-rm -rf ./$(OBJDIR)
.PHONY : all debug release build run clean objdir