模板一
CC:=/opt/mainline_toolchain-master/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
#CC:=gcc
RM:= rm -rf
INC:= -I./include/
LIBS:= -L./ -lmosquitto -pthread
TARGET:=Client
#COMPILE_TIME = $(shell date +"%Y%m%d-%H%M")
OBJS:= client_shared.o sub_client.o sub_client_output.o kyzh_protocol.o
all:$(OBJS)
$(CC) $^ $(INC) -o $(TARGET) $(LIBS)
$(CC) -o xxx xxx.c
%.o:%.c
$(CC) -c $< -o $@ $(LIBS) $(INC)
clean:
$(RM) $(OBJS) $(TARGET)
ln:
ln -s ./libmosquitto.so.1 /usr/local/lib/libmosquitto.so
模板二
CC:= gcc
#CUR_SOURCE=${wildcard *.c}
INC:= -I ./mbedtls
RM:= rm
TARGER:= main
CUR_OBJS += aes.o
CUR_OBJS += aesni.o
CUR_OBJS += platform.o
CUR_OBJS += platform_util.o
CUR_OBJS += aes_interf.o
//CUR_OBJS += PTC_common.o
all:$(CUR_OBJS)
$(CC) $^ $(INC) -o $(TARGER) -march=i486 -m32
#-m32 表示编译的可执行文件是32位的
%.o:%.c
$(CC) -c $< -o $@ $(INC) -march=i486 -m32
clean:
$(RM) $(CUR_OBJS) $(TARGET)
-march可用参数
-march=CPU[,+EXTENSION…]
generate code for CPU and EXTENSION, CPU is one of:
i8086, i186, i286, i386, i486, pentium, pentiumpro,
pentiumii, pentiumiii, pentium4, prescott, nocona,
core, core2, corei7, l1om, k6, k6_2, athlon, k8,
amdfam10, generic32, generic64
EXTENSION is combination of:
8087, 287, 387, no87, mmx, nommx, sse, sse2, sse3,
ssse3, sse4.1, sse4.2, sse4, nosse, avx, noavx,
vmx, smx, xsave, movbe, ept, aes, pclmul, fma,
clflush, syscall, rdtscp, 3dnow, 3dnowa, sse4a,
svme, abm, padlock, fma4, xop, lwp