-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
60 lines (50 loc) · 2.08 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
56
57
58
59
60
#---------------------------------------------------------------------------------
# ENVIROMENT
#---------------------------------------------------------------------------------
ENVPREFIX :=
CC := $(ENVPREFIX)gcc
CXX := $(ENVPREFIX)gpp
LD := $(ENVPREFIX)ld
#---------------------------------------------------------------------------------
# SUFFIXES
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDE is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
SOURCES := source source/polarssl
INCLUDE := source
BUILD := build
#---------------------------------------------------------------------------------
# OBJECTS
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
OFILES := $(CFILES:.c=.o)
OFILES := $(foreach f,$(OFILES),$(BUILD)/$(notdir $(f)))
CFLAGS := -Wall -std=c99 $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) -DAPPNAME='"$(TARGET)"'
LDFLAGS :=
#---------------------------------------------------------------------------------
# RULES
#---------------------------------------------------------------------------------
.PHONY: all clean
all: $(TARGET)
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET) $(TARGET).exe
#---------------------------------------------------------------------------------
# TARGETS
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $(BUILD) ] || mkdir -p $(BUILD)
$(TARGET): $(BUILD) $(OFILES)
@$(CC) $(CFLAGS) $(LDFLAGS) -o $(TARGET) $(OFILES)
@echo buildt... $@
$(BUILD)/%.o: source/%.c
@echo $(notdir $@) ...
@$(CC) $(CFLAGS) -o $@ -c $^
$(BUILD)/%.o: source/polarssl/%.c
@echo $(notdir $@) ...
@$(CC) $(CFLAGS) -o $@ -c $^
#---------------------------------------------------------------------------------