forked from sciantix/sciantix-official
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (59 loc) · 2.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#//////////////////////////////////////////////////////////////////////////////////////
#// _______. ______ __ ___ .__ __. .___________. __ ___ ___ //
#// / | / || | / \ | \ | | | || | \ \ / / //
#// | (----`| ,----'| | / ^ \ | \| | `---| |----`| | \ V / //
#// \ \ | | | | / /_\ \ | . ` | | | | | > < //
#// .----) | | `----.| | / _____ \ | |\ | | | | | / . \ //
#// |_______/ \______||__| /__/ \__\ |__| \__| |__| |__| /__/ \__\ //
#// //
#// Originally developed by D. Pizzocri & T. Barani //
#// //
#// Version: 2.0 //
#// Year: 2022 //
#// Authors: T. Barani. //
#// //
#//////////////////////////////////////////////////////////////////////////////////////
CC := g++ # Windows and Linux
# CC := /opt/homebrew/bin/g++-12 # Mac OS
TARGET := sciantix.x
SRCDIR := src
INCDIR := include
BUILDDIR := obj
TARGETDIR := bin
RESDIR := src
SRCEXT := cpp
DEPEXT := d
OBJEXT := o
CFLAGS := -Wall -O -g
LIB := -lm
INC := -I$(INCDIR) -I/usr/local/include #also this may change according to your environment specs
INCDEP := -I$(INCDIR)
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
#####################################################################################
all: resources $(TARGET)
remake: cleaner all
resources: directories
@cp $(RESDIR)/* $(TARGETDIR)/
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
clean:
@$(RM) -rf $(BUILDDIR)
@$(RM) -rf $(TARGETDIR)/*.$(SRCEXT)
cleaner: clean
@$(RM) -rf $(TARGETDIR)
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
$(TARGET): $(OBJECTS)
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $(INC) -c -o $@ $<
@echo "Compiling C++ "$<" ... "
@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
@$(RM) -rf $(TARGETDIR)/*.$(SRCEXT)
.PHONY: all remake clean cleaner resources