forked from 2xs/libpip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (46 loc) · 1.08 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
UNAME_S=$(shell uname -s)
# Use /usr/bin packages in Linux, MacPorts in Darwin
ifeq ($(UNAME_S),Linux)
CC=gcc
AR=ar
AS=gcc
endif
ifeq ($(UNAME_S),Darwin)
CC=/opt/local/bin/i386-elf-gcc
AR=/opt/local/bin/i386-elf-ar
AS=/opt/local/bin/i386-elf-gcc
endif
ifeq ($(UNAME_S),FreeBSD)
CC=gcc
AR=ar
AS=gcc
endif
# Directories
SRCDIR=src
INCDIR=include
# Generate source and object list
SOURCES=$(wildcard $(SRCDIR)/*.c)
OBJ=$(SOURCES:.c=.o)
ASOURCES=$(wildcard $(SRCDIR)/*.S)
AOBJ=$(ASOURCES:.S=.o)
# C compiler flags
CFLAGS=-c -ffreestanding -nostdlib -Wall -Werror -Wextra -fno-builtin -Wno-unused-parameter -Wno-unused-variable -m32 -O2 -fno-caller-saves
CFLAGS+=-I$(INCDIR)
ASFLAGS=-m32 -c -I. -I./include -fomit-frame-pointer --freestanding -nostdlib -fno-stack-protector
# Archiver flags
ARFLAGS=rcs
# Lib directory and output file
LIBDIR=lib
LIB=$(LIBDIR)/libpip.a
.PHONY: all
all: $(LIBDIR) $(LIB)
clean:
rm -rf $(LIBDIR) $(OBJ) $(AOBJ)
$(LIBDIR):
mkdir -p $(LIBDIR)
$(LIB): $(OBJ) $(AOBJ)
$(AR) $(ARFLAGS) $@ $^
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
%.o: %.S
$(AS) $(ASFLAGS) $< -o $@