-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile.common
63 lines (45 loc) · 1.19 KB
/
Makefile.common
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
ifeq ($(TARGETOS),Mingw)
EXEDIR = ..
LIBDIR = ../libs
else
prefix = /usr/local
EXEDIR = $(DESTDIR)$(prefix)/bin
LIBDIR = $(DESTDIR)$(prefix)/lib/ovcc
endif
ODIR = obj
DEBUG=#-g #-D _DEBUG
OPT=-Ofast -march=native -flto # -Og # -Ofast #
WARN = -w # -Wall
PTHREAD = -pthread
ifeq ($(TARGETOS),Darwin)
CFLAGS += -D DARWIN
endif
SDLINC := $(shell pkg-config --cflags sdl2)
AGARINC := $(shell agar-config --cflags)
IDIR = $(INCDIR) $(SDLINC) $(AGARINC)
SDLLIB := $(shell sdl2-config --libs)
AGARLIB := $(shell agar-config --libs)
LIBS = $(SDLLIB) $(AGARLIB)
ifneq ($(TARGETOS),Darwin)
LIBS := $(LIBS) -lrt
endif
CFLAGS += $(DEBUG) $(OPT) $(WARN) $(IDIR)
LDFLAGS += $(LIBS) #-Wl,-export-all-symbols # -export-dynamic
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
$(TARGET): $(OBJS)
$(CC) -o $@ $(OPT) $^ $(LDFLAGS)
testlib: $(ODIR)/testlib.o
$(CC) -o $@ $< $(LIBS)
$(ODIR)/testlib.o: ../testlib.c | $(ODIR)
$(CC) -O0 -g -c $(SDLINC) $< -o $@
test: $(TARGET) testlib
LD_LIBRARY_PATH=. ./testlib $(TARGET) ModuleName
$(ODIR):
mkdir -p $@
$(OBJS): | $(ODIR)
$(OBJS):
$(CC) $(CFLAGS) -c $< -o $@
install: $(TARGET)
install -D --mode=0644 $(TARGET) $(LIBDIR)/$(TARGET)
clean:
rm -f $(ODIR)/*.o $(TARGET) testlib