-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (39 loc) · 1.5 KB
/
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
52
# An example how you could use mkcres in a Makefile
#
# NOTE: THIS IS NOT a good example for a Makefile in general,
# I am not a Makefile expert and it just happens to work ;)
#
# Improvements and additions are welcome!
# Drop me a message at https://github.com/jahnf/mkcres
mkcres_DIR := ../..
mkcres_SCRIPT := $(mkcres_DIR)/mkcres.py
mkcres_OUTDIR := ./cresources
mkcres_CONFIG := resources.json
mkcres_CFILE := $(mkcres_DIR)/cresource.c
$(shell python2 $(mkcres_SCRIPT) create --quiet --outdir $(mkcres_OUTDIR) $(mkcres_CONFIG))
mkcres_FILES := $(shell python2 $(mkcres_SCRIPT) list --absolute $(mkcres_OUTDIR))
EXECUTABLE := example-02
SOURCES := main.c $(mkcres_CFILE) $(mkcres_FILES)
OBJECTS := $(addprefix obj/, $(notdir $(SOURCES:.c=.o)))
program_INCLUDE_DIRS := "../.."
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
.PHONY: all clean clean-mkcres distclean
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^
obj/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
obj/%.o: $(mkcres_OUTDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
obj/%.o: $(mkcres_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
clean-mkcres:
@rm $(mkcres_OUTDIR)/*
@rmdir $(mkcres_OUTDIR)
clean: clean-mkcres
@rm $(OBJECTS) $(EXECUTABLE)
@rmdir obj
distclean: clean