Makefile 839 Bytes
Newer Older
Alejandro Mery's avatar
Alejandro Mery committed
1
2
.PHONY: all clean

3
4
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
Alejandro Mery's avatar
Alejandro Mery committed
5
6
7
8
9

srctree	?= ..
O	?= $(srctree)/out

OBJDIR	:= $(O)/tools
10
11
TOOLS	:= fexc fex2bin bin2fex meminfo
SRCS	:= fexc.c meminfo.c
Alejandro Mery's avatar
Alejandro Mery committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

INCLUDES = -I$(srctree)/include
CFLAGS	 = -O2
CFLAGS  += -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L
CFLAGS  += $(INCLUDES)

DEPS	:= $(OBJDIR)/deps.mk

all: $(addprefix $(O)/,$(TOOLS))

clean:
	rm -vf $(DEPS)

# fexc
$(O)/fexc: $(OBJDIR)/fexc.o $(O)/libfex.a
	$(CC) -o $@ $^ $(CFLAGS)

%.o:
	mkdir -p $(@D)
	$(CC) -c -o $@ $(filter %.c,$^) $(CFLAGS)

$(O)/fex2bin $(O)/bin2fex: $(O)/fexc
	ln -svnf fexc $@

36
37
38
$(O)/meminfo: $(OBJDIR)/meminfo.o
	$(CC) -static $(CFLAGS) -o $@ $^

Alejandro Mery's avatar
Alejandro Mery committed
39
40
41
42
43
44
45
46
47
# dependencies
$(DEPS): Makefile
	mkdir -p $(@D)
	for x in $(SRCS); do \
		$(CC) -MM -MT $(OBJDIR)/$${x%.c}.o $$x $(INCLUDES); \
	done > $@~
	mv $@~ $@

include $(DEPS)