summaryrefslogtreecommitdiff
path: root/Makefile
blob: 610bff9bffdea3171dd79d3f91371f4fc82d00a4 (plain)
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
P	= nios2sim-ng
VERSION	= 0.1

OBJS	= main.o image.o elf.o srec.o nios2.o memory.o instruction.o simulator.o \
	  device.o timer.o uart.o jtag_uart.o util.o
#OBJS	+= load_image.o nor_flash.o simulator.o simulator.o niosii.o i_type_handler.o j_type_handler.o \
#	   r_type_handler.o custom_instr.o timer.o

DEFS	= -DVERSION="\"$(VERSION)\"" -DDEBUG

CFLAGS	+= -g -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \
	   -Wno-packed-bitfield-compat -Wshadow \
	   $(DEFS)
LDFLAGS	+= -lelf

all: prepare $(P)

prepare:
	@mkdir -p .deps

$(P): $(OBJS)
	@echo LD $@
	@$(CC) $(LDFLAGS) -o $@ $^

-include $(addprefix .deps/,$(OBJS:.o=.o.dep))

%.o: %.c %.h
	@echo CC $@
	@$(CC) $(CFLAGS) -c $< -o $@
	@$(CC) -MM $(CFLAGS) $< > $(addprefix .deps/,$@.dep)

%.o: %.c
	@echo CC $@
	@$(CC) $(CFLAGS) -c $< -o $@
	@$(CC) -MM $(CFLAGS) $< > $(addprefix .deps/,$@.dep)

clean:
	@echo CLEAN
	@rm -rf .deps
	@rm -rf $(P) *.o

distclean: clean
	@echo DISTCLEAN
	@rm -rf *~
	@rm -rf #*
	@rm -rf tags