-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
76 lines (51 loc) · 1.51 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
CC=gcc
LD=gcc
AR=ar
prefix := /usr/local
CFLAGS=-std=gnu99 -Wall -O2 -I$(FITSIO_BASE)/include
ARFLAGS=rcs
SRCDIR=./src
# note order
TEST_LINKFLAGS=-L$(SRCDIR) -L$(FITSIO_BASE)/lib -lpsfex -lcfitsio -lm
REC_LINKFLAGS=-L$(SRCDIR) -L$(FITSIO_BASE)/lib -lpsfex -lcfitsio -lm
LIB_SOURCES = $(SRCDIR)/psfex.c $(SRCDIR)/psfex_fits.c $(SRCDIR)/poly.c
TEST_SOURCES = $(SRCDIR)/test.c
REC_SOURCES = $(SRCDIR)/psfex-rec.c
ALL_SOURCES = $(LIB_SOURCES) \
$(TEST_SOURCES) \
$(REC_SOURCES)
LIB_OBJECTS=$(patsubst %.c,%.o,$(LIB_SOURCES))
TEST_OBJECTS=$(patsubst %.c,%.o,$(TEST_SOURCES))
REC_OBJECTS=$(patsubst %.c,%.o,$(REC_SOURCES))
# these installed
LIB_BASE=libpsfex.a
LIB = $(SRCDIR)/$(LIB_BASE)
HEADER = $(SRCDIR)/psfex.h
TEST_PROG = $(SRCDIR)/test
REC_BASE = psfex-rec
REC_PROG = $(SRCDIR)/$(REC_BASE)
PROGS=$(TEST_PROG) $(REC_PROG)
DEPFILE=$(SRCDIR)/.depend
default: all
depend: $(DEPFILE)
$(DEPFILE): $(ALL_SOURCES)
$(CC) $(CFLAGS) -MM $^ > $(DEPFILE);
-include $(DEPFILE)
install: $(LIB)
mkdir -p $(prefix)/lib
mkdir -p $(prefix)/include
mkdir -p $(prefix)/bin
cp $(LIB) $(prefix)/lib/
cp $(HEADER) $(prefix)/include/
cp $(REC_PROG) $(prefix)/bin
chmod a+x $(prefix)/bin/$(REC_BASE)
all: $(TEST_PROG) $(REC_PROG)
lib: $(LIB)
$(LIB): $(LIB_OBJECTS)
$(AR) $(ARFLAGS) $(LIB) $(LIB_OBJECTS)
$(TEST_PROG): $(LIB) $(TEST_OBJECTS)
$(LD) -o $@ $(TEST_OBJECTS) $(TEST_LINKFLAGS)
$(REC_PROG): $(LIB) $(REC_OBJECTS)
$(LD) -o $@ $(REC_OBJECTS) $(REC_LINKFLAGS)
clean:
rm -f $(SRCDIR)/*.o $(LIB) $(PROGS) $(DEPFILE)