File: Makefile.common

package info (click to toggle)
openttd-opensfx 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,576 kB
  • sloc: sh: 166; makefile: 70; python: 12
file content (144 lines) | stat: -rw-r--r-- 6,799 bytes parent folder | download | duplicates (2)
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
.PHONY: clean mrproper test all depend bundle bundle_src bundle_zip bundle_tar bundle_bzip docs check
.DEFAULT:

# Clean the source tree
clean:
	$(_E) "[Cleaning]"
	$(_V)-rm -rf *.orig *.pre *.bak *.grf *~
	$(_V)-rm -rf $(MAKEFILE_DEP) $(MAIN_TARGET) $(SRC_DIR)/*.nfo $(DOC_FILENAMES) $(REV_FILENAME) md5.check
	$(_V)-rm -rf $(CLEAN_ADD)

# More thoroughly clean the source tree. Should restore the initial
# state of a tarball (except for manual changes to Makefile.local, of
# course).
distclean: clean
	$(_V)-rm -rf $(SRC_DIR)/$(FILENAME_STUB) $(DIR_NAME_SRC) $(DIR_NAME)
	$(_V)for i in `ls -d $(DIR_BASE)*`; do if [ "$$i" != "$(MD5_FILENAME)" ]; then rm $$i; fi; done

# Even more thoroughly clean the tree. Intended to be used on a
# repository checkout. Also cleans files that are in a source tarball,
# but not in the repository.
mrproper: distclean
	$(_V)-rm -rf $(MD5_FILENAME)

# Print the output for a number of variables which define this newgrf.
test :
ifeq ($(PROJECT_TYPE),NFO)
	$(_E) "Call of nforenum:             $(NFORENUM) $(NFORENUM_FLAGS)"
	$(_E) "Call of grfcodec:             $(GRFCODEC) $(GRFCODEC_FLAGS)"
endif
	$(_E) "Make:                         $(MAKE)"
	$(_E) "MD5sum:                       $(MD5SUM)"
	$(_E) "unix2dos:                     $(UNIX2DOS)"
	$(_E) "gcc:                          $(CC) $(CC_FLAGS)"
	$(_E) "zip:                          $(ZIP) $(ZIP_FLAGS)"
	$(_E) "bzip:                         $(BZIP) $(BZIP_FLAGS)"
	$(_E) "Local installation directory: $(INSTALL_DIR)"
	$(_E) "Repository revision:          r$(REPO_REVISION)"
	$(_E) "Repository branch:            $(REPO_BRANCH)"
	$(_E) "Main target:                  $(MAIN_TARGET)"
	$(_E) "GRF files:                    $(GRF_FILES)"
	$(_E) "Doc files:                    $(DOC_FILES)"
ifeq ($(PROJECT_TYPE),NML)
	$(_E) "Language files:               $(LANG_FILES)"
endif
	$(_E) "REPO title:                   $(REPO_TITLE)"
	$(_E) "Bundled files:                $(BUNDLE_FILES)"
	$(_E) "Bundle filenames:             Tar=$(TAR_FILENAME) Zip=$(ZIP_FILENAME) Bz2=$(BZIP_FILENAME)"
	$(_E) "Dirs (build/src/base):        $(DIR_NAME) / $(DIR_NAME_SRC) / $(DIR_BASE)"
	$(_E) "Source dirs:                  $(MAIN_DIRS)"
	$(_E) "Source extensions (RE):       $(FILE_SRC_RE)"
	$(_E) "Repository dirs:              $(REPO_DIRS)"
	$(_E) "VPATH:                        $(VPATH)"
	$(_E) "Makefile:                     $(MAKEFILE)"
	$(_E) "Old Rev:                      $(shell [ -e $(REV_FILENAME) ] && cat $(REV_FILENAME) || "undefined")"
# uncomment the following two lines in order to get a list of all files which are considered to be part of the repo
# and the sub-list of those which are considered for the source bundle (for bundle_src)
#	$(_E) "Repository files:             $(REPO_FILES)"
#	$(_E) "Bundle source files:          `for i in $(REPO_FILES); do for j in $(MAIN_DIRS); do echo "$$i" | grep "$$j"; done; done;`"
ifeq ($(OSTYPE),Linux)
	$(_E) "Host type:                    $(OSTYPE) (Linux)"
else
ifeq ($(OSTYPE),Darwin)
	$(_E) "Host type:                    $(OSTYPE) (Mac)"
else
ifeq ($(shell echo "$(OSTYPE)" | cut -d_ -f1),MINGW32)
	$(_E) "Host type:                    $(OSTYPE) (Win)"
else
	$(_E) "Host type:                    unknown (win?)"
endif
endif
endif

# The real targets which build the grf
ifeq ($(PROJECT_TYPE),NML)
%.grf: %.nml $(REV_FILENAME)
	$(_E) "[Generating] $@"
	$(_V) $(NML) $(NML_FLAGS) --grf $@ $<
else
%.grf: %.nfo
# pipe all nfo files through grfcodec and produce the grf(s)
	$(_E) "[Generating] $@ with dep $^"
	$(_V) $(GRFCODEC) ${GRFCODEC_FLAGS} $(notdir $@)
endif
# .INTERMEDIATE: %.nfo
.PRECIOUS: %.nfo %.nml
.SECONDARY: %.nfo %.nml

# pre-processing for NML - style projects:
%.nml: %.pnml $(REV_FILENAME)
	$(_E) "[Generating] $@ with dep $^"
	$(_V) $(CC) $(CC_FLAGS) $< > $@

# Dependencies have to be added by a separate make dep step
%.nfo: %.pnfo $(REV_FILENAME)
# replace the place holders for version and name by the respective variables:
	$(_E) "[Generating] $@ with dep $^"
	$(_V) $(CC) $(CC_FLAGS) $< | \
		sed -e "s/$(GRF_ID_DUMMY)/$(GRF_ID)/" -e "s/$(REPO_TITLE_DUMMY)/$(REPO_TITLE)/" \
		-e "s/$(OUTPUT_FILENAME_DUMMY)/$(FILENAME)/" -e "s/$(REPO_REVISION_DUMMY)/$(REPO_REVISION)/" \
		| grep -v -E '^#' > $(SRC_DIR)/$@
	$(_E) "[NFORENUM] $@"
	$(_V)-$(NFORENUM) ${NFORENUM_FLAGS} $@

%.txt: %.ptxt $(REV_FILENAME) md5
	$(_E) "[Generating] $@"
	$(_V) cat $< \
		| sed -e "s/$(REPO_TITLE_DUMMY)/$(REPO_TITLE)/" \
		| sed -e "s/$(GRF_ID_DUMMY)/$(GRF_ID)/" \
		| sed -e "s/$(REPO_REVISION_DUMMY)/$(REPO_REVISION)/" \
		| sed -e "s/$(OUTPUT_FILENAME_DUMMY)/$(OUTPUT_FILENAME)/" \
		| sed -e "s/$(GRF_MD5SUM_DUMMY)/$(shell cat $(MD5_FILENAME))/" \
		> $@
	$(_V) [ -z "$(UNIX2DOS)" ] || $(UNIX2DOS) $(UNIX2DOS_FLAGS) $@

docs: $(DOC_FILES)

# Create the dependencies
%.$(REV_EXTENSION):
	$(_E) "Version change detected. Re-build forced."
	$(_V) [ -e *.$(REV_EXTENSION) ] && rm *.$(REV_EXTENSION) || echo ""
	$(_V) touch $@
ifeq ($(PROJECT_TYPE),NML) # NML projects need to define some custom tags in a special file
	$(_V) echo "VERSION: $(VERSION_STRING)" > $(FILE_CUSTOM_TAGS)
	$(_V) echo "TITLE: $(REPO_TITLE)" >> $(FILE_CUSTOM_TAGS)
	$(_V) echo "FILENAME: $(MAIN_TARGET)" >> $(FILE_CUSTOM_TAGS)
endif

depend: $(MAKEFILE_DEP)
$(MAKEFILE_DEP): $(REV_FILENAME)
	$(_E) "[Generating] $(MAKEFILE_DEP)"
ifeq ($(PROJECT_TYPE),CATCODEC)			# BASE SOUND: special file format
	$(_V) echo "$(SRC_DIR)/$(MAIN_FILENAME_SRC): "`cat $(SRC_DIR)/$(MAIN_FILENAME_SRC) | $(AWK) 'BEGIN { FS = " " } ; { print $$1 }' | grep 'wav' | grep -v '^//' | sed 's/"//g' | sort | uniq` > $(MAKEFILE_DEP)
else # NFO and NML projects
	$(_V) for i in `$(REPO_FILES_CMD) | grep -E '($(FILE_SRC_RE)grf)$$'`; do echo "$$i: "`for j in $(FILE_SRC_EXTENSIONS) $(FILE_INC_EXTENSIONS); do cat $$i |  grep -v '^//' | grep -o "[a-zA-Z0-9/_.-]\+\.$$j" | sort | uniq; done` | grep -v -E ": $$" ; done | sort | uniq | $(AWK) '{ print $$0"\n\t$$(_V) touch $$@" }' > $(MAKEFILE_DEP)
	$(_V) for i in `ls Makefile* scripts/* | grep -v Makefile.dep`; do echo "Makefile.dep: $$i"; done >> $(MAKEFILE_DEP)
ifeq ($(PROJECT_TYPE),NML)              # We need to take care of the language file which is not referenced in the source
	$(_V) echo "$(MAIN_TARGET): $(LANG_FILES)" >> $(MAKEFILE_DEP)
endif
endif
	$(_V) [ -e $(REV_FILENAME) ] && [ "`cat $(REV_FILENAME)`" = "$(VERSION_STRING)" ] || echo "$(VERSION_STRING)" > $(REV_FILENAME)

addcheck:
	$(_E) "[Checking] for missing repo files:"
	$(_V) for i in `$(REPO_FILES_CMD) | grep -E '($(FILE_SRC_RE)grf)$$'`; do git status $$i `for j in $(FILE_SRC_EXTENSIONS) $(FILE_INC_EXTENSIONS); do cat $$i |  grep -v '^//' | grep -o "[a-zA-Z0-9/_.-]\+\.$$j" | sort | uniq; done`; done | sort | uniq  | grep "^?" && echo "Missing dependencies!" || echo "All is fine"