-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
47 lines (36 loc) · 984 Bytes
/
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
TARGET = ssld-extract
SRC = ${wildcard *.c}
OBJ = ${SRC:.c=.o}
CC ?= cc
CFLAGS = -Wall
LFLAGS =
INSTALL = install
INSTALL_ARGS = -o root -g wheel -m 755
INSTALL_DIR = /usr/local/bin/
ifeq (${CC}, ${filter ${CC}, cc clang})
CFLAGS += -std=c99 -pedantic
endif
all: debug
debug: CFLAGS += -g -DDEBUG
debug: LFLAGS += -g
debug: build
release: CFLAGS += -Os
release: LFLAGS += -s
release: clean build
build: build_host.h ${TARGET}
build_host.h:
@echo "#define BUILD_HOST \"`hostname`\"" > build_host.h
@echo "#define BUILD_OS \"`uname`\"" >> build_host.h
@echo "#define BUILD_PLATFORM \"`uname -m`\"" >> build_host.h
@echo "#define BUILD_KERNEL \"`uname -r`\"" >> build_host.h
${TARGET}: build_host.h ${OBJ}
${CC} ${LFLAGS} -o $@ ${OBJ}
%.o : %.c
${CC} ${CFLAGS} -c $?
install: release
${INSTALL} ${INSTALL_ARGS} ${TARGET} ${INSTALL_DIR}
@echo "DONE"
clean:
-rm -f build_host.h
-rm -f *.o ${TARGET}
.PHONY : all debug release build install clean