-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
52 lines (38 loc) · 1.5 KB
/
makefile
File metadata and controls
52 lines (38 loc) · 1.5 KB
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
CC = gcc
CFLAGS = -ansi -g -Wall -pedantic -lm
MAIN = assembler
BIN = bin
SRC = src
HEDEARS = headers
OBJS = $(patsubst $(SRC)/%.c,$(BIN)/%.o,$(wildcard $(SRC)/*.c))
TESTDIR = tests
EXE = ./$(MAIN)
#auto rule to generate objects files
$(BIN)/%.o: $(SRC)/%.c $(wildcard $(HEADERS)/*.h)
$(CC) -c -o $@ $< $(CFLAGS)
default: $(BIN) $(MAIN)
@echo ""
@echo ""
@echo "Project binary is found in the current directory under the name '$(MAIN)'"
@echo "Sample tests cases can be found in '$(TESTDIR)' directory"
@echo ""
@echo "Use the following commands to run the project:"
@echo " - 'make clean' to delete all previous binaries"
@echo " - 'make test' to run all the test cases and see"
@echo " their output files in their respective directories"
@echo " under the $(TESTDIR) directory"
compile: $(BIN) $(MAIN)
$(MAIN): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS)
run: compile
$(EXE)
$(BIN):
@mkdir bin
.PHONY: clean run
objs-print:
@echo $(OBJS)
clean:
rm -rf bin
rm $(MAIN)
test: compile
$(EXE) $(TESTDIR)/shouldCompileSuccessfuly/shouldCompileSuccessfully $(TESTDIR)/shouldErrorData/shouldErrorData $(TESTDIR)/shouldErrorEntry/shouldErrorEntry $(TESTDIR)/shouldErrorExtern/shouldErrorExtern $(TESTDIR)/shouldErrorInvalidOperation/shouldErrorInvalidOperation $(TESTDIR)/shouldErrorJmp/shouldErrorJmp $(TESTDIR)/shouldErrorString/shouldErrorString $(TESTDIR)/shouldErrorStruct/shouldErrorStruct $(TESTDIR)/shouldErrorUndefinedLable/shouldErrorUndefinedLable $(TESTDIR)/shouldNotFindFile/shouldNotFindFile