-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (40 loc) · 1.25 KB
/
Makefile
File metadata and controls
51 lines (40 loc) · 1.25 KB
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
CC = gcc
CFLAGS = -Wall -c -Iinclude/ $(shell pkg-config --cflags libosu)
LFLAGS = $(shell pkg-config --libs libosu) -lm
TARGET = bnprdctr
BINFLR = bin/
all: CFLAGS += -g
all: $(TARGET)
unix64: CFLAGS += -m64
unix64: LFLAGS += -m64
unix64: $(TARGET)
unix32: CFLAGS += -m32
unix32: LFLAGS += -m32
unix32: $(TARGET)
win64: CC = x86_64-w64-mingw32-gcc
win64: LFLAGS += -static-libgcc -L.
win64: $(TARGET)
win32: CC = i686-w64-mingw32-gcc
win32: LFLAGS += -static-libgcc -static-libstdc++ -L.
win32: $(TARGET)
# Compiling specific object
%.o: %.c | $(BINFLR)
$(CC) $(CFLAGS) -o $(BINFLR)$(notdir $@) $<
# Compiling all objects to an executable
$(TARGET): $(addsuffix .o, $(basename $(shell find include/ -type f -name "*.h" | grep -Po '(?<=include/).*' | sed 's/^/src\//')))
$(CC) -o $(BINFLR)$@ $(addprefix $(BINFLR), $(notdir $^)) $(LFLAGS)
# Install
install:
$(shell cp ./bin/$(TARGET) /usr/local/bin/$(TARGET))
$(shell chmod 755 /usr/local/bin/$(TARGET))
$(shell ln -s /usr/local/bin/$(TARGET) /usr/bin/)
# Uninstall
uninstall:
$(shell test -L /usr/bin/$(TARGET) && unlink /usr/bin/$(TARGET))
$(shell test -f /usr/local/bin/$(TARGET) && rm -rf /usr/local/bin/$(TARGET))
# Make bin/ folder
$(BINFLR):
$(shell mkdir -p $@)
# Clean up
clean:
$(shell rm -rf $(BINFLR))