-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (87 loc) · 2.81 KB
/
Makefile
File metadata and controls
99 lines (87 loc) · 2.81 KB
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
#
# Makefile for pgwrap
#
# Created by Jayanth Chennamangalam on 2012.03.02
#
# C compiler and flags
CC = gcc
ifeq ($(shell uname), Darwin)
CFLAGS_INC_PGPLOT =-I/opt/local/include# define if needed (as -I[...])
else
CFLAGS_INC_PGPLOT =# define if needed (as -I[...])
endif
CFLAGS = -std=gnu99 -pedantic -Wall -fPIC $(CFLAGS_INC_PGPLOT)
CFLAGS_C_DEBUG = $(CFLAGS) -g -c
CFLAGS_C_RELEASE = $(CFLAGS) -O3 -c
ifeq ($(OPT_DEBUG), yes)
CFLAGS_C = $(CFLAGS_C_DEBUG)
else
CFLAGS_C = $(CFLAGS_C_RELEASE)
endif
# enable/disable the debug flag
ifeq ($(OPT_DEBUG), yes)
DDEBUG = -DDEBUG
endif
# directories
SRCDIR = src
MANDIR = man
LIBDIR = lib
# header file installation directory - modify if needed
INCINSTALLDIR = /usr/local/include
# library installation directory - modify if needed
LIBINSTALLDIR = /usr/local/lib
# man page installation directory - modify if needed
MANINSTALLDIR = /usr/local/share/man/man3
# command definitions
DELCMD = rm
ifeq ($(shell uname), Darwin)
all: colourmap.o \
pgwrap.o \
libpgwrap.a \
libpgwrap.1.dylib
else
all: colourmap.o \
pgwrap.o \
libpgwrap.a \
libpgwrap.so.1
endif
colourmap.o: $(SRCDIR)/colourmap.c \
$(SRCDIR)/pgwrap.h
$(CC) $(CFLAGS_C) $< -o $(LIBDIR)/$@
pgwrap.o: $(SRCDIR)/pgwrap.c \
$(SRCDIR)/pgwrap.h
$(CC) $(CFLAGS_C) $(SRCDIR)/pgwrap.c -o $(LIBDIR)/$@
libpgwrap.a: $(LIBDIR)/pgwrap.o $(LIBDIR)/colourmap.o
ar cr $(LIBDIR)/$@ $^
ifeq ($(shell uname), Darwin)
libpgwrap.1.dylib: $(LIBDIR)/pgwrap.o $(LIBDIR)/colourmap.o
ld -dylib -macosx_version_min 10.12 -undefined dynamic_lookup -o $(LIBDIR)/$@ -lc $^
else
libpgwrap.so.1: $(LIBDIR)/pgwrap.o $(LIBDIR)/colourmap.o
ld -shared -soname $@ -o $(LIBDIR)/$@ -lc $^
endif
# install the library and man pages
install:
@echo Copying libraries...
cp $(SRCDIR)/pgwrap.h $(INCINSTALLDIR)
ifeq ($(shell uname), Darwin)
cp $(LIBDIR)/libpgwrap.1.dylib $(LIBINSTALLDIR)
ln -sf $(LIBINSTALLDIR)/libpgwrap.1.dylib $(LIBINSTALLDIR)/libpgwrap.dylib
else
cp $(LIBDIR)/libpgwrap.so.1 $(LIBINSTALLDIR)
ln -sf $(LIBINSTALLDIR)/libpgwrap.so.1 $(LIBINSTALLDIR)/libpgwrap.so
ldconfig
endif
@echo DONE
#@echo Copying man pages...
#cp $(MANDIR)/*.1 $(MANINSTALLDIR)
#@echo DONE
clean:
$(DELCMD) $(LIBDIR)/colourmap.o
$(DELCMD) $(LIBDIR)/pgwrap.o
$(DELCMD) $(LIBDIR)/libpgwrap.a
ifeq ($(shell uname), Darwin)
$(DELCMD) $(LIBDIR)/libpgwrap.1.dylib
else
$(DELCMD) $(LIBDIR)/libpgwrap.so.1
endif