-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (70 loc) · 1.98 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# GNU Make
#
# General utility library makefile.
#
# Copyright (C) 2010 Curtis Dyer
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# The author may be contacted at: <dyer85@gmail.com>
# C compiler
CC = gcc
CFLAGS = -Wall -Wextra -pedantic -ansi -O3
# Assembler
# In this case, NASM is required; I like Intel syntax.
ASM = nasm
# *nix:
#FORMAT = elf
# Win32:
FORMAT = coff
# Librarian tool: this stores and manages the object code
LIB = ar
## Installation paths
# Possible Cygwin build
#LIB_DIR = /cygdrive/c/MinGW/lib
#INC_DIR = /cygdrive/c/MinGW/include/dutils
# Possible *nix build
LIB_DIR = /usr/local/lib
INC_DIR = /usr/local/include/dutils
# Library name
PROJECT = libdutil.a
## End of basic user configurable options ##
# Assembly build
asm_src := $(wildcard *.asm)
asm_obj := $(patsubst %.asm,%.o,$(asm_src))
# C build
src := $(wildcard *.c)
obj := $(patsubst %.c,%.o,$(src))
hdr := $(wildcard include/*.h)
file_hdr := $(notdir $(hdr))
$(PROJECT) : $(obj)
$(LIB) cr $@ $^ $(asm_obj)
$(obj) : $(src)
$(ASM) -f $(FORMAT) $(asm_src)
$(CC) $(CFLAGS) -c $^
$(src) : $(hdr)
.PHONY : clean install uninstall
clean :
rm -f $(obj) $(asm_obj)
install :
mkdir -p $(INC_DIR)
cp $(hdr) $(INC_DIR)
mv $(PROJECT) $(LIB_DIR)
uninstall :
rm -f $(LIB_DIR)/$(PROJECT)
for i in $(file_hdr); do \
rm -f $(INC_DIR)/$$i; \
done;