eclipse cdt 编译动态库,供msvc调用 -- 3.手写Makefile.cross
1 ##
2 ## libusp_bpm22.c
3 ##
4 ## Created by JK
5 ##
6
7 # General configuration variables:
8 CC = gcc
9 CXX = g++
10 AR = ar
11 RM = rm -rf
12 DEBUG =
13 CFLAGS = $(DEBUG) -O3 -Wall -c -fmessage-length=0 -MMD -MP
14 TIME = $(shell date +%Y%m%d)
15
16 OBJ = usbBasic.o cdebug.o libusp_BPM22.o
17
18 LIBS = -lusb-1.0 -lFreeImage
19
20 TOP_PATH = $(shell pwd)/..
21 LIB_PATH = -L$(TOP_PATH)/libs \
22 -L$(TOP_PATH)/libs/libusb-1.0.22 \
23 -L$(TOP_PATH)/libs/freeimage3180 \
24 -L$(TOP_PATH)/libs/plus
25 INC_PATH = -I$(TOP_PATH)/usbBasic \
26 -I$(TOP_PATH)/cDebug-log \
27 -I$(TOP_PATH)/libs
28
29 # All Target
30 all: libusp_BPM22.dll
31
32 usbBasic.o: $(TOP_PATH)/usbBasic/g_header.h $(TOP_PATH)/usbBasic/usbbasic.h
33 $(CXX) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/usbBasic/usbbasic.cpp
34
35 cdebug.o: $(TOP_PATH)/cDebug-log/cdebug.h
36 $(CXX) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/cDebug-log/cdebug.cpp
37
38 libusp_BPM22.o: $(TOP_PATH)/libusp_BPM22/src/libusp_bpm22.h
39 $(CC) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/libusp_BPM22/src/libusp_bpm22.c
40
41 libusp_BPM22.dll: $(OBJ)
42 @echo ''
43 @echo ''
44 @echo '-- Invoking: Cross G++ Linker With MinGW-GCC'
45 @echo '-- Building target: $@'
46 $(CXX) $(LIB_PATH) -shared -o "libusp_BPM22.dll" $(OBJ) $(LIBS)
47 @echo '-- Building target: libusp_BPM22.a'
48 $(CXX) $(LIB_PATH) -shared -o "libusp_BPM22.a" $(OBJ) $(LIBS)
49 @echo '-- Finished building target with makefile.cross'
50
51 clean:
52 -$(RM) $(OBJ) *.d libusp_BPM22.dll libusp_BPM22.def libusp_BPM22.lib libusp_BPM22.a
53 -@echo '-- Finished make clean'
54
55 package:
56 mkdir -p build$(TIME)
57 $(RM) build$(TIME)/*.*
58 mkdir -p build$(TIME)/gcc-win32 build$(TIME)/msvc
59 @pexports libusp_BPM22.dll > libusp_BPM22.def
60 @lib /machine:i386 /def:libusp_BPM22.def /out:libusp_BPM22.lib
61 @echo '-- Finished make objects with makefile.cross'
62 cp $(TOP_PATH)/usbBasic/g_header.h $(TOP_PATH)/libusp_BPM22/src/libusp_BPM22.h ./build$(TIME)/
63 cp -f libusp_BPM22.dll libusp_BPM22.a ./build$(TIME)/gcc-win32
64 cp -f libusp_BPM22.dll libusp_BPM22.lib ./build$(TIME)/msvc
65 @echo '-- 'build$(TIME) >>./readme.txt
66
67 clear:
68 -$(RM) $(OBJ) *.d libusp_BPM22.dll libusp_BPM22.def libusp_BPM22.lib libusp_BPM22.a libusp_BPM22.exp
69 -@echo '-- Finished make clear'
70
71 .PHONY: all clean dependents
参考博文:

浙公网安备 33010602011771号