Makefile:静态库与动态库:修订间差异

来自WHY42
imported>Soleverlee
(以“<source lang="make" highlight="15-19"> CC = gcc COMPILER_FLAGS = -O2 objects = mathApi.o main.o bin = hello.exe static = libmath.a shared = libmath.so all:main m...”为内容创建页面)
(没有差异)

2016年6月8日 (三) 06:58的版本

CC = gcc

COMPILER_FLAGS = -O2

objects = mathApi.o main.o
bin = hello.exe
static = libmath.a
shared = libmath.so

all:main

main:$(objects)
        $(CC) -o $(bin) $(objects)

static:mathApi.o
        ar cr $(static) mathApi.o

shared:mathApi.o
        $(CC) $(COMPILER_FLAG) mathApi.o -shared -fPIC -o $(shared)

.PHONY: clean
clean:
        rm -f $(objects) $(bin)