summaryrefslogtreecommitdiff
path: root/Makefile
blob: 5e89fbd0f83f48bf9793a94b85685f704b210d63 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
#
#
# Makefile for sdb
#

#
HOST_OS := $(shell uname -s | tr A-Z a-z | cut -d'_' -f1)
LBITS := $(shell getconf LONG_BIT)
OBJDIR := bin
MODULE := sdb

# sdb host tool
# =========================================================

ifeq ($(HOST_OS),darwin)
	CC := clang
endif
#
ifeq ($(HOST_OS),linux)
	LOCAL_USB_SRC :=  src/usb_linux.c
	LOCAL_UTIL_SRC := src/utils_unix.c
	LOCAL_OTHER_SRC := src/fdevent.c src/fdevent_unix.c
	LOCAL_LFLAGS := -lrt -lpthread -ludev
	LOCAL_CFLAGS := -DOS_LINUX -DHAVE_FORKEXEC -DHAVE_TERMIO_H -DHAVE_SYMLINKS -DSDB_HOST=1 -DSDB_HOST_ON_TARGET=1 -D_FILE_OFFSET_BITS=64
endif

ifeq ($(HOST_OS),darwin)
	LOCAL_USB_SRC := src/usb_darwin.c
	LOCAL_UTIL_SRC := src/utils_unix.c
	LOCAL_OTHER_SRC := src/fdevent.c src/fdevent_unix.c
	LOCAL_LFLAGS := -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
	LOCAL_CFLAGS := -DOS_DARWIN -DHAVE_FORKEXEC -DHAVE_TERMIO_H -DHAVE_SYMLINKS -mmacosx-version-min=10.4 -DSDB_HOST=1 -DSDB_HOST_ON_TARGET=1
endif

ifeq ($(HOST_OS),mingw32)
	LOCAL_USB_SRC := src/usb_windows.c
	LOCAL_UTIL_SRC := src/utils_windows.c
	LOCAL_OTHER_SRC := src/fdevent.c  src/fdevent_windows.c
	LOCAL_CFLAGS := -DOS_WINDOWS
	LOCAL_IFLAGS := -I/mingw/include/ddk
	LOCAL_LFLAGS := -lws2_32
	LOCAL_STATIC_LFLAGS := /mingw/lib/libsetupapi.a
endif


SDB_SRC_FILES := \
	src/sdb.c \
	src/transport.c \
	src/transport_local.c \
	src/transport_usb.c \
	src/commandline.c \
	src/sdb_client.c \
	src/sockets.c \
	src/file_sync_client.c \
	$(LOCAL_USB_SRC) \
	src/device_vendors.c \
	$(LOCAL_UTIL_SRC) \
	$(LOCAL_OTHER_SRC) \
	src/utils.c \
	src/strutils.c \
	src/memutils.c \
	src/linkedlist.c \
	src/sdb_model.c \
	src/sdb_constants.c \
	src/file_sync_functions.c \
	src/command_function.c \
	src/log.c \
	src/listener.c \
	src/sdb_map.c

SDB_CFLAGS := -O2 -g -Wall -Wno-unused-parameter
SDB_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
SDB_CFLAGS += -Iinclude -Isrc
SDB_CFLAGS += $(LOCAL_CFLAGS)
ifeq ($(MAKE_DEBUG),true)
SDB_CFLAGS += -DMAKE_DEBUG
endif
SDB_LFLAGS := $(LOCAL_LFLAGS)
STATIC_LFLAGS := $(LOCAL_STATIC_LFLAGS)

all : $(MODULE)

sdb : $(SDB_SRC_FILES)
	mkdir -p $(OBJDIR)
	$(CC) $(SDB_CFLAGS) -o $(OBJDIR)/$(MODULE) $(SDB_SRC_FILES) $(LOCAL_IFLAGS) $(SDB_LFLAGS) $(STATIC_LFLAGS)

clean :
	rm -rf $(OBJDIR)