-
Notifications
You must be signed in to change notification settings - Fork 2
/
cc.make
107 lines (100 loc) · 2.41 KB
/
cc.make
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
#
# Makefile to compile and maintain a fortran executable in SunOS
#
# Usage: type in your Sun > make -f cc.make
#
# created: I.Romero 20/05/2008
#-------------------------------------------------------------------
#
# Directory Paths for binaries and libraries
#
BIN_HOME = ../cc2noncc/bin
#
# List of Main Programs
# (Put a list of FORTRAN source files containing main programs
# here)
#
MAINS = cc2noncc.f
#
#
# Tools Libraries
# (Specify libraries to be linked in here. (e.g. orbit/attitude libs
# MIND the ORDER!)
#
# Use any of the following libraries if needed. Use ONLY the necessary ones!!
LIBS =
#
# Include Directory
# (Specify directories to pick up include files (MIND the ORDER!)
#
INCL = ./inc ../../inc
#
# Compiler (f77, g77, f90, etc)
FC = f77
#
# Compilation flags
# (Put the compilation flags here (-g is for debugging))
#
FFLAGS = -O3
#
#------------------------------------------------------------------------
# the rest is not likely to be changed
#------------------------------------------------------------------------
#
BIN_SUFFIX = .bin
#
#
# List of system libraries
# for example:
#LIBFDDB = -lfortran -lgen -l++ -lF77 -lsunmath -lC
LIBFDDB =
#
# List of source files, objects and binaries
#
LS_FORT = echo `ls *.f | grep -v "^," 2>/dev/null`
LIST_MOD = $(LS_FORT:sh)
LIST_OBJ = $(LIST_MOD:%.f=%.o)
XLS_SH = for file in $(LIST_OBJ);do X="0";for key in $(MAINS:%.f=%.o);\
do if test $$file = $$key;then X="1";fi;done;\
if test $$X = "0";then echo $$file;fi;done
LIST_SUBS = $(XLS_SH:sh)
LIST_EXEC = $(MAINS:%.f=$(BIN_HOME)/%.bin)
#
FFLAGS += $(INCL:%=-I%)
#
# Keep make status
#
.KEEP_STATE:
#
# default target (build when executing make w/o
# specifying target - maintains all binaries)
#
all: $(LIST_SUBS) $(LIST_EXEC)
# link binary (from library) and place in $(BIN_HOME)
#
$(LIST_EXEC): $$(@:$(BIN_HOME)/%$(BIN_SUFFIX)=%.o) $(LIST_OBJ) $(LIBS)
@echo "building" $@
@echo " since" $? "has changed"
$(LINK.f) $(@:$(BIN_HOME)/%$(BIN_SUFFIX)=%.o) -o $(@:$(BIN_HOME)/%=%) $(LIST_SUBS) $(LIBS) $(LIBFDDB)
@mv $(@:$(BIN_HOME)/%=%) $(BIN_HOME)
@touch .libs_status
#
# Build objects from source files
#
$(LIST_OBJ): $$(@:%.o=%.f)
@echo "compiling "
@$(COMPILE.f) $*.f -o $*.o
#
# CHECK
#
check: check_src check_libs
#
check_libs: .libs_status
#
.libs_status: $(DLIBS)
@echo $? has been changed
#
check_src: .src_status
#
.src_status: $(LIST_MOD)
@echo $? has been changed