-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
54 lines (44 loc) · 1.38 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Dummy builder for scramblenet project.
#FORWARD_TRAFFIC = -DFORWARD_UNMATCHED
CC = gcc
LD = gcc
# Options: -DPACK_EMU_INTERVAL_SHOW -DTIME_LOG -DNDEBUG
CFLAGS = -g -O3 -Wall -D_REENTRANT -DP_EMU_USE_SEMS
LDFLAGS = -lpthread -lrt -lm
OUTPUTFILE = p_emu.bin
#Source Directories
# Header file paths
INCLUDES = ./inc/ \
./libs/llib/ \
# Source file paths
SOURCE_PATHS = ./src \
./libs/llib \
# Gather all header files
INCLUDE_FILES =$(foreach d, $(INCLUDES), $(wildcard $d*.h))
# Gather all header paths and add -I flag
INC_PARAMS =$(foreach d, $(INCLUDES), -I $d)
# Gather all source files
SOURCE_FILES = $(foreach d, $(SOURCE_PATHS), $(wildcard $d/*.c))
# Gather all object files (source files changing ending)
OBJECTS = $(patsubst %.c,%.o,$(SOURCE_FILES))
# Rule for converting source files to object files (compile)
%.o: %.c $(INCLUDE_FILES)
$(CC) -c $(CFLAGS) $(INC_PARAMS) -o $@ $<
# Make all rule (linking)
all : $(OBJECTS)
@echo "Linking..."
$(LD) $(OBJECTS) $(LDFLAGS) -o $(OUTPUTFILE) -Wl,-Map=$(OUTPUTFILE).map
size $(OUTPUTFILE)
.PHONY: clean
# Make clean rule (removing binaries and object files)
clean:
@echo "Clean...."
rm -rf $(OBJECTS)
rm -rf ./$(OUTPUTFILE)
rm -rf ./$(OUTPUTFILE).map
# Make info rule (just show some stuff)
info:
@echo "Header Files....."
@echo $(INCLUDE_FILES)
@echo "Source Files....."
@echo $(SOURCE_FILES)