-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
48 lines (34 loc) · 820 Bytes
/
makefile
File metadata and controls
48 lines (34 loc) · 820 Bytes
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
# 046267 Computer Architecture - Winter 20/21 - HW #1
# makefile for test environment
all: bp_main
# Environment for C
CC = gcc
CFLAGS = -std=c99 -Wall -g
# Environment for C++
CXX = g++
CXXFLAGS = -std=c++11 -Wall -g
# Automatically detect whether the bp is C or C++
# Must have either bp.c or bp.cpp - NOT both
SRC_BP = $(wildcard bp.c bp.cpp)
SRC_GIVEN = bp_main.c
EXTRA_DEPS = bp_api.h
OBJ_GIVEN = $(patsubst %.c,%.o,$(SRC_GIVEN))
OBJ_BP = bp.o
OBJ = $(OBJ_GIVEN) $(OBJ_BP)
#$(info OBJ=$(OBJ))
ifeq ($(SRC_BP),bp.c)
bp_main: $(OBJ)
$(CC) -o $@ $(OBJ) -lm
bp.o: bp.c
$(CC) -c $(CFLAGS) -o $@ $^ -lm
else
bp_main: $(OBJ)
$(CXX) -o $@ $(OBJ)
bp.o: bp.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $^ -lm
endif
$(OBJ_GIVEN): %.o: %.c
$(CC) -c $(CFLAGS) -o $@ $^ -lm
.PHONY: clean
clean:
rm -f bp_main $(OBJ)