-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (66 loc) · 1.59 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# library name and version
PACKAGE_NAME:=himemmark
PACKAGE_VERSION:=1.0
# ----------------------------------------------------------------------------
# Define architectures -> gather system information
#
OS = $(shell uname -s)
OS_REL = $(shell uname -r)
ARCH = $(shell uname -m)
PROC = $(shell uname -p)
HOST = $(shell uname -n)
SYSTEM = $(OS)-$(ARCH)
NAME = $(shell uname -n)
#
EXEDIR = $(HOME)/bin
LIBDIR = $(HOME)/lib
BASE_NAME = $(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(SYSTEM)
LD_FLAGS = -lm
# ----------------------------------------------------------------------------
# Compiler options for specific machines.
#
CC = gcc -Wall -pedantic -ansi -Wstrict-prototypes
BASE_CFLAGS = -O2
ifdef GDB
BASE_CFLAGS = -O0 -g
endif
#
PROG_NAME = $(addsuffix -opt,$(BASE_NAME))
SYMLINK_NAME = $(addsuffix -opt,$(PACKAGE_NAME))
ifdef GDB
PROG_NAME = $(addsuffix -gdb,$(BASE_NAME))
SYMLINK_NAME = $(addsuffix -gdb,$(PACKAGE_NAME))
endif
EXE_NAME = $(PROG_NAME)
LIB_NAME = $(addsuffix .a,$(PROG_NAME))
SYMLINK_LIB_NAME = $(addsuffix .a,$(SYMLINK_NAME))
ifdef LINKLIB
PROG = $(LIB_NAME)
endif
ifdef LINKEXE
PROG = $(EXE_NAME)
CFLAGS = $(BASE_CFLAGS)
endif
C_FILES := $(wildcard *.c)
C_OBJECTS := $(patsubst %.c,%.o,$(C_FILES))
$(PROG): $(C_OBJECTS)
ifdef LINKEXE
$(CC) $(CFLAGS) -o $(PROG) *.o $(LD_FLAGS)
install $(PROG) $(EXEDIR)/$(PROG)
rm -f $(PROG)
endif
linkexe:
make LINKEXE=1
linkexe_gdb:
make LINKEXE=1 GDB=1
all:
make clean
make linkexe
make clean
make linkexe_gdb
make clean
.c.o:
$(CC) $(CFLAGS) -c $<
clean:
rm -rf *.o
# DO NOT DELETE THIS LINE -- make depend depends on it.