-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (41 loc) · 1.27 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
###########################################################################
#
# Filename: Makefile
#
# Author: Marcelo Mourier
# Created: Mon Dec 5 11:26:52 MST 2022
#
# Description: This makefile is used to build the 'grs' app
#
###########################################################################
#
# Copyright (c) 2023 Marcelo Mourier
#
###########################################################################
BIN_DIR = .
DEP_DIR = .
OBJ_DIR = .
OS := $(shell uname -o)
CFLAGS = -m64 -D_GNU_SOURCE -I. -ggdb -Wall -Werror -O0
LDFLAGS = -ggdb
ifeq ($(OS),Cygwin)
CFLAGS += -D__CYGWIN__
endif
SOURCES = $(wildcard *.c)
OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SOURCES))
DEPS := $(patsubst %.c,$(DEP_DIR)/%.d,$(SOURCES))
# Rule to autogenerate dependencies files
$(DEP_DIR)/%.d: %.c
@set -e; $(RM) $@; \
$(CC) -MM $(CPPFLAGS) $< > [email protected]; \
sed 's,\($*\)\.o[ :]*,$(OBJ_DIR)\/\1.o $@ : ,g' < [email protected] > $@; \
$(RM) [email protected]
# Rule to generate object files
$(OBJ_DIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
all: grs
grs: $(OBJECTS) Makefile
$(CC) $(LDFLAGS) -o $(BIN_DIR)/$@ $(OBJECTS)
clean:
$(RM) $(OBJECTS) $(OBJ_DIR)/build_info.o $(DEP_DIR)/*.d $(BIN_DIR)/grs
include $(DEPS)