-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (28 loc) · 912 Bytes
/
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
# -*- coding: utf-8 -*-
# Łukasz Czajka
CC := gcc
CFLAGS := -g -pedantic -Wall -c
LDFLAGS := -Wall
SOURCES := $(wildcard *.c)
MAINOBJECTS := $(subst .c,.o,$(shell egrep -l 'int[ \n\t]+main' $(SOURCES)))
ALL := $(subst .o,,$(MAINOBJECTS))
DEPENDS := $(subst .c,.d,$(SOURCES))
ALLOBJECTS := $(subst .c,.o,$(SOURCES))
OBJECTS := $(filter-out $(MAINOBJECTS),$(ALLOBJECTS))
all: $(DEPENDS) $(ALL)
$(DEPENDS) : %.d : %.c
$(CC) -MM $< > $@
printf "\t$(CC) $(CFLAGS) $<" >> $@
$(ALL) : % : %.o $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^
include $(DEPENDS)
clean:
-rm -f *.o $(ALL) $(ALLOBJECTS) $(DEPENDS)
Makefile: $(DEPENDS)
test: tests/calc tests/hello
tests/calc: all tests/calc.asm
./asm32 tests/calc.asm
ld -o tests/calc tests/calc.o -lc -dynamic-linker /lib/ld-linux.so.2
tests/hello: all tests/hello.asm
./asm32 tests/hello.asm
ld -o tests/hello tests/hello.o