-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (45 loc) · 2.35 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
53
54
55
CC := gcc
ASSETS_DIR := .
TMP := $(basename $(MAKECMDGOALS))
EXT := $(suffix $(MAKECMDGOALS))
INPUT_FILE := $(ASSETS_DIR)/$(TMP).xpm
NAME := $(basename $(TMP))
# get XPM_DATA field from file contents
FIELD := $(shell sed -n '/static/p' $(INPUT_FILE) | sed 's/^static\s\+char\s\+\*\s\+\(\w\+\).\+/\1/')
XPM_INCLUDE := -DXPM_FILE="\"$(INPUT_FILE)\""
TAG_NAME := $(guile (string-upcase "$(subst -,_,$(NAME))"))
CFLAGS := $(CFLAGS) -I.
BUILD_DIR := ./build
OUTPUT_FILE := $(BUILDDIR)/$(NAME)
TARGET := $(BUILDDIR)/$(NAME)
.PHONY: clean $(NAME).c $(NAME).h $(NAME).raw
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.DELETE_ON_ERROR:
$(NAME).h: converter.c $(INPUT_FILE) $(BUILD_DIR)
echo BUILD_DIR=$(BUILD_DIR)
$(CC) $(CFLAGS) $(XPM_INCLUDE) -DXPM_DATA="$(FIELD)" -DXPM_LABEL="\"$(guile (string-upcase "$(TAG_NAME)"))\"" -o $(BUILD_DIR)$(basename $(OUTPUT_FILE)) $<
$(basename $(OUTPUT_FILE)) $(INPUT_FILE) > $(BUILD_DIR)$(OUTPUT_FILE).h
rm $(BUILD_DIR)$(basename $(OUTPUT_FILE))
.DELETE_ON_ERROR:
$(NAME).c: converter.c $(INPUT_FILE) $(BUILD_DIR)
$(CC) $(CFLAGS) $(XPM_INCLUDE) -DXPM_DATA="$(FIELD)" -DXPM_LABEL="\"$(guile (string-upcase "$(TAG_NAME)"))\"" -o $(BUILD_DIR)$(basename $(OUTPUT_FILE)) $<
$(basename $(OUTPUT_FILE)) > $(BUILD_DIR)$(OUTPUT_FILE).c
$(basename $(OUTPUT_FILE)) --header > $(BUILD_DIR)$(OUTPUT_FILE).h
rm $(BUILD_DIR)$(basename $(OUTPUT_FILE))
.DELETE_ON_ERROR:
$(NAME).raw: converter.c $(INPUT_FILE) $(BUILD_DIR)
echo BUILD_DIR=$(BUILD_DIR)
$(CC) $(CFLAGS) $(XPM_INCLUDE) -DXPM_DATA="$(FIELD)" -DXPM_LABEL="\"$(guile (string-upcase "$(TAG_NAME)"))\"" -o $(BUILD_DIR)$(basename $(OUTPUT_FILE)) $<
$(BUILD_DIR)$(basename $(OUTPUT_FILE)) --contains-palette --raw $(BUILD_DIR)$(OUTPUT_FILE).raw
$(BUILD_DIR)$(basename $(OUTPUT_FILE)) --contains-palette --header > $(BUILD_DIR)$(OUTPUT_FILE).h
rm $(BUILD_DIR)$(basename $(OUTPUT_FILE))
.DELETE_ON_ERROR:
$(NAME).bin: converter.c $(INPUT_FILE) $(BUILD_DIR)
echo BUILD_DIR=$(BUILD_DIR)
$(CC) $(CFLAGS) $(XPM_INCLUDE) -DXPM_DATA="$(FIELD)" -DXPM_LABEL="\"$(guile (string-upcase "$(TAG_NAME)"))\"" -o $(BUILD_DIR)$(basename $(OUTPUT_FILE)) $<
$(BUILD_DIR)$(basename $(OUTPUT_FILE)) --contains-palette --basic --raw $(BUILD_DIR)$(OUTPUT_FILE).bin
$(BUILD_DIR)$(basename $(OUTPUT_FILE)) --contains-palette --basic --palette > $(BUILD_DIR)$(OUTPUT_FILE).bas
rm $(BUILD_DIR)$(basename $(OUTPUT_FILE))
clean:
rm -rf $(BUILD_DIR)