-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (36 loc) · 1.11 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
PLATFORM = pc
ifeq ($(PLATFORM), avr)
CC = avr-gcc
CXX = avr-g++
else
CC = gcc
CXX = g++
endif
MCU = atmega2560
F_CPU = 16000000UL
avr_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DAVR
EXTERN_INCLUDES = ../io/src $($(PLATFORM)_EXTERN_INCLUDES)
CFLAGS = -c -std=c11 -Wall -Wpedantic -Wextra -I$(SRCDIR) -g $($(PLATFORM)_CFLAGS) $(addprefix -I, $(EXTERN_INCLUDES))
CPPFLAGS = -DIEEE754 $($(PLATFORM)_CPPFLAGS)
BUILDDIR = build_$(PLATFORM)
SRCDIR = src
SOURCES = $(wildcard $(SRCDIR)/*.c $(SRCDIR)/*.cpp $(SRCDIR)/$(PLATFORM)/*.c $(SRCDIR)/$(PLATFORM)/*.cpp)
OBJECTS = $(addprefix $(BUILDDIR)/, $(addsuffix .o, $(notdir $(basename $(SOURCES)))))
.PHONY: all
all: $(BUILDDIR) $(OBJECTS)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
$(CC) $< -o $@ $(CFLAGS) $(CPPFLAGS)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $< -o $@ $(CXXFLAGS) $(CPPFLAGS)
$(BUILDDIR)/%.o: $(SRCDIR)/$(PLATFORM)/%.c
$(CC) $< -o $@ $(CFLAGS) $(CPPFLAGS)
$(BUILDDIR)/%.o: $(SRCDIR)/$(PLATFORM)/%.cpp
$(CXX) $< -o $@ $(CXXFLAGS) $(CPPFLAGS)
.PHONY: clean
clean:
rm -f build_pc/*
rm -f build_avr/*
rm -fd build_pc
rm -fd build_avr