blob: cf87dd4b3aa326b1faed66f3459c967da5680302 (
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
|
VERSION := $(shell ./versie.sh)
PREFIX ?= /usr
CC := gcc
CFLAGS := -Wall -Wextra -std=c2x
ifeq ($(DEBUG),)
CFLAGS += -O2
else
CFLAGS += -Og -g
endif
CFLAGS += -D_GNU_SOURCE -DDRUKKEDOOS_VERSIE=\"$(VERSION)\"
CFLAGS += -Isrc -I.
LDFLAGS :=
OBJDIR := obj
TARGET := drukkedoos
SOURCES := $(shell find src -type f -name '*.c')
HEADERS := $(shell find . -type f -name '*.h')
OBJECTS := $(patsubst src/%.c,obj/%.o,$(SOURCES))
PROGNAMES := $(patsubst src/%.c,%,$(wildcard src/*.c))
PROGNAMES_X := $(patsubst %,X(%),$(PROGNAMES))
.PHONY: all clean install
all: $(TARGET)
clean:
rm -rf $(OBJDIR) $(TARGET)
install: $(TARGET)
mkdir -p $(PREFIX)/bin
install $(TARGET) $(PREFIX)/bin/drukkedoos
for name in $(PROGNAMES); do ln -vfs drukkedoos $(PREFIX)/bin/$$name; done
$(TARGET): main.c $(OBJECTS)
$(CC) -o $@ $^ $(LDFLAGS) -DPROGNAMES_XLIST="$(PROGNAMES_X)"
$(OBJECTS): obj/%.o: src/%.c $(HEADERS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
|