-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
147 lines (123 loc) · 3.01 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# main makefile
#
# build-time configuration should be done in config.mk
# see the config-sameple*.mk files for examples
TOPDIR=.
include include.mk
ifdef USE_SVNREV
SVNREV=$(shell svnversion -n |sed -r -e's/^([0-9]+:)?([0-9]+)[MSP]?/\2/')
ifeq ("$(SVNREV)","")
SVNREV=0
endif
else
SVNREV=0
endif
ifeq ($(OSTYPE),Windows)
SYS_LIBS=ws2_32 kernel32
IUP_SYS_LIBS=comctl32 ole32 gdi32 comdlg32 uuid
endif
ifeq ("$(PTPIP_SUPPORT)","1")
CFLAGS +=-DCHDKPTP_PTPIP=1
PTPIP_SRCS=sockutil.c
# ws2_32 already included
endif
# PTPIP
ifeq ($(OSTYPE),Linux)
# need 32 bit libs to do this
#TARGET_ARCH=-m32
endif
LINK_LIBS=$(LUA_LIB) $(LIBUSB_LIB)
ifdef LUA_LIB_DIR
LIB_PATHS+=-L$(LUA_LIB_DIR)
endif
ifdef LUA_INCLUDE_DIR
INC_PATHS+=-I$(LUA_INCLUDE_DIR)
endif
ifdef LIBUSB_LIB_DIR
LIB_PATHS+=-L$(LIBUSB_LIB_DIR)
endif
ifdef LIBUSB_INCLUDE_DIR
INC_PATHS+=-I$(LIBUSB_INCLUDE_DIR)
endif
ifdef READLINE_LIB_DIR
LIB_PATHS+=-L$(READLINE_LIB_DIR)
endif
ifdef READLINE_INCLUDE_DIR
INC_PATHS+=-I$(READLINE_INCLUDE_DIR)
endif
ifeq ("$(READLINE_SUPPORT)","1")
CFLAGS+=-DCHDKPTP_READLINE
SYS_LIBS+=$(READLINE_LIB)
endif
ifeq ("$(IUP_SUPPORT)","1")
ifdef IUP_LIB_DIR
LIB_PATHS+=-L$(IUP_LIB_DIR)
endif
ifdef IUP_INCLUDE_DIR
INC_PATHS+=-I$(IUP_INCLUDE_DIR)
endif
CFLAGS+=-DCHDKPTP_IUP=1
SYS_LIBS+=$(IUP_SYS_LIBS)
# CD only usable with IUP
ifeq ("$(CD_SUPPORT)","1")
ifdef CD_LIB_DIR
LIB_PATHS+=-L$(CD_LIB_DIR)
endif
ifdef CD_INCLUDE_DIR
INC_PATHS+=-I$(CD_INCLUDE_DIR)
endif
CFLAGS+=-DCHDKPTP_CD=1
SYS_LIBS+=$(IUP_SYS_LIBS)
LINK_LIBS=$(IUP_LUA_LIB) $(IUP_CD_LUA_LIB) $(CD_LUA_LIB) $(LUA_LIB) $(IUP_CD_LIB) $(CD_LIB) $(IUP_LIB) $(LIBUSB_LIB) $(CD_FREETYPE_LIB)
ifeq ($(OSTYPE),Windows)
SYS_LIBS+=winspool
endif
ifdef CD_USE_PLUS
SYS_LIBS+=$(CD_PLUS_SYS_LIBS)
LINK_LIBS+=$(CD_PLUS_LIB)
CFLAGS+=-DCHDKPTP_CD_PLUS=1
# TODO static/dynamic should be a top level option.
# This is required if you want to build a standalone context+ executable, otherwise libstdc++ and libgcc are dynamic
ifeq ($(OSTYPE),Windows)
LDFLAGS+=-static
endif
endif
else
LINK_LIBS=$(IUP_LUA_LIB) $(LUA_LIB) $(IUP_LIB) $(LIBUSB_LIB)
endif
# iup
endif
# needed for linking static lua lib on linux, should be harmless if dynamic linking
ifneq ($(OSTYPE),Windows)
LINK_LIBS+=m dl
endif
INC_PATHS+=-I$(CHDK_SRC_DIR)
CFLAGS+=$(INC_PATHS) -DCHDKPTP_BUILD_NUM=$(SVNREV) -DCHDKPTP_REL_DESC="\"alpha\""
LDFLAGS+=$(LIB_PATHS) $(patsubst %,-l%,$(LINK_LIBS) $(SYS_LIBS))
SUBDIRS=lfs
CHDKPTP_EXE=chdkptp$(EXE_EXTRA)$(EXE)
LIBNAME=libchdkptp.so
EXES=$(CHDKPTP_EXE)
all: $(EXES)
SRCS=properties.c ptp.c chdkptp.c lbuf.c liveimg.c rawimg.c luautil.c $(PTPIP_SRCS)
OBJS=$(SRCS:.c=.o)
$(CHDKPTP_EXE): $(OBJS)
$(CC) -o $@ lfs/lfs.o $^ $(LDFLAGS)
ifeq ($(OSTYPE),Darwin)
so: $(OBJS)
$(CC) $^ -shared -Wl,-install_name,$(LIBNAME) -o $(LIBNAME) -lc
else
ifeq ($(OSTYPE),Linux)
so: $(OBJS)
$(CC) $^ -shared -Wl,-soname,$(LIBNAME) -o $(LIBNAME) -lc
endif
endif
# temp for PTP/IP test code
ifeq ($(OSTYPE),Windows)
NET_LIBS=-lws2_32
else
NETLIBS=
endif
ptpip$(EXE): ptpip.c sockutil.c
$(CC) $(CFLAGS) -o $@ $^ $(NET_LIBS)
include bottom.mk