forked from cofyc/argparse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (39 loc) · 1.02 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
# Defaults
CFLAGS ?= -O3 -g -ggdb
LDFLAGS ?=
BASIC_CFLAGS = -Wall -Wextra -fPIC
BASIC_LDFLAGS =
# We use ALL_* variants
ALL_CFLAGS = $(BASIC_CFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(BASIC_LDFLAGS) $(LDFLAGS)
LIBNAME=libargparse
DYLIBSUFFIX=so
STLIBSUFFIX=a
DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX)
DYLIB_MAKE_CMD=$(CC) -shared -o $(DYLIBNAME) $(ALL_LDFLAGS)
STLIBNAME=$(LIBNAME).$(STLIBSUFFIX)
STLIB_MAKE_CMD=ar rcs $(STLIBNAME)
# Platform-specific overrides
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(uname_S),Darwin)
DYLIBSUFFIX=dylib
DYLIB_MAKE_CMD=$(CC) -shared -o $(DYLIBNAME) $(ALL_LDFLAGS)
endif
all: $(DYLIBNAME) $(STLIBNAME)
OBJS += argparse.o
OBJS += test_argparse.o
$(OBJS): %.o: %.c
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
$(DYLIBNAME): argparse.o
$(DYLIB_MAKE_CMD) $^
$(STLIBNAME): argparse.o
$(STLIB_MAKE_CMD) $^
test: test_argparse
@echo "###### Unit Test #####"
@./test.sh
test_argparse: $(OBJS)
$(CC) $(ALL_CFLAGS) -o $@ $^ $(ALL_LDFLAGS)
clean:
rm -rf test_argparse
rm -rf *.[ao]
rm -rf *.dylib