-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
48 lines (38 loc) · 1.21 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
# Uniicorn Makefile
# the directories to compile, include and use for objects
SRC_DIR := source
INC_DIRS := include
BUILD_DIR := build
# the libraries to link the application with
LIBS := unicorn
# the output filename
OUT_FILE := uniicorn
ifeq ($(OS),Windows_NT)
OUT_FILE := $(addsuffix .exe,$(OUT_FILE))
endif
# add the include directories to the C flags
CFLAGS += $(patsubst %,-I%,$(INC_DIRS))
# add the libraries to the LD flags
LDFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) $(patsubst %,-l%,$(LIBS))
# list of sources and object files required to compile
SOURCES := $(wildcard $(SRC_DIR)/*.c)
OBJECTS := $(subst $(SRC_DIR),$(BUILD_DIR),$(patsubst %.c,%.c.o,$(SOURCES)))
# all phony entry
all: $(OUT_FILE)
# linking the objects together into an executable
$(OUT_FILE): $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
# compiling all the source files into objects
$(BUILD_DIR)/%.c.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
# clean up the temp build dir and the executable
clean:
@echo Cleaning...
@rm -rf $(BUILD_DIR)
@rm $(OUT_FILE)
@rm boot1-extract
boot1-extract:
$(CC) $(CFLAGS) source/util_aes.c source/util_sha1.c tools/boot1-extract.c -o $@
tools: boot1-extract
.PHONY: all clean boot1-extract tools