-
Notifications
You must be signed in to change notification settings - Fork 14
/
makefile.rules
77 lines (61 loc) · 2.53 KB
/
makefile.rules
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
# -*- Makefile -*-
#
# This file contains make rules valid in all source directories
CFILES = $(SRC_CFILES)
# derive object files from C files
OBJECTS = $(CFILES:%.c=$(CURRPWD)%$(OBJ_SUFFIX))
# files to be included in distributed archives
DISTRIBUTEDFILES = $(CFILES) $(INCLUDES) depend makefile.*
# produce an object file from a C file
$(CURRPWD)%$(OBJ_SUFFIX): $(CURRPWD)%.c
$(CCTARGET) $(CFLAGS) $(COMPILEONLY) $< $(OBJFILE)$@
# work around compilers that blindly put objects in the current
# directory
@if [ 0 -eq $(OBJFILE_WORKS) -a $(notdir $@) != $@ ]; then \
mv -f $(notdir $@) $@; \
fi
# produce a typedef declaration
enum_include_guard= $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$(subst .,_,$(subst /,_,$(subst \,_,$(subst -,_,$(subst +,_,$(strip $@))))))))))))))))))))))))))))))))
$(CURRPWD)%.enum.h: $(CURRPWD)%.enum
( \
echo "#if !defined(${enum_include_guard})"; \
echo "#define ${enum_include_guard}"; \
echo ""; \
gcc -E -P -imacros $< -D ENUMERATION_DECLARE utilities/enumeration.h; \
echo "/* include $(notdir $<) to make sure that all the dependencies are generated correctly: */"; \
echo "#include \"$(notdir $<)\""; \
echo "#undef ENUMERATION_TYPENAME"; \
echo "#undef ENUMERATORS"; \
echo ""; \
echo "#endif"; \
) > $@
# produce a library form the object files in the current directory
$(CURRPWD)library.$(LIB_SUFFIX): $(OBJECTS) $(CURRPWD)makefile.local
$(ARCHIVER) $(ARCHIVERFLAGS) $(LIBFILE)$@ $(OBJECTS)
$(ARCHIVE_INDEXER) $@
# clean up after ourselves
clean: $(NESTED:%=%/clean)
rm -f $(OBJECTS) $(HOSTFILES) $(CURRPWD)library.$(LIB_SUFFIX) $(CURRPWD)core $(CURRPWD)*~
# clean up after ourselves in a nested directory
%/clean: FORCE
$(MAKE) CURRPWD=$(dir $@) -f $(dir $@)makefile.local clean
# generate source file dependencies file
depend:
ifdef DEPEND
$(CURRPWD)depend: $(SRC_CFILES:%=$(CURRPWD)%) $(INCLUDES:%=$(CURRPWD)%) $(CURRPWD)makefile.local
touch $@
chmod u+w $@
-for f in $(SRC_CFILES:%=$(CURRPWD)%); \
do \
$(MAKEDEPEND) \
-I. -MG -MT `echo $$f | sed -e "s/[.]c$$/$(OBJ_SUFFIX)/"` \
$$f \
| sed -e "s/[.]o:/\$$(OBJ_SUFFIX):/"; \
done > $@
endif
VERSIONDIR = $(VERSION)/$(CURRPWD)
$(CURRPWD)sourcedist: FORCE $(VERSIONDIR)
ln $(DISTRIBUTEDFILES:%=$(CURRPWD)%) $(VERSIONDIR)
$(VERSIONDIR):
mkdir -p $(VERSIONDIR)
FORCE: