Makefile.embed 1.2 KB
Newer Older
1 2 3 4 5 6 7 8
PLATFORM=$(shell uname -s)

ifneq (,$(CROSS_COMPILE))
	PREFIX=$(CROSS_COMPILE)-
else
	PREFIX=
endif

9
MINGW=0
10
ifneq (,$(findstring MINGW32,$(PLATFORM)))
11
	MINGW=1
12 13
endif
ifneq (,$(findstring mingw,$(CROSS_COMPILE)))
14
	MINGW=1
15
endif
16

17
rm=rm -f
18 19 20
AR=$(PREFIX)ar cq
RANLIB=$(PREFIX)ranlib

21
LIBNAME=libgit2.a
22

23
ifeq ($(MINGW),1)
24 25 26 27
	CC=gcc
else
	CC=cc
endif
28

29 30
CC:=$(PREFIX)$(CC)

31
INCLUDES= -I. -Isrc -Iinclude -Ideps/http-parser -Ideps/zlib
32

33
DEFINES= $(INCLUDES) -DNO_VIZ -DSTDC -DNO_GZIP -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $(EXTRA_DEFINES)
34
CFLAGS= -g $(DEFINES) -Wall -Wextra -Wno-missing-field-initializers -O2 $(EXTRA_CFLAGS)
35

36
SRCS = $(wildcard src/*.c) $(wildcard src/transports/*.c) $(wildcard src/xdiff/*.c) $(wildcard deps/http-parser/*.c) $(wildcard deps/zlib/*.c) src/hash/hash_generic.c
37

38
ifeq ($(MINGW),1)
39
	SRCS += $(wildcard src/win32/*.c) $(wildcard src/compat/*.c) deps/regex/regex.c
40
	INCLUDES += -Ideps/regex
41
	DEFINES += -DWIN32 -D_WIN32_WINNT=0x0501 -D__USE_MINGW_ANSI_STDIO=1
42
else
43
	SRCS += $(wildcard src/unix/*.c) 
44 45 46
	CFLAGS += -fPIC
endif

47 48 49 50 51 52 53 54 55 56 57 58 59 60
OBJS = $(patsubst %.c,%.o,$(SRCS))

%.c.o:
	$(CC) $(CFLAGS) -c $*.c

all: $(LIBNAME)

$(LIBNAME): $(OBJS)
	$(rm) $@
	$(AR) $@ $(OBJS)
	$(RANLIB) $@

clean:
	$(rm) $(OBJS) $(LIBNAME)