-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
71 lines (59 loc) · 1.51 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
# https://github.com/danielpinto8zz6/c-cpp-project-generator#readme
CC = gcc
CFLAGS := -Wall -Wextra -g -Werror=missing-declarations -Werror=redundant-decls
LFLAGS = -lncurses
# OUTPUT := output
SRC := src
BUILDDIR := build
BINDIR := bin
INCLUDE := include
# LIB := lib
ifeq ($(OS),Windows_NT)
MAIN := pcalc.exe
SOURCEDIRS := $(SRC)
INCLUDEDIRS := $(INCLUDE)
# LIBDIRS := $(LIB)
FIXPATH = $(subst /,\,$1)
RM := del /q /f
MD := mkdir
else
MAIN := pcalc
SOURCEDIRS := $(shell find $(SRC) -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
# LIBDIRS := $(shell find $(LIB) -type d)
FIXPATH = $1
RM := rm -rf
MD := mkdir -p
CP := cp -i
endif
INCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))
# LIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%))
SOURCES := $(wildcard $(patsubst %,%/*.c, $(SOURCEDIRS)))
OBJECTS := $(patsubst $(SOURCEDIRS)/%,$(BUILDDIR)/%,$(SOURCES:.c=.o))
all: projdir $(MAIN)
@echo Executing "all" complete!
projdir:
@$(MD) $(BUILDDIR)
@$(MD) $(BINDIR)
$(MAIN): $(OBJECTS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(BINDIR)/$(MAIN) $(OBJECTS) $(LFLAGS) # $(LIBS)
$(BUILDDIR)/%.o: $(SOURCEDIRS)/%.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
.PHONY: clean
clean:
$(RM) $(BINDIR)
$(RM) $(BUILDDIR)
@echo Cleanup complete!
run: all
$(BINDIR)/$(MAIN)
@echo Executing "run: all" complete!
.PHONY: install
# Won't work for Windows Platform
install:
@echo "Installing!"
$(MAKE) all
@$(CP) $(BINDIR)/$(MAIN) /usr/local/bin
.PHONY: uninstall
uninstall:
@echo "Unistalling :("
@$(RM) $(shell whereis $(MAIN) | cut -d " " -f 2)