blob: fb9ce4b4e91819e62fa61c143ca115f6d6d8e2f9 (
plain)
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
|
CC := gcc
INSTALL := install
CFLAGS += -g -O2 -flto -Wall
LDFLAGS :=
LIBS := -lX11 -lXi
DESTDIR :=
PREFIX := /usr/local
CFLAGS += -DPREFIX=$(PREFIX)
BIN = execonkp
SRCS = main.c
V = @ # Verbose build: make V=1
Q = $(V:1=)
QUIET_CC = $(Q:@=@echo ' CC '$@;)$(CC)
QUIET_DEPEND = $(Q:@=@echo ' DEPEND '$@;)$(CC)
DEPS = $(patsubst %.c,dep/%.d,$(1))
OBJS = $(patsubst %.c,obj/%.o,$(1))
.SUFFIXES:
.PHONY: all install clean
.DEFAULT_GOAL := all
# Generate dependencies
$(call DEPS,$(SRCS)): dep/%.d: %.c
@mkdir -p $(dir $@)
$(QUIET_DEPEND) -o $@.tmp -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f $@.tmp $@
-include $(call DEPS,$(SRCS))
# Generate object files
$(call OBJS,$(SRCS)): obj/%.o:
@mkdir -p $(dir $@)
$(QUIET_CC) -o $@ -c $(CFLAGS) $<
all: $(BIN)
$(BIN): $(call OBJS,$(SRCS))
$(QUIET_CC) $(CFLAGS) -o $(BIN) $(LDFLAGS) $(LIBS) $(call OBJS,$(SRCS))
clean:
rm -Rf dep obj core *~ $(BIN)
install: $(BIN)
$(INSTALL) -d -m755 $(DESTDIR)$(PREFIX)/bin/
$(INSTALL) -m755 $(BIN) $(DESTDIR)$(PREFIX)/bin/
|