-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-c
61 lines (51 loc) · 1.53 KB
/
Makefile-c
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
55
56
57
58
59
60
61
## -----------------------------------------------------------------------------
## Created: Sun 26 Aug 2018 23:09:53 IST
## Last-Updated: Sun 26 Aug 2018 23:46:02 IST
##
## Makefile is part of be-comp-sem1
## URL: https://github.com/justinekizhak/be-comp-sem1
## Description: Makefile for c files
##
## Copyright (c) 2018, Justine Kizhakkinedath
## All rights reserved
##
## Licensed under the terms of MIT License
## See LICENSE file in the project root for full information.
## -----------------------------------------------------------------------------
# project name (generate executable with this name)
TARGET = assignment_name
CC = clang++
# compiling flags here
CFLAGS=-I$(IDIR) -Wall -g -O3
LINKER = clang++
# linking flags here
LFLAGS = -Wall -I. -lm
# change these to proper directories where each file should be
SRCDIR = src
OBJDIR = obj
BINDIR = bin
INCDIR = inc
LIBDIR = lib
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(INCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -f
MKDIR_P = mkdir -p
$(TARGET): $(OBJECTS)
@$(LINKER) $(OBJECTS) $(LFLAGS) -o $(BINDIR)/$@
@echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c directories
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"
directories:
@echo "Creating directories"
@$(MKDIR_P) $(SRCDIR)
@$(MKDIR_P) $(OBJDIR)
@$(MKDIR_P) $(BINDIR)
@$(MKDIR_P) $(INCDIR)
@$(MKDIR_P) $(LIBDIR)
.PHONY: clean
clean:
rm -f $(OBJDIR)/*.o
rm -f $(BINDIR)/*
@echo "Cleanup complete!"