-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
190 lines (158 loc) · 5.93 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
############################################################################
# Makefile for the Volume Processing Library (libvp)
# Oliver Hinds <[email protected]> 2005-06-02
#######################################################################
# project name
export PROJECT = libvp
export MAJOR_VER = 1
export MINOR_VER = 1
export RELEASE_VER = 1
# operating system, mac, linux and win are supported
export OS = linux
# whether to build a static or shared library
export LIB_TYPE = shared
# IMPORTANT!! CHANGE THIS TO BIG IF ON NON-X86 PLATFORMS!!!
export ENDIAN = little
# whether to compile with debug, optimize flags
export DEBUG = 0
export OPTIM = 1
export STRIP = 1
export PROF = 0
export MEMLEAK = 0
# directories
export LIB_DEST_DIR = /usr/local/lib/
export HDR_DEST_DIR = /usr/local/include/
export LIB_DIR = /tmp/
export SRC_DIR = $(PWD)/src/
export OBJ_DIR = $(PWD)/obj/
################################ APPS ################################
export RM = /bin/rm -v
export ECHO = /bin/echo
export CC = /usr/bin/gcc
export AR = /usr/bin/ar
export INSTALL=sudo /usr/bin/install
export ROOTLN=sudo ln
export LDCONFIG=/sbin/ldconfig
# endian define flag
ifeq ($(ENDIAN),little)
ENDIAN_FLAG = -DLITTLE_ENDIAN
else
ENDIAN_FLAG = -DBIG_ENDIAN
endif
# jpeg includes and libs
ifeq ($(OS),mac)
# FINK_ROOT = /
LIB_TYPE = static
JPEG_INCS = -I$(FINK_ROOT)/sw/include
JPEG_LIBS = -L$(FINK_ROOT)/sw/lib -ljpeg
else
JPEG_INCS = -I/usr/include
JPEG_LIBS = -L/usr/lib -ljpeg
endif
# debug flag
ifeq ($(DEBUG),1)
DEBUG_FLAG = -g
endif
# profile flag
ifeq ($(PROF),1)
PROF_FLAG = -pg
endif
# optimize flag
ifeq ($(OPTIM),1)
OPTIM_FLAG = -O
endif
# strip flag
ifeq ($(STRIP),1)
STRIP_FLAG = -s
endif
# memleak catch flag
ifeq ($(MEMLEAK),1)
MEMLEAK_FLAG = -DMEMLEAK
endif
# flags for the compiler and linker
ifeq ($(OS),linux)
export fPIC = -fPIC
endif
export CINCL = -I$(SRC_DIR) -I$(SRC_DIR)/ljpg -I$(SRC_DIR)/dicom
export CFLAGS = $(fPIC) -Werror -Wall -Wno-unused-result $(MEMLEAK_FLAG) $(PROF_FLAG) $(JPEG_INCS) $(DEBUG_FLAG) $(OPTIM_FLAG) $(STRIP_FLAG) $(CINCL) $(ENDIAN_FLAG)
export LDFLAGS = $(PROF_FLAG) $(JPEG_LIBS)
# differences between mac and *nix
ifeq ($(OS),mac)
CFLAGS += -DMAC
LDFLAGS += -lobjc
endif
# specific flags for windows, these override earlier defs of cflags and ldflags
ifeq ($(OS),win)
LIB_TYPE = static
# export CFLAGS = -Wall -I/usr/include $(PROF_FLAG) $(JPEG_INCS) $(DEBUG_FLAG) $(OPTIM_FLAG) $(STRIP_FLAG)
export LDFLAGS = -L/usr/X11R6/lib $(JPEG_LIBS) -lm -lgsl -lz
endif
############################## SUFFIXES ##############################
## if any command to generate target flibvps, the target is deleted.
# (see http://www.gnu.org/manual/make/html_chapter/make_5.html#SEC48)
.DELETE_ON_ERROR:
.SUFFIXES:
.SUFFIXES: .o .c
# suffix rule for subsidiary source files
# (see http://www.gnu.org/manual/make/html_chapter/make_10.html#SEC111)
$(OBJ_DIR)/%.o: %.c %.h
@$(ECHO) '[make: building $@]'
$(CC) $(CFLAGS) -o $@ -c $<
HDR_FILES = $(wildcard *.h)
SRC_FILES = $(wildcard ./*.c)
TMP_FILES = $(patsubst ./%,$(OBJ_DIR)/%,$(SRC_FILES))
OBJ_FILES = $(TMP_FILES:.c=.o)
default: $(PROJECT)
debug:
$(MAKE) DEBUG=1 OPTIM=0 STRIP=0 $(PROJECT)
$(PROJECT): $(OBJ_FILES)
@$(ECHO) 'make: building lib$@ for $(OS)...'
cd $(SRC_DIR) && $(MAKE)
ifeq ($(LIB_TYPE),shared)
$(CC) -shared -Wl,-soname,$(PROJECT).so.$(MAJOR_VER) $(OBJ_DIR)/*.o -o $(LIB_DIR)/$(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LDFLAGS)
@$(ECHO) '############################################'
@$(ECHO) 'make: built [[email protected].$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER)] successfully!'
@$(ECHO) '############################################'
else
$(AR) rcs $(LIB_DIR)/$(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(OBJ_DIR)/*.o
@$(ECHO) '############################################'
@$(ECHO) 'make: built [[email protected].$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER)] successfully!'
@$(ECHO) '############################################'
endif
############################### INSTALL ################################
install: $(PROJECT)
$(INSTALL) -m 644 $(SRC_DIR)/*.h $(HDR_DEST_DIR)
$(INSTALL) -m 644 $(SRC_DIR)/dicom/*.h $(HDR_DEST_DIR)
$(INSTALL) -m 644 $(SRC_DIR)/ljpg/*.h $(HDR_DEST_DIR)
ifeq ($(LIB_TYPE),shared)
@$(ECHO) 'make: installing $(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) for $(OS)...'
$(INSTALL) -m 644 $(LIB_DIR)/$(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)
$(ROOTLN) -sf $(LIB_DEST_DIR)/$(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)/$(PROJECT).so.$(MAJOR_VER)
$(ROOTLN) -sf $(LIB_DEST_DIR)/$(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)/$(PROJECT).so
ifeq ($(OS),linux)
$(LDCONFIG) -n $(LIB_DEST_DIR)
endif
@$(ECHO) '############################################'
@$(ECHO) 'make: installed [$(PROJECT).so.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER)] successfully!'
@$(ECHO) '############################################'
else
@$(ECHO) 'make: installing $(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) for $(OS)...'
cp $(LIB_DIR)/$(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)
$(ROOTLN) -sf $(LIB_DEST_DIR)/$(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)/$(PROJECT).a.$(MAJOR_VER)
$(ROOTLN) -sf $(LIB_DEST_DIR)/$(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER) $(LIB_DEST_DIR)/$(PROJECT).a
@$(ECHO) '############################################'
@$(ECHO) 'make: installed [$(PROJECT).a.$(MAJOR_VER).$(MINOR_VER).$(RELEASE_VER)] successfully!'
@$(ECHO) '############################################'
endif
############################### CLEAN ################################
clean:
@$(ECHO) 'make: removing object and autosave files'
-$(RM) -f $(OBJ_DIR)/*.o *~ $(SRC_DIR)/*~
cd $(SRC_DIR) && $(MAKE) clean
######################################################################
### $Source: /home/cvs/PROJECTS/VolumeProcessingLibrary/makefile,v $
### Local Variables:
### mode: makefile
### fill-column: 76
### comment-column: 0
### End: