File: example.mk

package info (click to toggle)
gmsl 1.1.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 240 kB
  • sloc: makefile: 6
file content (30 lines) | stat: -rw-r--r-- 740 bytes parent folder | download | duplicates (4)
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
# small sample Makefile do demonstrate usage of gmsl.
# Essentially, you should
#
# 1. include the library
# 2. invoke each function with $(call func,arg1,arg2,...)


include gmsl

# If any of the targets are "fail", throw an assertion. So 'make fail' will
# assert
$(call assert,$(call not,$(filter fail,$(MAKECMDGOALS))))



# If we're trying to compile with different -O flags at the same time, throw an
# error. So the following command to compile tst.c into tst.o will throw an
# error:
#
#   CFLAGS="-O1 -O2" make -n -f example.mk tst.o
define validate
$(if $(call chop,$(sort $(filter -O%,$1))), \
  $(error Have conflict with -O options in "$1"),$1)
endef

%.o: %.c
	$(CC) $(call validate,$(CPPFLAGS) $(CFLAGS)) -o $@ $<

%::
	true